Skip to content

Commit b5be2bb

Browse files
committed
updated makefile for make clean and emit simpler mir
1 parent c558fe6 commit b5be2bb

File tree

5 files changed

+139
-231
lines changed

5 files changed

+139
-231
lines changed

kmir/Makefile

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
POETRY_RUN := poetry run
2+
13
.PHONY: default all clean build install \
24
poetry-install \
35
test test-unit test-integration \
@@ -10,21 +12,23 @@ default: check test-unit
1012

1113
all: check test
1214

15+
.PHONY: clean
1316
clean:
14-
rm -rf dist .mypy_cache
15-
find -type d -name __pycache__ -prune -exec rm -rf {} \;
17+
rm -rf dist .mypy_cache .pytest_cache
18+
find . -type d -name __pycache__ -prune -exec rm -rf {} \;
1619

20+
.PHONY: build
1721
build: poetry-install kbuild-llvm kbuild-haskell
1822
poetry build
1923

24+
.PHONY: poetry-install
2025
poetry-install:
2126
poetry install
2227

23-
POETRY_RUN := poetry run
24-
25-
2628
# Tests
2729

30+
TEST_ARGS :=
31+
2832
test: test-unit test-integration
2933

3034
test-unit: poetry-install

kmir/src/tests/integration/test-data/handwritten-rust/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ clean:
88

99
RUSTC:=rustc
1010
RUST_SOURCES=$(wildcard *.rs)
11-
RUSTC_OPTIONS=-C overflow-checks=off
11+
RUSTC_OPTIONS=-C overflow-checks=off -Zmir-enable-passes=-ConstDebugInfo,-PromoteTemps
1212

1313
mir: $(RUST_SOURCES:%.rs=%.mir)
1414
%.mir : %.rs
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,51 @@
11
// WARNING: This output format is intended for human consumers only
22
// and is subject to change without notice. Knock yourself out.
33
fn test(_1: usize, _2: usize) -> bool {
4-
debug x => _1; // in scope 0 at const-arithm-simple.rs:1:9: 1:10
5-
debug y => _2; // in scope 0 at const-arithm-simple.rs:1:19: 1:20
6-
let mut _0: bool; // return place in scope 0 at const-arithm-simple.rs:1:31: 1:35
7-
let mut _3: usize; // in scope 0 at const-arithm-simple.rs:2:12: 2:13
8-
let mut _4: usize; // in scope 0 at const-arithm-simple.rs:2:16: 2:17
4+
debug x => _1;
5+
debug y => _2;
6+
let mut _0: bool;
97

108
bb0: {
11-
_3 = _1; // scope 0 at const-arithm-simple.rs:2:12: 2:13
12-
_4 = _2; // scope 0 at const-arithm-simple.rs:2:16: 2:17
13-
_0 = Gt(move _3, move _4); // scope 0 at const-arithm-simple.rs:2:12: 2:17
14-
return; // scope 0 at const-arithm-simple.rs:3:2: 3:2
9+
_0 = Gt(_1, _2);
10+
return;
1511
}
1612
}
1713

