Skip to content

Commit

Permalink
Rollup merge of rust-lang#126502 - cuviper:dump-mir-exclude-alloc-byt…
Browse files Browse the repository at this point in the history
…es, 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 rust-lang#126261
  • Loading branch information
matthiaskrgr authored Jul 12, 2024
2 parents 5d76a13 + 7c3673f commit d18af83
Show file tree
Hide file tree
Showing 72 changed files with 205 additions and 390 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ fn test_unstable_options_tracking_hash() {
untracked!(dump_mir, Some(String::from("abc")));
untracked!(dump_mir_dataflow, true);
untracked!(dump_mir_dir, String::from("abc"));
untracked!(dump_mir_exclude_alloc_bytes, true);
untracked!(dump_mir_exclude_pass_number, true);
untracked!(dump_mir_graphviz, true);
untracked!(dump_mono_stats, SwitchWithOptPath::Enabled(Some("mono-items-dir/".into())));
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,9 @@ impl<'a, 'tcx, Prov: Provenance, Extra, Bytes: AllocBytes> std::fmt::Display
// We are done.
return write!(w, " {{}}");
}
if tcx.sess.opts.unstable_opts.dump_mir_exclude_alloc_bytes {
return write!(w, " {{ .. }}");
}
// Write allocation bytes.
writeln!(w, " {{")?;
write_allocation_bytes(tcx, alloc, w, " ")?;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,8 @@ options! {
(default: no)"),
dump_mir_dir: String = ("mir_dump".to_string(), parse_string, [UNTRACKED],
"the directory the MIR is dumped into (default: `mir_dump`)"),
dump_mir_exclude_alloc_bytes: bool = (false, parse_bool, [UNTRACKED],
"exclude the raw bytes of allocations when dumping MIR (used in tests) (default: no)"),
dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
"exclude the pass number when dumping MIR (used in tests) (default: no)"),
dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
Expand Down
8 changes: 2 additions & 6 deletions tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,7 @@
}
}

ALLOC0 (size: 8, align: 4) {
20 00 00 00 20 00 00 00 │ ... ...
}
ALLOC0 (size: 8, align: 4) { .. }

ALLOC1 (size: 4, align: 2) {
01 00 63 00 │ ..c.
}
ALLOC1 (size: 4, align: 2) { .. }

2 changes: 1 addition & 1 deletion tests/mir-opt/const_debuginfo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ test-mir-pass: SingleUseConsts
//@ compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN
//@ compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN -Zdump-mir-exclude-alloc-bytes

#![allow(unused)]

Expand Down
6 changes: 2 additions & 4 deletions tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
StorageDead(_2);
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 01 00 00 00 00 __ __ __ │ .....░░░
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

1 change: 1 addition & 0 deletions tests/mir-opt/const_prop/address_of_pair.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ test-mir-pass: GVN
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes

// EMIT_MIR address_of_pair.fn0.GVN.diff
pub fn fn0() -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
StorageDead(_1);
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 02 00 00 00 00 __ __ __ │ .....░░░
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
StorageDead(_1);
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 02 00 00 00 00 __ __ __ │ .....░░░
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

2 changes: 1 addition & 1 deletion tests/mir-opt/const_prop/checked_add.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//@ test-mir-pass: GVN
//@ compile-flags: -C overflow-checks=on
//@ compile-flags: -C overflow-checks=on -Zdump-mir-exclude-alloc-bytes

// EMIT_MIR checked_add.main.GVN.diff
fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
StorageDead(_1);
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 2a 00 00 00 2b 00 00 00 │ *...+...
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

1 change: 1 addition & 0 deletions tests/mir-opt/const_prop/mutable_variable_aggregate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ test-mir-pass: GVN
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes

// EMIT_MIR mutable_variable_aggregate.main.GVN.diff
fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
StorageDead(_1);
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 2a 00 00 00 2b 00 00 00 │ *...+...
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ test-mir-pass: GVN
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes

// EMIT_MIR mutable_variable_aggregate_mut_ref.main.GVN.diff
fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
+ nop;
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 01 00 00 00 02 00 00 00 │ ........
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
+ nop;
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 01 00 00 00 02 00 00 00 │ ........
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

1 change: 1 addition & 0 deletions tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//@ test-mir-pass: GVN
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes

// EMIT_MIR mutable_variable_unprop_assign.main.GVN.diff
fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
+ _0 = const 4_u32;
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 04 00 00 00 00 __ __ __ │ .....░░░
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
+ _0 = const 4_u32;
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 04 00 00 00 00 __ __ __ │ .....░░░
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ fn add() -> u32 {
}
}

ALLOC0 (size: 8, align: 4) {
04 00 00 00 00 __ __ __ │ .....░░░
}
ALLOC0 (size: 8, align: 4) { .. }
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ fn add() -> u32 {
}
}

