Skip to content

Commit 5d56572

Browse files
Rollup merge of #126502 - cuviper:dump-mir-exclude-alloc-bytes, r=estebank
Ignore allocation bytes in some mir-opt tests This adds `rustc -Zdump-mir-exclude-alloc-bytes` to skip writing allocation bytes in MIR dumps, and applies it to tests that were failing on s390x due to its big-endian byte order. Fixes #126261
2 parents 62c068f + 7c3673f commit 5d56572

File tree

72 files changed

+205
-390
lines changed

Some content is hidden

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

72 files changed

+205
-390
lines changed

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ fn test_unstable_options_tracking_hash() {
691691
untracked!(dump_mir, Some(String::from("abc")));
692692
untracked!(dump_mir_dataflow, true);
693693
untracked!(dump_mir_dir, String::from("abc"));
694+
untracked!(dump_mir_exclude_alloc_bytes, true);
694695
untracked!(dump_mir_exclude_pass_number, true);
695696
untracked!(dump_mir_graphviz, true);
696697
untracked!(dump_mono_stats, SwitchWithOptPath::Enabled(Some("mono-items-dir/".into())));

compiler/rustc_middle/src/mir/pretty.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,9 @@ impl<'a, 'tcx, Prov: Provenance, Extra, Bytes: AllocBytes> std::fmt::Display
15451545
// We are done.
15461546
return write!(w, " {{}}");
15471547
}
1548+
if tcx.sess.opts.unstable_opts.dump_mir_exclude_alloc_bytes {
1549+
return write!(w, " {{ .. }}");
1550+
}
15481551
// Write allocation bytes.
15491552
writeln!(w, " {{")?;
15501553
write_allocation_bytes(tcx, alloc, w, " ")?;

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,8 @@ options! {
16871687
(default: no)"),
16881688
dump_mir_dir: String = ("mir_dump".to_string(), parse_string, [UNTRACKED],
16891689
"the directory the MIR is dumped into (default: `mir_dump`)"),
1690+
dump_mir_exclude_alloc_bytes: bool = (false, parse_bool, [UNTRACKED],
1691+
"exclude the raw bytes of allocations when dumping MIR (used in tests) (default: no)"),
16901692
dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
16911693
"exclude the pass number when dumping MIR (used in tests) (default: no)"),
16921694
dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],

tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff

+2-6
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@
119119
}
120120
}
121121

122-
ALLOC0 (size: 8, align: 4) {
123-
20 00 00 00 20 00 00 00 │ ... ...
124-
}
122+
ALLOC0 (size: 8, align: 4) { .. }
125123

126-
ALLOC1 (size: 4, align: 2) {
127-
01 00 63 00 │ ..c.
128-
}
124+
ALLOC1 (size: 4, align: 2) { .. }
129125

tests/mir-opt/const_debuginfo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ test-mir-pass: SingleUseConsts
2-
//@ compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN
2+
//@ compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN -Zdump-mir-exclude-alloc-bytes
33

44
#![allow(unused)]
55

tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444
StorageDead(_2);
4545
return;
4646
}
47-
+ }
48-
+
49-
+ ALLOC0 (size: 8, align: 4) {
50-
+ 01 00 00 00 00 __ __ __ │ .....░░░
5147
}
48+
+
49+
+ ALLOC0 (size: 8, align: 4) { .. }
5250

tests/mir-opt/const_prop/address_of_pair.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ test-mir-pass: GVN
2+
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes
23

34
// EMIT_MIR address_of_pair.fn0.GVN.diff
45
pub fn fn0() -> bool {

tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
StorageDead(_1);
2525
return;
2626
}
27-
+ }
28-
+
29-
+ ALLOC0 (size: 8, align: 4) {
30-
+ 02 00 00 00 00 __ __ __ │ .....░░░
3127
}
28+
+
29+
+ ALLOC0 (size: 8, align: 4) { .. }
3230

tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
StorageDead(_1);
2525
return;
2626
}
27-
+ }
28-
+
29-
+ ALLOC0 (size: 8, align: 4) {
30-
+ 02 00 00 00 00 __ __ __ │ .....░░░
3127
}
28+
+
29+
+ ALLOC0 (size: 8, align: 4) { .. }
3230

tests/mir-opt/const_prop/checked_add.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
22
//@ test-mir-pass: GVN
3-
//@ compile-flags: -C overflow-checks=on
3+
//@ compile-flags: -C overflow-checks=on -Zdump-mir-exclude-alloc-bytes
44