1814
fn main() -> () {
19-
let mut _0: (); // return place in scope 0 at const-arithm-simple.rs:6:11: 6:11
20-
let _1: usize; // in scope 0 at const-arithm-simple.rs:7:7: 7:8
21-
let mut _4: usize; // in scope 0 at const-arithm-simple.rs:9:21: 9:22
22-
let mut _5: usize; // in scope 0 at const-arithm-simple.rs:9:24: 9:25
23-
let mut _6: bool; // in scope 0 at const-arithm-simple.rs:10:3: 10:13
24-
let mut _7: bool; // in scope 0 at const-arithm-simple.rs:10:11: 10:12
25-
let mut _8: !; // in scope 0 at const-arithm-simple.rs:10:3: 10:13
15+
let mut _0: ();
16+
let _1: usize;
17+
let mut _4: bool;
18+
let mut _5: bool;
19+
let mut _6: !;
2620
scope 1 {
27-
debug x => _1; // in scope 1 at const-arithm-simple.rs:7:7: 7:8
28-
let _2: usize; // in scope 1 at const-arithm-simple.rs:8:7: 8:8
21+
debug x => _1;
22+
let _2: usize;
2923
scope 2 {
30-
debug y => _2; // in scope 2 at const-arithm-simple.rs:8:7: 8:8
31-
let _3: bool; // in scope 2 at const-arithm-simple.rs:9:7: 9:8
24+
debug y => _2;
25+
let _3: bool;
3226
scope 3 {
33-
debug z => _3; // in scope 3 at const-arithm-simple.rs:9:7: 9:8
27+
debug z => _3;
3428
}
3529
}
3630
}
3731

3832
bb0: {
39-
_1 = const 42_usize; // scope 0 at const-arithm-simple.rs:7:17: 7:19
40-
_2 = const 0_usize; // scope 1 at const-arithm-simple.rs:8:17: 8:18
41-
_4 = const 42_usize; // scope 2 at const-arithm-simple.rs:9:21: 9:22
42-
_5 = const 0_usize; // scope 2 at const-arithm-simple.rs:9:24: 9:25
43-
_3 = test(move _4, move _5) -> bb1; // scope 2 at const-arithm-simple.rs:9:16: 9:26
44-
// mir::Constant
45-
// + span: const-arithm-simple.rs:9:16: 9:20
46-
// + literal: Const { ty: fn(usize, usize) -> bool {test}, val: Value(<ZST>) }
33+
_1 = const 42_usize;
34+
_2 = const 0_usize;
35+
_3 = test(_1, _2) -> bb1;
4736
}
4837

4938
bb1: {
50-
_7 = _3; // scope 3 at const-arithm-simple.rs:10:11: 10:12
51-
_6 = Not(move _7); // scope 3 at const-arithm-simple.rs:10:3: 10:13
52-
switchInt(move _6) -> [0: bb3, otherwise: bb2]; // scope 3 at const-arithm-simple.rs:10:3: 10:13
39+
_5 = _3;
40+
_4 = Not(move _5);
41+
switchInt(move _4) -> [0: bb3, otherwise: bb2];
5342
}
5443

5544
bb2: {
56-
_8 = core::panicking::panic(const "assertion failed: z"); // scope 3 at const-arithm-simple.rs:10:3: 10:13
57-
// mir::Constant
58-
// + span: const-arithm-simple.rs:10:3: 10:13
59-
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(<ZST>) }
60-
// mir::Constant
61-
// + span: no-location
62-
// + literal: Const { ty: &str, val: Value(Slice(..)) }
45+
_6 = core::panicking::panic(const "assertion failed: z");
6346
}
6447

