Skip to content

Commit 42e3bd2

Browse files
committed
Stop trying to preserve pretty-printing.
1 parent 0eb958a commit 42e3bd2

35 files changed

+195
-193
lines changed

src/tools/compiletest/src/runtest.rs

+17-15
Original file line numberDiff line numberDiff line change
@@ -4263,30 +4263,32 @@ impl<'test> TestCx<'test> {
42634263
// to keep them numbered, to see if the same id appears multiple times.
42644264
// So we remap to deterministic numbers that only depend on the subset of allocations
42654265
// that actually appear in the output.
4266+
// We use uppercase ALLOC to distinguish from the non-normalized version.
42664267
{
42674268
use std::fmt::Write;
42684269

4269-
let re = Regex::new(r"(╾a|─a|\balloc)([0-9]+)\b(─|\+0x[0-9]+─)?").unwrap();
42704270
let mut seen_allocs = indexmap::IndexSet::new();
4271+
4272+
// The alloc-id appears in pretty-printed allocations.
4273+
let re = Regex::new(r"╾─*a(lloc)?([0-9]+)(\+0x[0-9]+)?─*╼").unwrap();
42714274
normalized = re
42724275
.replace_all(&normalized, |caps: &Captures<'_>| {
4273-
// Use uppercase to distinguish with the non-normalized version.
4274-
let mut ret = caps.get(1).unwrap().as_str().to_uppercase();
42754276
// Renumber the captured index.
42764277
let index = caps.get(2).unwrap().as_str().to_string();
42774278
let (index, _) = seen_allocs.insert_full(index);
4278-
write!(&mut ret, "{index}").unwrap();
4279-
// If we have a tail finishing with `─`, this means pretty-printing.
4280-
// Complete with filler `─` to preserve the pretty-print.
4281-
if let Some(tail) = caps.get(3) {
4282-
ret.push_str(tail.as_str());
4283-
let orig_len = caps.get(0).unwrap().as_str().len();
4284-
let ret_len = ret.len();
4285-
for _ in orig_len..ret_len {
4286-
ret.push('─');
4287-
}
4288-
}
4289-
ret
4279+
let offset = caps.get(3).map_or("", |c| c.as_str());
4280+
// Do not bother keeping it pretty, just make it deterministic.
4281+
format!("╾ALLOC{index}{offset}╼")
4282+
})
4283+
.into_owned();
4284+
4285+
// The alloc-id appears in a sentence.
4286+
let re = Regex::new(r"\balloc([0-9]+)\b").unwrap();
4287+
normalized = re
4288+
.replace_all(&normalized, |caps: &Captures<'_>| {
4289+
let index = caps.get(1).unwrap().as_str().to_string();
4290+
let (index, _) = seen_allocs.insert_full(index);
4291+
format!("ALLOC{index}")
42904292
})
42914293
.into_owned();
42924294
}

tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir

+18-18
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() -> () {
88
bb0: {
99
StorageLive(_1);
1010
StorageLive(_2);
11-
_2 = const {ALLOC0: &&[(Option<i32>, &[&str])]};
11+
_2 = const {ALLOC9: &&[(Option<i32>, &[&str])]};
1212
_1 = (*_2);
1313
StorageDead(_2);
1414
StorageDead(_1);
@@ -17,43 +17,43 @@ fn main() -> () {
1717
}
1818
}
1919

20-
ALLOC0 (static: FOO, size: 8, align: 4) {
21-
─ALLOC1─╼ 03 00 00 00 │ ╾──╼....
20+
ALLOC9 (static: FOO, size: 8, align: 4) {
21+
ALLOC0╼ 03 00 00 00 │ ╾──╼....
2222
}
2323

24-
ALLOC1 (size: 48, align: 4) {
25-
0x00 │ 00 00 00 00 __ __ __ __ ╾─ALLOC2──╼ 00 00 00 00 │ ....░░░░╾──╼....
26-
0x10 │ 00 00 00 00 __ __ __ __ ╾─ALLOC3─╼ 02 00 00 00 │ ....░░░░╾──╼....
27-
0x20 │ 01 00 00 00 2a 00 00 00 ╾─ALLOC4─╼ 03 00 00 00 │ ....*...╾──╼....
24+
ALLOC0 (size: 48, align: 4) {
25+
0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ 00 00 00 00 │ ....░░░░╾──╼....
26+
0x10 │ 00 00 00 00 __ __ __ __ ╾ALLOC2╼ 02 00 00 00 │ ....░░░░╾──╼....
27+
0x20 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ 03 00 00 00 │ ....*...╾──╼....
2828
}
2929

30-
ALLOC2 (size: 0, align: 4) {}
30+
ALLOC1 (size: 0, align: 4) {}
3131

32-
ALLOC3 (size: 16, align: 4) {
33-
─ALLOC5──╼ 03 00 00 00 ╾─ALLOC6─╼ 03 00 00 00 │ ╾──╼....╾──╼....
32+
ALLOC2 (size: 16, align: 4) {
33+
ALLOC4╼ 03 00 00 00 ╾ALLOC5╼ 03 00 00 00 │ ╾──╼....╾──╼....
3434
}
3535

36-
ALLOC5 (size: 3, align: 1) {
36+
ALLOC4 (size: 3, align: 1) {
3737
66 6f 6f │ foo
3838
}
3939

40-
ALLOC6 (size: 3, align: 1) {
40+
ALLOC5 (size: 3, align: 1) {
4141
62 61 72 │ bar
4242
}
4343

44-
ALLOC4 (size: 24, align: 4) {
45-
0x00 │ ╾─ALLOC7─╼ 03 00 00 00 ╾─ALLOC8─╼ 03 00 00 00 │ ╾──╼....╾──╼....
46-
0x10 │ ╾─ALLOC9─╼ 04 00 00 00 │ ╾──╼....
44+
ALLOC3 (size: 24, align: 4) {
45+
0x00 │ ╾ALLOC6╼ 03 00 00 00 ╾ALLOC7╼ 03 00 00 00 │ ╾──╼....╾──╼....
46+
0x10 │ ╾ALLOC8╼ 04 00 00 00 │ ╾──╼....
4747
}
4848

49-
ALLOC7 (size: 3, align: 1) {
49+
ALLOC6 (size: 3, align: 1) {
5050
6d 65 68 │ meh
5151
}
5252

53-
ALLOC8 (size: 3, align: 1) {
53+
ALLOC7 (size: 3, align: 1) {
5454
6d 6f 70 │ mop
5555
}
5656

57-
ALLOC9 (size: 4, align: 1) {
57+
ALLOC8 (size: 4, align: 1) {
5858
6d c3 b6 70 │ m..p
5959
}

tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir

+20-20
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() -> () {
88
bb0: {
99
StorageLive(_1);
1010
StorageLive(_2);
11-
_2 = const {ALLOC0: &&[(Option<i32>, &[&str])]};
11+
_2 = const {ALLOC9: &&[(Option<i32>, &[&str])]};
1212
_1 = (*_2);
1313
StorageDead(_2);
1414
StorageDead(_1);
@@ -17,47 +17,47 @@ fn main() -> () {
1717
}
1818
}
1919

20-
ALLOC0 (static: FOO, size: 16, align: 8) {
21-
───────ALLOC1───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
20+
ALLOC9 (static: FOO, size: 16, align: 8) {
21+
ALLOC0╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
2222
}
2323

24-
ALLOC1 (size: 72, align: 8) {
25-
0x00 │ 00 00 00 00 __ __ __ __ ╾───────ALLOC2────────╼ │ ....░░░░╾──────╼
24+
ALLOC0 (size: 72, align: 8) {
25+
0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼
2626
0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░
27-
0x20 │ ╾───────ALLOC3───────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........
28-
0x30 │ 01 00 00 00 2a 00 00 00 ╾───────ALLOC4───────╼ │ ....*...╾──────╼
27+
0x20 │ ╾ALLOC2╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........
28+
0x30 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ │ ....*...╾──────╼
2929
0x40 │ 03 00 00 00 00 00 00 00 │ ........
3030
}
3131

32-
ALLOC2 (size: 0, align: 8) {}
32+
ALLOC1 (size: 0, align: 8) {}
3333

34-
ALLOC3 (size: 32, align: 8) {
35-
0x00 │ ╾───────ALLOC5────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
36-
0x10 │ ╾───────ALLOC6───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
34+
ALLOC2 (size: 32, align: 8) {
35+
0x00 │ ╾ALLOC4╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
36+
0x10 │ ╾ALLOC5╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
3737
}
3838

39-
ALLOC5 (size: 3, align: 1) {
39+
ALLOC4 (size: 3, align: 1) {
4040
66 6f 6f │ foo
4141
}
4242

43-
ALLOC6 (size: 3, align: 1) {
43+
ALLOC5 (size: 3, align: 1) {
4444
62 61 72 │ bar
4545
}
4646

47-
ALLOC4 (size: 48, align: 8) {
48-
0x00 │ ╾───────ALLOC7───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
49-
0x10 │ ╾───────ALLOC8───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
50-
0x20 │ ╾───────ALLOC9───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
47+
ALLOC3 (size: 48, align: 8) {
48+
0x00 │ ╾ALLOC6╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
49+
0x10 │ ╾ALLOC7╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
50+
0x20 │ ╾ALLOC8╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
5151
}
5252

53-
ALLOC7 (size: 3, align: 1) {
53+
ALLOC6 (size: 3, align: 1) {
5454
6d 65 68 │ meh
5555
}
5656

57-
ALLOC8 (size: 3, align: 1) {
57+
ALLOC7 (size: 3, align: 1) {
5858
6d 6f 70 │ mop
5959
}
6060

61-
ALLOC9 (size: 4, align: 1) {
61+
ALLOC8 (size: 4, align: 1) {
6262
6d c3 b6 70 │ m..p
6363
}

tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir

+17-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() -> () {
88
bb0: {
99
StorageLive(_1);
1010
StorageLive(_2);
11-
_2 = const {ALLOC0: &&[(Option<i32>, &[&u8])]};
11+
_2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]};
1212
_1 = (*_2);
1313
StorageDead(_2);
1414
StorageDead(_1);
@@ -17,42 +17,42 @@ fn main() -> () {
1717
}
1818
}
1919

20-
ALLOC0 (static: FOO, size: 8, align: 4) {
21-
─ALLOC1─╼ 03 00 00 00 │ ╾──╼....
20+
ALLOC9 (static: FOO, size: 8, align: 4) {
21+
ALLOC0╼ 03 00 00 00 │ ╾──╼....
2222
}
2323

24-
ALLOC1 (size: 48, align: 4) {
25-
0x00 │ 00 00 00 00 __ __ __ __ ╾─ALLOC2─╼ 00 00 00 00 │ ....░░░░╾──╼....
26-
0x10 │ 00 00 00 00 __ __ __ __ ╾─ALLOC3─╼ 02 00 00 00 │ ....░░░░╾──╼....
27-
0x20 │ 01 00 00 00 2a 00 00 00 ╾─ALLOC4─╼ 03 00 00 00 │ ....*...╾──╼....
24+
ALLOC0 (size: 48, align: 4) {
25+
0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ 00 00 00 00 │ ....░░░░╾──╼....
26+
0x10 │ 00 00 00 00 __ __ __ __ ╾ALLOC2╼ 02 00 00 00 │ ....░░░░╾──╼....
27+
0x20 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ 03 00 00 00 │ ....*...╾──╼....
2828
}
2929

30-
ALLOC2 (size: 0, align: 4) {}
30+
ALLOC1 (size: 0, align: 4) {}
3131

32-
ALLOC3 (size: 8, align: 4) {
33-
─ALLOC5─╼ ╾─ALLOC6─╼ │ ╾──╼╾──╼
32+
ALLOC2 (size: 8, align: 4) {
33+
ALLOC4╼ ╾ALLOC5╼ │ ╾──╼╾──╼
3434
}
3535

36-
ALLOC5 (size: 1, align: 1) {
36+
ALLOC4 (size: 1, align: 1) {
3737
05 │ .
3838
}
3939

40-
ALLOC6 (size: 1, align: 1) {
40+
ALLOC5 (size: 1, align: 1) {
4141
06 │ .
4242
}
4343

44-
ALLOC4 (size: 12, align: 4) {
45-
─A7+0x3╼ ╾─ALLOC8─╼ ╾─A9+0x2╼ │ ╾──╼╾──╼╾──╼
44+
ALLOC3 (size: 12, align: 4) {
45+
ALLOC6+0x3╼ ╾ALLOC7╼ ╾ALLOC8+0x2╼ │ ╾──╼╾──╼╾──╼
4646
}
4747

48-
ALLOC7 (size: 4, align: 1) {
48+
ALLOC6 (size: 4, align: 1) {
4949
2a 45 15 6f │ *E.o
5050
}
5151

52-
ALLOC8 (size: 1, align: 1) {
52+
ALLOC7 (size: 1, align: 1) {
5353
2a │ *
5454
}
5555

56-
ALLOC9 (size: 4, align: 1) {
56+
ALLOC8 (size: 4, align: 1) {
5757
2a 45 15 6f │ *E.o
5858
}

tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir

+18-18
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() -> () {
88
bb0: {
99
StorageLive(_1);
1010
StorageLive(_2);
11-
_2 = const {ALLOC0: &&[(Option<i32>, &[&u8])]};
11+
_2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]};
1212
_1 = (*_2);
1313
StorageDead(_2);
1414
StorageDead(_1);
@@ -17,45 +17,45 @@ fn main() -> () {
1717
}
1818
}
1919

20-
ALLOC0 (static: FOO, size: 16, align: 8) {
21-
───────ALLOC1───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
20+
ALLOC9 (static: FOO, size: 16, align: 8) {
21+
ALLOC0╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
2222
}
2323

24-
ALLOC1 (size: 72, align: 8) {
25-
0x00 │ 00 00 00 00 __ __ __ __ ╾───────ALLOC2───────╼ │ ....░░░░╾──────╼
24+
ALLOC0 (size: 72, align: 8) {
25+
0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼
2626
0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░
27-
0x20 │ ╾───────ALLOC3───────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........
28-
0x30 │ 01 00 00 00 2a 00 00 00 ╾───────ALLOC4───────╼ │ ....*...╾──────╼
27+
0x20 │ ╾ALLOC2╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........
28+
0x30 │ 01 00 00 00 2a 00 00 00 ╾ALLOC3╼ │ ....*...╾──────╼
2929
0x40 │ 03 00 00 00 00 00 00 00 │ ........
3030
}
3131

32-
ALLOC2 (size: 0, align: 8) {}
32+
ALLOC1 (size: 0, align: 8) {}
3333

34-
ALLOC3 (size: 16, align: 8) {
35-
───────ALLOC5───────╼ ╾───────ALLOC6───────╼ │ ╾──────╼╾──────╼
34+
ALLOC2 (size: 16, align: 8) {
35+
ALLOC4╼ ╾ALLOC5╼ │ ╾──────╼╾──────╼
3636
}
3737

38-
ALLOC5 (size: 1, align: 1) {
38+
ALLOC4 (size: 1, align: 1) {
3939
05 │ .
4040
}
4141

42-
ALLOC6 (size: 1, align: 1) {
42+
ALLOC5 (size: 1, align: 1) {
4343
06 │ .
4444
}
4545

46-
ALLOC4 (size: 24, align: 8) {
47-
0x00 │ ╾─────ALLOC7+0x3─────╼ ╾───────ALLOC8───────╼ │ ╾──────╼╾──────╼
48-
0x10 │ ╾─────ALLOC9+0x2─────╼ │ ╾──────╼
46+
ALLOC3 (size: 24, align: 8) {
47+
0x00 │ ╾ALLOC6+0x3╼ ╾ALLOC7╼ │ ╾──────╼╾──────╼
48+
0x10 │ ╾ALLOC8+0x2╼ │ ╾──────╼
4949
}
5050

51-
ALLOC7 (size: 4, align: 1) {
51+
ALLOC6 (size: 4, align: 1) {
5252
2a 45 15 6f │ *E.o
5353
}
5454

55-
ALLOC8 (size: 1, align: 1) {
55+
ALLOC7 (size: 1, align: 1) {
5656
2a │ *
5757
}
5858

59-
ALLOC9 (size: 4, align: 1) {
59+
ALLOC8 (size: 4, align: 1) {
6060
2a 45 15 6f │ *E.o
6161
}

tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() -> () {
88
bb0: {
99
StorageLive(_1);
1010
StorageLive(_2);
11-
_2 = const {ALLOC0: &&Packed};
11+
_2 = const {ALLOC4: &&Packed};
1212
_1 = (*_2);
1313
StorageDead(_2);
1414
StorageDead(_1);
@@ -17,31 +17,31 @@ fn main() -> () {
1717
}
1818
}
1919

20-
ALLOC0 (static: FOO, size: 4, align: 4) {
21-
─ALLOC1─╼ │ ╾──╼
20+
ALLOC4 (static: FOO, size: 4, align: 4) {
21+
ALLOC0╼ │ ╾──╼
2222
}
2323

24-
ALLOC1 (size: 168, align: 1) {
24+
ALLOC0 (size: 168, align: 1) {
2525
0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................
26-
0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾─ALLOC2──╼ │ ............╾──╼
26+
0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾ALLOC1╼ │ ............╾──╼
2727
0x20 │ 01 ef cd ab 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
2828
0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
2929
0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
3030
0x50 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
3131
0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
3232
0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
33-
0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾─ALLOC3──╼ 00 00 │ ..........╾──╼..
34-
0x90 │ ╾A4+0x63╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............
33+
0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾ALLOC2╼ 00 00 │ ..........╾──╼..
34+
0x90 │ ╾ALLOC3+0x63╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............
3535
0xa0 │ 00 00 00 00 00 00 00 00 │ ........
3636
}
3737

38-
ALLOC2 (size: 4, align: 4) {
38+
ALLOC1 (size: 4, align: 4) {
3939
2a 00 00 00 │ *...
4040
}
4141

42-
ALLOC3 (fn: main)
42+
ALLOC2 (fn: main)
4343

44-
ALLOC4 (size: 100, align: 1) {
44+
ALLOC3 (size: 100, align: 1) {
4545
0x00 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
4646
0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
4747
0x20 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................

0 commit comments

Comments
 (0)