55
// EMIT_MIR checked_add.main.GVN.diff
66
fn main() {

tests/mir-opt/const_prop/mutable_variable_aggregate.main.GVN.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
StorageDead(_1);
2525
return;
2626
}
27-
+ }
28-
+
29-
+ ALLOC0 (size: 8, align: 4) {
30-
+ 2a 00 00 00 2b 00 00 00 │ *...+...
3127
}
28+
+
29+
+ ALLOC0 (size: 8, align: 4) { .. }
3230

tests/mir-opt/const_prop/mutable_variable_aggregate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ test-mir-pass: GVN
2+
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes
23

34
// EMIT_MIR mutable_variable_aggregate.main.GVN.diff
45
fn main() {

tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
StorageDead(_1);
3232
return;
3333
}
34-
+ }
35-
+
36-
+ ALLOC0 (size: 8, align: 4) {
37-
+ 2a 00 00 00 2b 00 00 00 │ *...+...
3834
}
35+
+
36+
+ ALLOC0 (size: 8, align: 4) { .. }
3937

tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ test-mir-pass: GVN
2+
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes
23

34
// EMIT_MIR mutable_variable_aggregate_mut_ref.main.GVN.diff
45
fn main() {

tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
+ nop;
4949
return;
5050
}
51-
+ }
52-
+
53-
+ ALLOC0 (size: 8, align: 4) {
54-
+ 01 00 00 00 02 00 00 00 │ ........
5551
}
52+
+
53+
+ ALLOC0 (size: 8, align: 4) { .. }
5654

tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
+ nop;
4949
return;
5050
}
51-
+ }
52-
+
53-
+ ALLOC0 (size: 8, align: 4) {
54-
+ 01 00 00 00 02 00 00 00 │ ........
5551
}
52+
+
53+
+ ALLOC0 (size: 8, align: 4) { .. }
5654

tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
22
//@ test-mir-pass: GVN
3+
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes
34

45
// EMIT_MIR mutable_variable_unprop_assign.main.GVN.diff
56
fn main() {

tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
+ _0 = const 4_u32;
1818
return;
1919
}
20-
+ }
21-
+
22-
+ ALLOC0 (size: 8, align: 4) {
23-
+ 04 00 00 00 00 __ __ __ │ .....░░░
2420
}
21+
+
22+
+ ALLOC0 (size: 8, align: 4) { .. }
2523

tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
+ _0 = const 4_u32;
1818
return;
1919
}
20-
+ }
21-
+
22-
+ ALLOC0 (size: 8, align: 4) {
23-
+ 04 00 00 00 00 __ __ __ │ .....░░░
2420
}
21+
+
22+
+ ALLOC0 (size: 8, align: 4) { .. }
2523

tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-abort.mir

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@ fn add() -> u32 {
1515
}
1616
}
1717

18-
ALLOC0 (size: 8, align: 4) {
19-
04 00 00 00 00 __ __ __ │ .....░░░
20-
}
18+
ALLOC0 (size: 8, align: 4) { .. }

tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@ fn add() -> u32 {
1515
}
1616
}
1717

18-
ALLOC0 (size: 8, align: 4) {
19-
04 00 00 00 00 __ __ __ │ .....░░░
20-
}
18+
ALLOC0 (size: 8, align: 4) { .. }

tests/mir-opt/const_prop/return_place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ test-mir-pass: GVN
22
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3-
//@ compile-flags: -C overflow-checks=on
3+
//@ compile-flags: -C overflow-checks=on -Zdump-mir-exclude-alloc-bytes
44

55
// EMIT_MIR return_place.add.GVN.diff
66
// EMIT_MIR return_place.add.PreCodegen.before.mir

tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
StorageDead(_1);
5050
return;
5151
}
52-
+ }
53-
+
54-
+ ALLOC0 (size: 12, align: 4) {
55-
+ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............
5652
}
53+
+
54+
+ ALLOC0 (size: 12, align: 4) { .. }
5755

tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
StorageDead(_1);
5050
return;
5151
}
52-
+ }
53-
+
54-
+ ALLOC0 (size: 12, align: 4) {
55-
+ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............
5652
}
53+
+
54+
+ ALLOC0 (size: 12, align: 4) { .. }
5755

tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
StorageDead(_1);
5050
return;
5151
}
52-
+ }
53-
+
54-
+ ALLOC0 (size: 12, align: 4) {
55-
+ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............
5652
}
53+
+
54+
+ ALLOC0 (size: 12, align: 4) { .. }
5755

tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
StorageDead(_1);
5050
return;
5151
}
52-
+ }
53-
+
54-
+ ALLOC0 (size: 12, align: 4) {
55-
+ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............
5652
}
53+
+
54+
+ ALLOC0 (size: 12, align: 4) { .. }
5755