6548
bb3: {
66-
return; // scope 0 at const-arithm-simple.rs:12:2: 12:2
49+
return;
6750
}
6851
}
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,111 @@
11
// WARNING: This output format is intended for human consumers only
22
// and is subject to change without notice. Knock yourself out.
33
fn test_binop(_1: usize, _2: usize) -> () {
4-
debug x => _1; // in scope 0 at test-binop.rs:1:15: 1:16
5-
debug y => _2; // in scope 0 at test-binop.rs:1:24: 1:25
6-
let mut _0: (); // return place in scope 0 at test-binop.rs:1:36: 1:38
7-
let mut _3: bool; // in scope 0 at test-binop.rs:2:5: 2:23
8-
let mut _4: bool; // in scope 0 at test-binop.rs:2:13: 2:22
9-
let mut _5: usize; // in scope 0 at test-binop.rs:2:13: 2:18
10-
let mut _6: usize; // in scope 0 at test-binop.rs:2:13: 2:14
11-
let mut _7: usize; // in scope 0 at test-binop.rs:2:17: 2:18
12-
let mut _8: usize; // in scope 0 at test-binop.rs:2:21: 2:22
13-
let mut _9: !; // in scope 0 at test-binop.rs:2:5: 2:23
14-
let mut _10: bool; // in scope 0 at test-binop.rs:3:5: 3:25
15-
let mut _11: bool; // in scope 0 at test-binop.rs:3:13: 3:24
16-
let mut _12: usize; // in scope 0 at test-binop.rs:3:13: 3:18
17-
let mut _13: usize; // in scope 0 at test-binop.rs:3:13: 3:14
18-
let mut _14: usize; // in scope 0 at test-binop.rs:3:17: 3:18
19-
let mut _15: !; // in scope 0 at test-binop.rs:3:5: 3:25
20-
let mut _16: bool; // in scope 0 at test-binop.rs:4:5: 4:28
21-
let mut _17: bool; // in scope 0 at test-binop.rs:4:13: 4:27
22-
let mut _18: usize; // in scope 0 at test-binop.rs:4:13: 4:18
23-
let mut _19: usize; // in scope 0 at test-binop.rs:4:13: 4:14
24-
let mut _20: usize; // in scope 0 at test-binop.rs:4:17: 4:18
25-
let mut _21: usize; // in scope 0 at test-binop.rs:4:22: 4:27
26-
let mut _22: usize; // in scope 0 at test-binop.rs:4:22: 4:23
27-
let mut _23: usize; // in scope 0 at test-binop.rs:4:26: 4:27
28-
let mut _24: !; // in scope 0 at test-binop.rs:4:5: 4:28
29-
let mut _25: bool; // in scope 0 at test-binop.rs:5:5: 5:25
30-
let mut _26: bool; // in scope 0 at test-binop.rs:5:13: 5:24
31-
let mut _27: usize; // in scope 0 at test-binop.rs:5:13: 5:18
32-
let mut _28: usize; // in scope 0 at test-binop.rs:5:13: 5:14
33-
let mut _29: usize; // in scope 0 at test-binop.rs:5:17: 5:18
34-
let mut _30: !; // in scope 0 at test-binop.rs:5:5: 5:25
35-
let mut _31: bool; // in scope 0 at test-binop.rs:6:5: 6:25
36-
let mut _32: bool; // in scope 0 at test-binop.rs:6:13: 6:24
37-
let mut _33: usize; // in scope 0 at test-binop.rs:6:13: 6:18
38-
let mut _34: usize; // in scope 0 at test-binop.rs:6:13: 6:14
39-
let mut _35: usize; // in scope 0 at test-binop.rs:6:17: 6:18
40-
let mut _36: !; // in scope 0 at test-binop.rs:6:5: 6:25
4+
debug x => _1;
5+
debug y => _2;
6+
let mut _0: ();
7+
let mut _3: bool;
8+
let mut _4: bool;
9+
let mut _5: usize;
10+
let mut _6: !;
11+
let mut _7: bool;
12+
let mut _8: bool;
13+
let mut _9: usize;
14+
let mut _10: !;
15+
let mut _11: bool;
16+
let mut _12: bool;
17+
let mut _13: usize;
18+
let mut _14: usize;
19+
let mut _15: !;
20+
let mut _16: bool;
21+
let mut _17: bool;
22+
let mut _18: usize;
23+
let mut _19: !;
24+
let mut _20: bool;
25+
let mut _21: bool;
26+
let mut _22: usize;
27+
let mut _23: !;
4128

4229
bb0: {
43-
_6 = _1; // scope 0 at test-binop.rs:2:13: 2:14
44-
_7 = _2; // scope 0 at test-binop.rs:2:17: 2:18
45-
_5 = Add(move _6, move _7); // scope 0 at test-binop.rs:2:13: 2:18
46-
_8 = _1; // scope 0 at test-binop.rs:2:21: 2:22
47-
_4 = Gt(move _5, move _8); // scope 0 at test-binop.rs:2:13: 2:22
48-
_3 = Not(move _4); // scope 0 at test-binop.rs:2:5: 2:23
49-
switchInt(move _3) -> [0: bb2, otherwise: bb1]; // scope 0 at test-binop.rs:2:5: 2:23
30+
_5 = Add(_1, _2);
31+
_4 = Gt(move _5, _1);
32+
_3 = Not(move _4);
33+
switchInt(move _3) -> [0: bb2, otherwise: bb1];
5034
}
5135

5236
bb1: {
53-
_9 = core::panicking::panic(const "assertion failed: x + y > x"); // scope 0 at test-binop.rs:2:5: 2:23
54-
// mir::Constant
55-
// + span: test-binop.rs:2:5: 2:23
56-
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(<ZST>) }
57-
// mir::Constant
58-
// + span: no-location
59-
// + literal: Const { ty: &str, val: Value(Slice(..)) }
37+
_6 = core::panicking::panic(const "assertion failed: x + y > x");
6038
}
6139