ALLOC0 (size: 8, align: 4) {
04 00 00 00 00 __ __ __ │ .....░░░
}
ALLOC0 (size: 8, align: 4) { .. }
2 changes: 1 addition & 1 deletion tests/mir-opt/const_prop/return_place.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ test-mir-pass: GVN
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//@ compile-flags: -C overflow-checks=on
//@ compile-flags: -C overflow-checks=on -Zdump-mir-exclude-alloc-bytes

// EMIT_MIR return_place.add.GVN.diff
// EMIT_MIR return_place.add.PreCodegen.before.mir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
StorageDead(_1);
return;
}
+ }
+
+ ALLOC0 (size: 12, align: 4) {
+ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............
}
+
+ ALLOC0 (size: 12, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
StorageDead(_1);
return;
}
+ }
+
+ ALLOC0 (size: 12, align: 4) {
+ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............
}
+
+ ALLOC0 (size: 12, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
StorageDead(_1);
return;
}
+ }
+
+ ALLOC0 (size: 12, align: 4) {
+ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............
}
+
+ ALLOC0 (size: 12, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
StorageDead(_1);
return;
}
+ }
+
+ ALLOC0 (size: 12, align: 4) {
+ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............
}
+
+ ALLOC0 (size: 12, align: 4) { .. }

2 changes: 1 addition & 1 deletion tests/mir-opt/const_prop/slice_len.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ test-mir-pass: GVN
//@ compile-flags: -Zmir-enable-passes=+InstSimplify
//@ compile-flags: -Zmir-enable-passes=+InstSimplify -Zdump-mir-exclude-alloc-bytes
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
+ nop;
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 01 00 00 00 02 00 00 00 │ ........
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
+ nop;
return;
}
+ }
+
+ ALLOC0 (size: 8, align: 4) {
+ 01 00 00 00 02 00 00 00 │ ........
}
+
+ ALLOC0 (size: 8, align: 4) { .. }

1 change: 1 addition & 0 deletions tests/mir-opt/const_prop/tuple_literal_propagation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ test-mir-pass: GVN
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR tuple_literal_propagation.main.GVN.diff

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,9 @@
StorageDead(_1);
return;
}
+ }
}
+
+ ALLOC0 (size: 8, align: 4) {
+ 00 00 00 80 01 __ __ __ │ .....░░░
+ }
+ ALLOC0 (size: 8, align: 4) { .. }
+
+ ALLOC1 (size: 8, align: 4) {
+ 03 00 00 00 00 __ __ __ │ .....░░░
}
+ ALLOC1 (size: 8, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,9 @@
StorageDead(_1);
return;
}
+ }
}
+
+ ALLOC0 (size: 8, align: 4) {
+ 00 00 00 80 01 __ __ __ │ .....░░░
+ }
+ ALLOC0 (size: 8, align: 4) { .. }
+
+ ALLOC1 (size: 8, align: 4) {
+ 03 00 00 00 00 __ __ __ │ .....░░░
}
+ ALLOC1 (size: 8, align: 4) { .. }

2 changes: 1 addition & 1 deletion tests/mir-opt/dataflow-const-prop/checked.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ test-mir-pass: DataflowConstProp
//@ compile-flags: -Coverflow-checks=on
//@ compile-flags: -Coverflow-checks=on -Zdump-mir-exclude-alloc-bytes
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY

// EMIT_MIR checked.main.DataflowConstProp.diff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,9 @@
}
}

ALLOC2 (size: 8, align: 4) {
01 00 00 00 00 00 00 00 │ ........
}
ALLOC2 (size: 8, align: 4) { .. }

ALLOC1 (size: 8, align: 4) {
01 00 00 00 00 00 00 00 │ ........
}
ALLOC1 (size: 8, align: 4) { .. }

ALLOC0 (size: 8, align: 4) {
01 00 00 00 00 00 00 00 │ ........
}
ALLOC0 (size: 8, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,9 @@
}
}

ALLOC2 (size: 8, align: 4) {
01 00 00 00 00 00 00 00 │ ........
}
ALLOC2 (size: 8, align: 4) { .. }

ALLOC1 (size: 8, align: 4) {
01 00 00 00 00 00 00 00 │ ........
}
ALLOC1 (size: 8, align: 4) { .. }

ALLOC0 (size: 8, align: 4) {
01 00 00 00 00 00 00 00 │ ........
}
ALLOC0 (size: 8, align: 4) { .. }

Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,9 @@
}
}

ALLOC2 (size: 16, align: 8) {
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
}
ALLOC2 (size: 16, align: 8) { .. }

ALLOC1 (size: 16, align: 8) {
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
}
ALLOC1 (size: 16, align: 8) { .. }

ALLOC0 (size: 16, align: 8) {
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
}
ALLOC0 (size: 16, align: 8) { .. }

Loading

0 comments on commit d18af83

Please sign in to comment.