Skip to content

Commit a8d90ba

Browse files
committed
Normalize alloc-id in tests.
1 parent a483969 commit a8d90ba

File tree

98 files changed

+308
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+308
-278
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ dependencies = [
697697
"getopts",
698698
"glob",
699699
"home",
700+
"indexmap 2.0.0",
700701
"lazycell",
701702
"libc",
702703
"miow",

src/tools/compiletest/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ colored = "2"
1111
diff = "0.1.10"
1212
unified-diff = "0.2.1"
1313
getopts = "0.2"
14+
indexmap = "2.0.0"
1415
miropt-test-tools = { path = "../miropt-test-tools" }
1516
build_helper = { path = "../build_helper" }
1617
tracing = "0.1"

src/tools/compiletest/src/runtest.rs

+28
Original file line numberDiff line numberDiff line change
@@ -4258,6 +4258,34 @@ impl<'test> TestCx<'test> {
42584258
V0_BACK_REF_RE.replace_all(&normalized, V0_BACK_REF_PLACEHOLDER).into_owned();
42594259
}
42604260

4261+
// Normalize AllocId counter
4262+
{
4263+
use std::fmt::Write;
4264+
4265+
let re = Regex::new(r"(╾a|─a|\balloc)([0-9]+)\b(─|\+0x[0-9]+─)?").unwrap();
4266+
let mut seen_allocs = indexmap::IndexSet::new();
4267+
normalized = re
4268+
.replace_all(&normalized, |caps: &Captures<'_>| {
4269+
// Use uppercase to distinguish with the non-normalized version.
4270+
let mut ret = caps.get(1).unwrap().as_str().to_uppercase();
4271+
// Renumber the captured index.
4272+
let index = caps.get(2).unwrap().as_str().to_string();
4273+
let (index, _) = seen_allocs.insert_full(index);
4274+
write!(&mut ret, "{index}").unwrap();
4275+
// If we have a tail finishing with `─`, this means pretty-printing.
4276+
// Complete with filler `─` to preserve the pretty-print.
4277+
if let Some(tail) = caps.get(3) {
4278+
ret.push_str(tail.as_str());
4279+
let diff = caps.get(0).unwrap().as_str().len() - ret.len();
4280+
for _ in 0..diff {
4281+
ret.push('─');
4282+
}
4283+
}
4284+
ret
4285+
})
4286+
.into_owned();
4287+
}
4288+
42614289
// Custom normalization rules
42624290
for rule in custom_rules {
42634291
let re = Regex::new(&rule.0).expect("bad regex in custom normalization rule");

tests/mir-opt/building/custom/consts.statics.built.after.mir

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ fn statics() -> () {
66
let mut _2: *mut i32;
77

88
bb0: {
9-
_1 = const {alloc1: &i32};
10-
_2 = const {alloc2: *mut i32};
9+
_1 = const {ALLOC0: &i32};
10+
_2 = const {ALLOC1: *mut i32};
1111
return;
1212
}
1313
}
1414

15-
alloc2 (static: T, size: 4, align: 4) {
15+
ALLOC1 (static: T, size: 4, align: 4) {
1616
0a 0a 0a 0a │ ....
1717
}
1818

19-
alloc1 (static: S, size: 4, align: 4) {
19+
ALLOC0 (static: S, size: 4, align: 4) {
2020
05 05 05 05 │ ....
2121
}

tests/mir-opt/byte_slice.main.SimplifyCfg-elaborate-drops.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ fn main() -> () {
2323
}
2424
}
2525

26-
alloc1 (size: 3, align: 1) {
26+
ALLOC0 (size: 3, align: 1) {
2727
66 6f 6f │ foo
2828
}

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 {alloc1: &&[(Option<i32>, &[&str])]};
11+
_2 = const {ALLOC0: &&[(Option<i32>, &[&str])]};
1212
_1 = (*_2);
1313
StorageDead(_2);
1414
StorageDead(_1);
@@ -17,43 +17,43 @@ fn main() -> () {
1717
}
1818
}
1919

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

24-
alloc19 (size: 48, align: 4) {
25-
0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc6──╼ 00 00 00 00 │ ....░░░░╾──╼....
26-
0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc10─╼ 02 00 00 00 │ ....░░░░╾──╼....
27-
0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc15─╼ 03 00 00 00 │ ....*...╾──╼....
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 │ ....*...╾──╼....
2828
}
2929

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

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

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

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

44-
alloc15 (size: 24, align: 4) {
45-
0x00 │ ╾─alloc14─╼ 03 00 00 00 ╾─alloc16─╼ 03 00 00 00 │ ╾──╼....╾──╼....
46-
0x10 │ ╾─alloc17─╼ 04 00 00 00 │ ╾──╼....
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 │ ╾──╼....
4747
}
4848

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

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

57-
alloc17 (size: 4, align: 1) {
57+
ALLOC9 (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 {alloc1: &&[(Option<i32>, &[&str])]};
11+
_2 = const {ALLOC0: &&[(Option<i32>, &[&str])]};
1212
_1 = (*_2);
1313
StorageDead(_2);
1414
StorageDead(_1);
@@ -17,47 +17,47 @@ fn main() -> () {
1717
}
1818
}
1919

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

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

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

34-
alloc10 (size: 32, align: 8) {
35-
0x00 │ ╾───────alloc9────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
36-
0x10 │ ╾───────alloc11───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
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 │ ╾──────╼........
3737
}
3838

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

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

47-
alloc15 (size: 48, align: 8) {
48-
0x00 │ ╾───────alloc14───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
49-
0x10 │ ╾───────alloc16───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
50-
0x20 │ ╾───────alloc17───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
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 │ ╾──────╼........
5151
}
5252

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

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

61-
alloc17 (size: 4, align: 1) {
61+
ALLOC9 (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 {alloc1: &&[(Option<i32>, &[&u8])]};
11+
_2 = const {ALLOC0: &&[(Option<i32>, &[&u8])]};
1212
_1 = (*_2);
1313
StorageDead(_2);
1414
StorageDead(_1);
@@ -17,42 +17,42 @@ fn main() -> () {
1717
}
1818
}
1919

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

24-
alloc23 (size: 48, align: 4) {
25-
0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc10─╼ 00 00 00 00 │ ....░░░░╾──╼....
26-
0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc15─╼ 02 00 00 00 │ ....░░░░╾──╼....
27-
0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc21─╼ 03 00 00 00 │ ....*...╾──╼....
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 │ ....*...╾──╼....
2828
}
2929

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

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

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

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

44-
alloc21 (size: 12, align: 4) {
45-
╾─a18+0x3─╼ ╾─alloc19─╼ ╾─a20+0x2─╼ │ ╾──╼╾──╼╾──╼
44+
ALLOC4 (size: 12, align: 4) {
45+
╾─A7+0x3─╼ ╾─ALLOC8──╼ ╾─A9+0x2─╼ │ ╾──╼╾──╼╾──╼
4646
}
4747

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

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

56-
alloc20 (size: 4, align: 1) {
56+
ALLOC9 (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 {alloc1: &&[(Option<i32>, &[&u8])]};
11+
_2 = const {ALLOC0: &&[(Option<i32>, &[&u8])]};
1212
_1 = (*_2);
1313
StorageDead(_2);
1414
StorageDead(_1);
@@ -17,45 +17,45 @@ fn main() -> () {
1717
}
1818
}
1919

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)