6240
bb2: {
63-
_13 = _1; // scope 0 at test-binop.rs:3:13: 3:14
64-
_14 = _2; // scope 0 at test-binop.rs:3:17: 3:18
65-
_12 = Add(move _13, move _14); // scope 0 at test-binop.rs:3:13: 3:18
66-
_11 = Eq(move _12, const 52_usize); // scope 0 at test-binop.rs:3:13: 3:24
67-
_10 = Not(move _11); // scope 0 at test-binop.rs:3:5: 3:25
68-
switchInt(move _10) -> [0: bb4, otherwise: bb3]; // scope 0 at test-binop.rs:3:5: 3:25
41+
_9 = Add(_1, _2);
42+
_8 = Eq(move _9, const 52_usize);
43+
_7 = Not(move _8);
44+
switchInt(move _7) -> [0: bb4, otherwise: bb3];
6945
}
7046

7147
bb3: {
72-
_15 = core::panicking::panic(const "assertion failed: x + y == 52"); // scope 0 at test-binop.rs:3:5: 3:25
73-
// mir::Constant
74-
// + span: test-binop.rs:3:5: 3:25
75-
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(<ZST>) }
76-
// mir::Constant
77-
// + span: no-location
78-
// + literal: Const { ty: &str, val: Value(Slice(..)) }
48+
_10 = core::panicking::panic(const "assertion failed: x + y == 52");
7949
}
8050

8151
bb4: {
82-
_19 = _1; // scope 0 at test-binop.rs:4:13: 4:14
83-
_20 = _2; // scope 0 at test-binop.rs:4:17: 4:18
84-
_18 = Add(move _19, move _20); // scope 0 at test-binop.rs:4:13: 4:18
85-
_22 = _2; // scope 0 at test-binop.rs:4:22: 4:23
86-
_23 = _1; // scope 0 at test-binop.rs:4:26: 4:27
87-
_21 = Add(move _22, move _23); // scope 0 at test-binop.rs:4:22: 4:27
88-
_17 = Eq(move _18, move _21); // scope 0 at test-binop.rs:4:13: 4:27
89-
_16 = Not(move _17); // scope 0 at test-binop.rs:4:5: 4:28
90-
switchInt(move _16) -> [0: bb6, otherwise: bb5]; // scope 0 at test-binop.rs:4:5: 4:28
52+
_13 = Add(_1, _2);
53+
_14 = Add(_2, _1);
54+
_12 = Eq(move _13, move _14);
55+
_11 = Not(move _12);
56+
switchInt(move _11) -> [0: bb6, otherwise: bb5];
9157
}
9258

9359
bb5: {
94-
_24 = core::panicking::panic(const "assertion failed: x + y == y + x"); // scope 0 at test-binop.rs:4:5: 4:28
95-
// mir::Constant
96-
// + span: test-binop.rs:4:5: 4:28
97-
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(<ZST>) }
98-
// mir::Constant
99-
// + span: no-location
100-
// + literal: Const { ty: &str, val: Value(Slice(..)) }
60+
_15 = core::panicking::panic(const "assertion failed: x + y == y + x");
10161
}
10262

10363
bb6: {
104-
_28 = _1; // scope 0 at test-binop.rs:5:13: 5:14
105-
_29 = _2; // scope 0 at test-binop.rs:5:17: 5:18
106-
_27 = Add(move _28, move _29); // scope 0 at test-binop.rs:5:13: 5:18
107-
_26 = Eq(move _27, const 52_usize); // scope 0 at test-binop.rs:5:13: 5:24
108-
_25 = Not(move _26); // scope 0 at test-binop.rs:5:5: 5:25
109-
switchInt(move _25) -> [0: bb8, otherwise: bb7]; // scope 0 at test-binop.rs:5:5: 5:25
64+
_18 = Add(_1, _2);
65+
_17 = Eq(move _18, const 52_usize);
66+
_16 = Not(move _17);
67+
switchInt(move _16) -> [0: bb8, otherwise: bb7];
11068
}
11169