tests/mir-opt/const_prop/slice_len.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ test-mir-pass: GVN
2-
//@ compile-flags: -Zmir-enable-passes=+InstSimplify
2+
//@ compile-flags: -Zmir-enable-passes=+InstSimplify -Zdump-mir-exclude-alloc-bytes
33
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
44
// EMIT_MIR_FOR_EACH_BIT_WIDTH
55

tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
+ nop;
3232
return;
3333
}
34-
+ }
35-
+
36-
+ ALLOC0 (size: 8, align: 4) {
37-
+ 01 00 00 00 02 00 00 00 │ ........
3834
}
35+
+
36+
+ ALLOC0 (size: 8, align: 4) { .. }
3937

tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
+ nop;
3232
return;
3333
}
34-
+ }
35-
+
36-
+ ALLOC0 (size: 8, align: 4) {
37-
+ 01 00 00 00 02 00 00 00 │ ........
3834
}
35+
+
36+
+ ALLOC0 (size: 8, align: 4) { .. }
3937

tests/mir-opt/const_prop/tuple_literal_propagation.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ test-mir-pass: GVN
2+
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes
23
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
34
// EMIT_MIR tuple_literal_propagation.main.GVN.diff
45

tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-abort.diff

+3-7
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,9 @@
7676
StorageDead(_1);
7777
return;
7878
}
79-
+ }
79+
}
8080
+
81-
+ ALLOC0 (size: 8, align: 4) {
82-
+ 00 00 00 80 01 __ __ __ │ .....░░░
83-
+ }
81+
+ ALLOC0 (size: 8, align: 4) { .. }
8482
+
85-
+ ALLOC1 (size: 8, align: 4) {
86-
+ 03 00 00 00 00 __ __ __ │ .....░░░
87-
}
83+
+ ALLOC1 (size: 8, align: 4) { .. }
8884

tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff

+3-7
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,9 @@
7676
StorageDead(_1);
7777
return;
7878
}
79-
+ }
79+
}
8080
+
81-
+ ALLOC0 (size: 8, align: 4) {
82-
+ 00 00 00 80 01 __ __ __ │ .....░░░
83-
+ }
81+
+ ALLOC0 (size: 8, align: 4) { .. }
8482
+
85-
+ ALLOC1 (size: 8, align: 4) {
86-
+ 03 00 00 00 00 __ __ __ │ .....░░░
87-
}
83+
+ ALLOC1 (size: 8, align: 4) { .. }
8884

tests/mir-opt/dataflow-const-prop/checked.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ test-mir-pass: DataflowConstProp
2-
//@ compile-flags: -Coverflow-checks=on
2+
//@ compile-flags: -Coverflow-checks=on -Zdump-mir-exclude-alloc-bytes
33
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
44

55
// EMIT_MIR checked.main.DataflowConstProp.diff

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff

+3-9
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,9 @@
9494
}
9595
}
9696

97-
ALLOC2 (size: 8, align: 4) {
98-
01 00 00 00 00 00 00 00 │ ........
99-
}
97+
ALLOC2 (size: 8, align: 4) { .. }
10098

101-
ALLOC1 (size: 8, align: 4) {
102-
01 00 00 00 00 00 00 00 │ ........
103-
}
99+
ALLOC1 (size: 8, align: 4) { .. }
104100

105-
ALLOC0 (size: 8, align: 4) {
106-
01 00 00 00 00 00 00 00 │ ........
107-
}
101+
ALLOC0 (size: 8, align: 4) { .. }
108102

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff

+3-9
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,9 @@
9898
}
9999
}
100100

101-
ALLOC2 (size: 8, align: 4) {
102-
01 00 00 00 00 00 00 00 │ ........
103-
}
101+
ALLOC2 (size: 8, align: 4) { .. }
104102

105-
ALLOC1 (size: 8, align: 4) {
106-
01 00 00 00 00 00 00 00 │ ........
107-
}
103+
ALLOC1 (size: 8, align: 4) { .. }
108104

109-
ALLOC0 (size: 8, align: 4) {
110-
01 00 00 00 00 00 00 00 │ ........
111-
}
105+
ALLOC0 (size: 8, align: 4) { .. }
112106

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff

+3-9
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,9 @@
9494
}
9595
}
9696

97-
ALLOC2 (size: 16, align: 8) {
98-
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
99-
}
97+
ALLOC2 (size: 16, align: 8) { .. }
10098

101-
ALLOC1 (size: 16, align: 8) {
102-
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
103-
}
99+
ALLOC1 (size: 16, align: 8) { .. }
104100

105-
ALLOC0 (size: 16, align: 8) {
106-
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
107-
}
101+
ALLOC0 (size: 16, align: 8) { .. }
108102

0 commit comments

Comments
 (0)