Skip to content

Commit

Permalink
Stop trying to preserve pretty-printing.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Oct 16, 2023
1 parent 0eb958a commit 1f90d85
Show file tree
Hide file tree
Showing 35 changed files with 195 additions and 195 deletions.
34 changes: 17 additions & 17 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4263,30 +4263,30 @@ impl<'test> TestCx<'test> {
// to keep them numbered, to see if the same id appears multiple times.
// So we remap to deterministic numbers that only depend on the subset of allocations
// that actually appear in the output.
// We use uppercase ALLOC to distinguish from the non-normalized version.
{
use std::fmt::Write;

let re = Regex::new(r"(╾a|─a|\balloc)([0-9]+)\b(─|\+0x[0-9]+─)?").unwrap();
let mut seen_allocs = indexmap::IndexSet::new();

// The alloc-id appears in pretty-printed allocations.
let re = Regex::new(r"╾─*a(lloc)?([0-9]+)(\+0x[0-9]+)?─*╼").unwrap();
normalized = re
.replace_all(&normalized, |caps: &Captures<'_>| {
// Use uppercase to distinguish with the non-normalized version.
let mut ret = caps.get(1).unwrap().as_str().to_uppercase();
// Renumber the captured index.
let index = caps.get(2).unwrap().as_str().to_string();
let (index, _) = seen_allocs.insert_full(index);
write!(&mut ret, "{index}").unwrap();
// If we have a tail finishing with `─`, this means pretty-printing.
// Complete with filler `─` to preserve the pretty-print.
if let Some(tail) = caps.get(3) {
ret.push_str(tail.as_str());
let orig_len = caps.get(0).unwrap().as_str().len();
let ret_len = ret.len();
for _ in orig_len..ret_len {
ret.push('─');
}
}
ret
let offset = caps.get(3).map_or("", |c| c.as_str());
// Do not bother keeping it pretty, just make it deterministic.
format!("╾ALLOC{index}{offset}╼")
})
.into_owned();

// The alloc-id appears in a sentence.
let re = Regex::new(r"\balloc([0-9]+)\b").unwrap();
normalized = re
.replace_all(&normalized, |caps: &Captures<'_>| {
let index = caps.get(1).unwrap().as_str().to_string();
let (index, _) = seen_allocs.insert_full(index);
format!("ALLOC{index}")
})
.into_owned();
}
Expand Down
36 changes: 18 additions & 18 deletions tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> () {
bb0: {
StorageLive(_1);
StorageLive(_2);
_2 = const {ALLOC0: &&[(Option<i32>, &[&str])]};
_2 = const {ALLOC9: &&[(Option<i32>, &[&str])]};
_1 = (*_2);
StorageDead(_2);
StorageDead(_1);
Expand All @@ -17,43 +17,43 @@ fn main() -> () {
}
}

ALLOC0 (static: FOO, size: 8, align: 4) {
ALLOC103 00 00 00 │ ╾──╼....
ALLOC9 (static: FOO, size: 8, align: 4) {
ALLOC003 00 00 00 │ ╾──╼....
}

ALLOC1 (size: 48, align: 4) {
0x0000 00 00 00 __ __ __ __ ╾ALLOC2──00 00 00 00 │ ....░░░░╾──╼....
0x1000 00 00 00 __ __ __ __ ╾ALLOC302 00 00 00 │ ....░░░░╾──╼....
0x2001 00 00 00 2a 00 00 00ALLOC403 00 00 00 │ ....*...╾──╼....
ALLOC0 (size: 48, align: 4) {
0x0000 00 00 00 __ __ __ __ ╾ALLOC100 00 00 00 │ ....░░░░╾──╼....
0x1000 00 00 00 __ __ __ __ ╾ALLOC202 00 00 00 │ ....░░░░╾──╼....
0x2001 00 00 00 2a 00 00 00ALLOC303 00 00 00 │ ....*...╾──╼....
}

ALLOC2 (size: 0, align: 4) {}
ALLOC1 (size: 0, align: 4) {}

ALLOC3 (size: 16, align: 4) {
ALLOC5──03 00 00 00ALLOC603 00 00 00 │ ╾──╼....╾──╼....
ALLOC2 (size: 16, align: 4) {
ALLOC403 00 00 00ALLOC503 00 00 00 │ ╾──╼....╾──╼....
}

ALLOC5 (size: 3, align: 1) {
ALLOC4 (size: 3, align: 1) {
66 6f 6f │ foo
}

ALLOC6 (size: 3, align: 1) {
ALLOC5 (size: 3, align: 1) {
62 61 72 │ bar
}

ALLOC4 (size: 24, align: 4) {
0x00 │ ╾ALLOC703 00 00 00ALLOC803 00 00 00 │ ╾──╼....╾──╼....
0x10 │ ╾ALLOC904 00 00 00 │ ╾──╼....
ALLOC3 (size: 24, align: 4) {
0x00 │ ╾ALLOC603 00 00 00ALLOC703 00 00 00 │ ╾──╼....╾──╼....
0x10 │ ╾ALLOC804 00 00 00 │ ╾──╼....
}

ALLOC7 (size: 3, align: 1) {
ALLOC6 (size: 3, align: 1) {
6d 65 68 │ meh
}

ALLOC8 (size: 3, align: 1) {
ALLOC7 (size: 3, align: 1) {
6d 6f 70 │ mop
}

ALLOC9 (size: 4, align: 1) {
ALLOC8 (size: 4, align: 1) {
6d c3 b6 70 │ m..p
}
40 changes: 20 additions & 20 deletions tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> () {
bb0: {
StorageLive(_1);
StorageLive(_2);
_2 = const {ALLOC0: &&[(Option<i32>, &[&str])]};
_2 = const {ALLOC9: &&[(Option<i32>, &[&str])]};
_1 = (*_2);
StorageDead(_2);
StorageDead(_1);
Expand All @@ -17,47 +17,47 @@ fn main() -> () {
}
}

ALLOC0 (static: FOO, size: 16, align: 8) {
───────ALLOC1───────03 00 00 00 00 00 00 00 │ ╾──────╼........
ALLOC9 (static: FOO, size: 16, align: 8) {
ALLOC003 00 00 00 00 00 00 00 │ ╾──────╼........
}

ALLOC1 (size: 72, align: 8) {
0x0000 00 00 00 __ __ __ __ ╾───────ALLOC2────────╼ │ ....░░░░╾──────╼
ALLOC0 (size: 72, align: 8) {
0x0000 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼
0x1000 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░
0x20 │ ╾───────ALLOC3───────02 00 00 00 00 00 00 00 │ ╾──────╼........
0x3001 00 00 00 2a 00 00 00───────ALLOC4───────╼ │ ....*...╾──────╼
0x20 │ ╾ALLOC202 00 00 00 00 00 00 00 │ ╾──────╼........
0x3001 00 00 00 2a 00 00 00ALLOC3╼ │ ....*...╾──────╼
0x4003 00 00 00 00 00 00 00 │ ........
}

ALLOC2 (size: 0, align: 8) {}
ALLOC1 (size: 0, align: 8) {}

ALLOC3 (size: 32, align: 8) {
0x00 │ ╾───────ALLOC5────────03 00 00 00 00 00 00 00 │ ╾──────╼........
0x10 │ ╾───────ALLOC6───────03 00 00 00 00 00 00 00 │ ╾──────╼........
ALLOC2 (size: 32, align: 8) {
0x00 │ ╾ALLOC403 00 00 00 00 00 00 00 │ ╾──────╼........
0x10 │ ╾ALLOC503 00 00 00 00 00 00 00 │ ╾──────╼........
}

ALLOC5 (size: 3, align: 1) {
ALLOC4 (size: 3, align: 1) {
66 6f 6f │ foo
}

ALLOC6 (size: 3, align: 1) {
ALLOC5 (size: 3, align: 1) {
62 61 72 │ bar
}

ALLOC4 (size: 48, align: 8) {
0x00 │ ╾───────ALLOC7───────03 00 00 00 00 00 00 00 │ ╾──────╼........
0x10 │ ╾───────ALLOC8───────03 00 00 00 00 00 00 00 │ ╾──────╼........
0x20 │ ╾───────ALLOC9───────04 00 00 00 00 00 00 00 │ ╾──────╼........
ALLOC3 (size: 48, align: 8) {
0x00 │ ╾ALLOC603 00 00 00 00 00 00 00 │ ╾──────╼........
0x10 │ ╾ALLOC703 00 00 00 00 00 00 00 │ ╾──────╼........
0x20 │ ╾ALLOC804 00 00 00 00 00 00 00 │ ╾──────╼........
}

ALLOC7 (size: 3, align: 1) {
ALLOC6 (size: 3, align: 1) {
6d 65 68 │ meh
}

ALLOC8 (size: 3, align: 1) {
ALLOC7 (size: 3, align: 1) {
6d 6f 70 │ mop
}

ALLOC9 (size: 4, align: 1) {
ALLOC8 (size: 4, align: 1) {
6d c3 b6 70 │ m..p
}
34 changes: 17 additions & 17 deletions tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> () {
bb0: {
StorageLive(_1);
StorageLive(_2);
_2 = const {ALLOC0: &&[(Option<i32>, &[&u8])]};
_2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]};
_1 = (*_2);
StorageDead(_2);
StorageDead(_1);
Expand All @@ -17,42 +17,42 @@ fn main() -> () {
}
}

ALLOC0 (static: FOO, size: 8, align: 4) {
ALLOC103 00 00 00 │ ╾──╼....
ALLOC9 (static: FOO, size: 8, align: 4) {
ALLOC003 00 00 00 │ ╾──╼....
}

ALLOC1 (size: 48, align: 4) {
0x0000 00 00 00 __ __ __ __ ╾ALLOC200 00 00 00 │ ....░░░░╾──╼....
0x1000 00 00 00 __ __ __ __ ╾ALLOC302 00 00 00 │ ....░░░░╾──╼....
0x2001 00 00 00 2a 00 00 00ALLOC403 00 00 00 │ ....*...╾──╼....
ALLOC0 (size: 48, align: 4) {
0x0000 00 00 00 __ __ __ __ ╾ALLOC100 00 00 00 │ ....░░░░╾──╼....
0x1000 00 00 00 __ __ __ __ ╾ALLOC202 00 00 00 │ ....░░░░╾──╼....
0x2001 00 00 00 2a 00 00 00ALLOC303 00 00 00 │ ....*...╾──╼....
}

ALLOC2 (size: 0, align: 4) {}
ALLOC1 (size: 0, align: 4) {}

ALLOC3 (size: 8, align: 4) {
ALLOC5╼ ╾ALLOC6╼ │ ╾──╼╾──╼
ALLOC2 (size: 8, align: 4) {
ALLOC4╼ ╾ALLOC5╼ │ ╾──╼╾──╼
}

ALLOC5 (size: 1, align: 1) {
ALLOC4 (size: 1, align: 1) {
05.
}

ALLOC6 (size: 1, align: 1) {
ALLOC5 (size: 1, align: 1) {
06.
}

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

ALLOC7 (size: 4, align: 1) {
ALLOC6 (size: 4, align: 1) {
2a 45 15 6f │ *E.o
}

ALLOC8 (size: 1, align: 1) {
ALLOC7 (size: 1, align: 1) {
2a │ *
}

ALLOC9 (size: 4, align: 1) {
ALLOC8 (size: 4, align: 1) {
2a 45 15 6f │ *E.o
}
36 changes: 18 additions & 18 deletions tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> () {
bb0: {
StorageLive(_1);
StorageLive(_2);
_2 = const {ALLOC0: &&[(Option<i32>, &[&u8])]};
_2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]};
_1 = (*_2);
StorageDead(_2);
StorageDead(_1);
Expand All @@ -17,45 +17,45 @@ fn main() -> () {
}
}

ALLOC0 (static: FOO, size: 16, align: 8) {
───────ALLOC1───────03 00 00 00 00 00 00 00 │ ╾──────╼........
ALLOC9 (static: FOO, size: 16, align: 8) {
ALLOC003 00 00 00 00 00 00 00 │ ╾──────╼........
}

ALLOC1 (size: 72, align: 8) {
0x0000 00 00 00 __ __ __ __ ╾───────ALLOC2───────╼ │ ....░░░░╾──────╼
ALLOC0 (size: 72, align: 8) {
0x0000 00 00 00 __ __ __ __ ╾ALLOC1╼ │ ....░░░░╾──────╼
0x1000 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░
0x20 │ ╾───────ALLOC3───────02 00 00 00 00 00 00 00 │ ╾──────╼........
0x3001 00 00 00 2a 00 00 00───────ALLOC4───────╼ │ ....*...╾──────╼
0x20 │ ╾ALLOC202 00 00 00 00 00 00 00 │ ╾──────╼........
0x3001 00 00 00 2a 00 00 00ALLOC3╼ │ ....*...╾──────╼
0x4003 00 00 00 00 00 00 00 │ ........
}

ALLOC2 (size: 0, align: 8) {}
ALLOC1 (size: 0, align: 8) {}

ALLOC3 (size: 16, align: 8) {
───────ALLOC5───────╼ ╾───────ALLOC6───────╼ │ ╾──────╼╾──────╼
ALLOC2 (size: 16, align: 8) {
ALLOC4╼ ╾ALLOC5╼ │ ╾──────╼╾──────╼
}

ALLOC5 (size: 1, align: 1) {
ALLOC4 (size: 1, align: 1) {
05.
}

ALLOC6 (size: 1, align: 1) {
ALLOC5 (size: 1, align: 1) {
06.
}

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

ALLOC7 (size: 4, align: 1) {
ALLOC6 (size: 4, align: 1) {
2a 45 15 6f │ *E.o
}

ALLOC8 (size: 1, align: 1) {
ALLOC7 (size: 1, align: 1) {
2a │ *
}

ALLOC9 (size: 4, align: 1) {
ALLOC8 (size: 4, align: 1) {
2a 45 15 6f │ *E.o
}
20 changes: 10 additions & 10 deletions tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() -> () {
bb0: {
StorageLive(_1);
StorageLive(_2);
_2 = const {ALLOC0: &&Packed};
_2 = const {ALLOC4: &&Packed};
_1 = (*_2);
StorageDead(_2);
StorageDead(_1);
Expand All @@ -17,31 +17,31 @@ fn main() -> () {
}
}

ALLOC0 (static: FOO, size: 4, align: 4) {
ALLOC1╼ │ ╾──╼
ALLOC4 (static: FOO, size: 4, align: 4) {
ALLOC0╼ │ ╾──╼
}

ALLOC1 (size: 168, align: 1) {
ALLOC0 (size: 168, align: 1) {
0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................
0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾ALLOC2──╼ │ ............╾──╼
0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾ALLOC1╼ │ ............╾──╼
0x2001 ef cd ab 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
0x3000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
0x4000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
0x5000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
0x6000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
0x7000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
0x8000 00 00 00 00 00 00 00 00 00ALLOC3──00 00 │ ..........╾──╼..
0x90 │ ╾A4+0x6300 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............
0x8000 00 00 00 00 00 00 00 00 00ALLOC200 00 │ ..........╾──╼..
0x90 │ ╾ALLOC3+0x6300 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............
0xa000 00 00 00 00 00 00 00 │ ........
}

ALLOC2 (size: 4, align: 4) {
ALLOC1 (size: 4, align: 4) {
2a 00 00 00*...
}

ALLOC3 (fn: main)
ALLOC2 (fn: main)

ALLOC4 (size: 100, align: 1) {
ALLOC3 (size: 100, align: 1) {
0x0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
0x1000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
0x2000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
Expand Down
Loading

0 comments on commit 1f90d85

Please sign in to comment.