11270
bb7: {
113-
_30 = core::panicking::panic(const "assertion failed: x + y == 52"); // scope 0 at test-binop.rs:5:5: 5:25
114-
// mir::Constant
115-
// + span: test-binop.rs:5:5: 5:25
116-
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(<ZST>) }
117-
// mir::Constant
118-
// + span: no-location
119-
// + literal: Const { ty: &str, val: Value(Slice(..)) }
71+
_19 = core::panicking::panic(const "assertion failed: x + y == 52");
12072
}
12173

12274
bb8: {
123-
_34 = _1; // scope 0 at test-binop.rs:6:13: 6:14
124-
_35 = _2; // scope 0 at test-binop.rs:6:17: 6:18
125-
_33 = Sub(move _34, move _35); // scope 0 at test-binop.rs:6:13: 6:18
126-
_32 = Eq(move _33, const 32_usize); // scope 0 at test-binop.rs:6:13: 6:24
127-
_31 = Not(move _32); // scope 0 at test-binop.rs:6:5: 6:25
128-
switchInt(move _31) -> [0: bb10, otherwise: bb9]; // scope 0 at test-binop.rs:6:5: 6:25
75+
_22 = Sub(_1, _2);
76+
_21 = Eq(move _22, const 32_usize);
77+
_20 = Not(move _21);
78+
switchInt(move _20) -> [0: bb10, otherwise: bb9];
12979
}
13080

13181
bb9: {
132-
_36 = core::panicking::panic(const "assertion failed: x - y == 32"); // scope 0 at test-binop.rs:6:5: 6:25
133-
// mir::Constant
134-
// + span: test-binop.rs:6:5: 6:25
135-
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(<ZST>) }
136-
// mir::Constant
137-
// + span: no-location
138-
// + literal: Const { ty: &str, val: Value(Slice(..)) }
82+
_23 = core::panicking::panic(const "assertion failed: x - y == 32");
13983
}
14084

14185
bb10: {
142-
return; // scope 0 at test-binop.rs:8:2: 8:2
86+
return;
14387
}
14488
}
14589

14690
fn main() -> () {
147-
let mut _0: (); // return place in scope 0 at test-binop.rs:11:11: 11:11
148-
let _1: usize; // in scope 0 at test-binop.rs:12:7: 12:8
149-
let _3: (); // in scope 0 at test-binop.rs:14:3: 14:19
150-
let mut _4: usize; // in scope 0 at test-binop.rs:14:14: 14:15
151-
let mut _5: usize; // in scope 0 at test-binop.rs:14:17: 14:18
91+
let mut _0: ();
92+
let _1: usize;
93+
let _3: ();
15294
scope 1 {
153-
debug x => _1; // in scope 1 at test-binop.rs:12:7: 12:8
154-
let _2: usize; // in scope 1 at test-binop.rs:13:7: 13:8
95+
debug x => _1;
96+
let _2: usize;
15597
scope 2 {
156-
debug y => _2; // in scope 2 at test-binop.rs:13:7: 13:8
98+
debug y => _2;
15799
}
158100
}
159101

160102
bb0: {
161-
_1 = const 42_usize; // scope 0 at test-binop.rs:12:11: 12:13
162-
_2 = const 10_usize; // scope 1 at test-binop.rs:13:11: 13:13
163-
_4 = const 42_usize; // scope 2 at test-binop.rs:14:14: 14:15
164-
_5 = const 10_usize; // scope 2 at test-binop.rs:14:17: 14:18
165-
_3 = test_binop(move _4, move _5) -> bb1; // scope 2 at test-binop.rs:14:3: 14:19
166-
// mir::Constant
167-
// + span: test-binop.rs:14:3: 14:13
168-
// + literal: Const { ty: fn(usize, usize) {test_binop}, val: Value(<ZST>) }
103+
_1 = const 42_usize;
104+
_2 = const 10_usize;
105+
_3 = test_binop(_1, _2) -> bb1;
169106
}
170107

171108
bb1: {
172-
return; // scope 0 at test-binop.rs:16:2: 16:2
109+
return;
173110
}
174111
}

0 commit comments

Comments
 (0)