Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mir-opt tests fail on big endian #126261

Closed
nikic opened this issue Jun 11, 2024 · 5 comments · Fixed by #126502 or #127752
Closed

mir-opt tests fail on big endian #126261

nikic opened this issue Jun 11, 2024 · 5 comments · Fixed by #126502 or #127752
Labels
A-compiletest Area: The compiletest test runner A-mir-opt Area: MIR optimizations A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. O-SystemZ Target: SystemZ processors (s390x) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikic
Copy link
Contributor

nikic commented Jun 11, 2024

A number of mir-opt tests fail on s390x, which is a big endian architecture. Failures for 1.79:

---- [mir-opt] tests/mir-opt/const_debuginfo.rs stdout ----
106	  }
107	  
108	  ALLOC0 (size: 8, align: 4) {
-	      20 00 00 00 20 00 00 00                         │  ... ...
+	      00 00 00 20 00 00 00 20                         │ ... ... 
110	  }
111	  
112	  ALLOC1 (size: 4, align: 2) {
-	      01 00 63 00                                     │ ..c.
+	      00 01 00 63                                     │ ...c
114	  }
115	  
116	
thread '[mir-opt] tests/mir-opt/const_debuginfo.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- [mir-opt] tests/mir-opt/const_prop/address_of_pair.rs stdout ----
47	+ }
48	+ 
49	+ ALLOC0 (size: 8, align: 4) {
-	+     01 00 00 00 00 __ __ __                         │ .....░░░
+	+     00 00 00 01 00 __ __ __                         │ .....░░░
51	  }
52	  
53	
thread '[mir-opt] tests/mir-opt/const_prop/address_of_pair.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff
---- [mir-opt] tests/mir-opt/const_prop/checked_add.rs stdout ----
27	+ }
28	+ 
29	+ ALLOC0 (size: 8, align: 4) {
-	+     02 00 00 00 00 __ __ __                         │ .....░░░
+	+     00 00 00 02 00 __ __ __                         │ .....░░░
31	  }
32	  
33	
thread '[mir-opt] tests/mir-opt/const_prop/checked_add.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff
---- [mir-opt] tests/mir-opt/const_prop/mutable_variable_aggregate.rs stdout ----
27	+ }
28	+ 
29	+ ALLOC0 (size: 8, align: 4) {
-	+     2a 00 00 00 2b 00 00 00                         │ *...+...
+	+     00 00 00 2a 00 00 00 2b                         │ ...*...+
31	  }
32	  
33	
thread '[mir-opt] tests/mir-opt/const_prop/mutable_variable_aggregate.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/const_prop/mutable_variable_aggregate.main.GVN.diff
---- [mir-opt] tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs stdout ----
34	+ }
35	+ 
36	+ ALLOC0 (size: 8, align: 4) {
-	+     2a 00 00 00 2b 00 00 00                         │ *...+...
+	+     00 00 00 2a 00 00 00 2b                         │ ...*...+
38	  }
39	  
40	
thread '[mir-opt] tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff
---- [mir-opt] tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs stdout ----
51	+ }
52	+ 
53	+ ALLOC0 (size: 8, align: 4) {
-	+     01 00 00 00 02 00 00 00                         │ ........
+	+     00 00 00 01 00 00 00 02                         │ ........
55	  }
56	  
57	
thread '[mir-opt] tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff
---- [mir-opt] tests/mir-opt/const_prop/return_place.rs stdout ----
20	+ }
21	+ 
22	+ ALLOC0 (size: 8, align: 4) {
-	+     04 00 00 00 00 __ __ __                         │ .....░░░
+	+     00 00 00 04 00 __ __ __                         │ .....░░░
24	  }
25	  
26	
thread '[mir-opt] tests/mir-opt/const_prop/return_place.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff
---- [mir-opt] tests/mir-opt/const_prop/slice_len.rs stdout ----
52	+ }
53	+ 
54	+ ALLOC0 (size: 12, align: 4) {
-	+     01 00 00 00 02 00 00 00 03 00 00 00             │ ............
+	+     00 00 00 01 00 00 00 02 00 00 00 03             │ ............
56	  }
57	  
58	
thread '[mir-opt] tests/mir-opt/const_prop/slice_len.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff
---- [mir-opt] tests/mir-opt/const_prop/tuple_literal_propagation.rs stdout ----
34	+ }
35	+ 
36	+ ALLOC0 (size: 8, align: 4) {
-	+     01 00 00 00 02 00 00 00                         │ ........
+	+     00 00 00 01 00 00 00 02                         │ ........
38	  }
39	  
40	
thread '[mir-opt] tests/mir-opt/const_prop/tuple_literal_propagation.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff
---- [mir-opt] tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs stdout ----
109	+ }
110	+ 
111	+ ALLOC2 (size: 16, align: 8) {
-	+     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+	+     00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 │ ................
113	+ }
114	+ 
115	+ ALLOC1 (size: 16, align: 8) {
-	+     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+	+     00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 │ ................
117	+ }
118	+ 
119	+ ALLOC0 (size: 16, align: 8) {
-	+     01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+	+     00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 │ ................
121	  }
122	  
123	
thread '[mir-opt] tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff
---- [mir-opt] tests/mir-opt/dataflow-const-prop/checked.rs stdout ----
79	+ }
80	+ 
81	+ ALLOC0 (size: 8, align: 4) {
-	+     00 00 00 80 01 __ __ __                         │ .....░░░
+	+     80 00 00 00 01 __ __ __                         │ .....░░░
83	+ }
84	+ 
85	+ ALLOC1 (size: 8, align: 4) {
-	+     03 00 00 00 00 __ __ __                         │ .....░░░
+	+     00 00 00 03 00 __ __ __                         │ .....░░░
87	  }
88	  
89	
thread '[mir-opt] tests/mir-opt/dataflow-const-prop/checked.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff
---- [mir-opt] tests/mir-opt/dataflow-const-prop/enum.rs stdout ----
122	  }
123	  
124	  ALLOC0 (size: 8, align: 4) {
-	      01 00 00 00 04 00 00 00                         │ ........
+	      00 00 00 01 00 00 00 04                         │ ........
126	  }
127	  
128	  ALLOC1 (static: statics::C, size: 8, align: 4) {
thread '[mir-opt] tests/mir-opt/dataflow-const-prop/enum.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff
---- [mir-opt] tests/mir-opt/dataflow-const-prop/struct.rs stdout ----
200	+ }
201	+ 
202	+ ALLOC6 (size: 8, align: 4) {
-	+     01 00 00 00 23 00 00 00                         │ ....#...
+	+     00 00 00 01 00 00 00 23                         │ .......#
204	+ }
205	+ 
206	+ ALLOC7 (size: 8, align: 4) {
-	+     01 00 00 00 23 00 00 00                         │ ....#...
+	+     00 00 00 01 00 00 00 23                         │ .......#
208	+ }
209	+ 
210	+ ALLOC8 (size: 8, align: 4) {
-	+     01 00 00 00 23 00 00 00                         │ ....#...
+	+     00 00 00 01 00 00 00 23                         │ .......#
212	+ }
213	+ 
214	+ ALLOC9 (size: 8, align: 4) {
-	+     01 00 00 00 01 00 00 00                         │ ........
+	+     00 00 00 01 00 00 00 01                         │ ........
216	+ }
217	+ 
218	+ ALLOC10 (size: 4, align: 4) {
-	+     01 00 00 00                                     │ ....
+	+     00 00 00 01                                     │ ....
220	  }
221	  
222	  ALLOC5 (static: BIG_STAT, size: 8, align: 8) {
224	  }
225	  
226	  ALLOC0 (size: 32, align: 8) {
-	      0x00 │ 01 00 00 00 23 00 00 00 ╾ALLOC1<imm>╼ │ ....#...╾──────╼
-	      0x10 │ 02 00 00 00 00 00 00 00 00 00 a4 42 __ __ __ __ │ ...........B░░░░
+	      0x00 │ 00 00 00 01 00 00 00 23 ╾ALLOC1<imm>╼ │ .......#╾──────╼
+	      0x10 │ 00 00 00 00 00 00 00 02 42 a4 00 00 __ __ __ __ │ ........B...░░░░
229	  }
230	  
231	  ALLOC1 (size: 8, align: 4) {
-	      00 00 34 42 00 00 90 42                         │ ..4B...B
+	      42 34 00 00 42 90 00 00                         │ B4..B...
233	  }
234	  
235	  ALLOC4 (static: SMALL_STAT, size: 8, align: 8) {
238	  
239	  ALLOC2 (size: 32, align: 8) {
240	      0x00 │ 00 00 00 00 __ __ __ __ ╾ALLOC3<imm>╼ │ ....░░░░╾──────╼
-	      0x10 │ 01 00 00 00 00 00 00 00 00 00 10 41 __ __ __ __ │ ...........A░░░░
+	      0x10 │ 00 00 00 00 00 00 00 01 41 10 00 00 __ __ __ __ │ ........A...░░░░
242	  }
243	  
244	  ALLOC3 (size: 4, align: 4) {
-	      00 00 50 41                                     │ ..PA
+	      41 50 00 00                                     │ AP..
246	  }
247	  
248	
thread '[mir-opt] tests/mir-opt/dataflow-const-prop/struct.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.64bit.diff
---- [mir-opt] tests/mir-opt/dataflow-const-prop/tuple.rs stdout ----
95	+ }
96	+ 
97	+ ALLOC0 (size: 8, align: 4) {
-	+     02 00 00 00 03 00 00 00                         │ ........
+	+     00 00 00 02 00 00 00 03                         │ ........
99	+ }
100	+ 
101	+ ALLOC1 (size: 8, align: 4) {
-	+     02 00 00 00 03 00 00 00                         │ ........
+	+     00 00 00 02 00 00 00 03                         │ ........
103	+ }
104	+ 
105	+ ALLOC2 (size: 8, align: 4) {
-	+     02 00 00 00 03 00 00 00                         │ ........
+	+     00 00 00 02 00 00 00 03                         │ ........
107	+ }
108	+ 
109	+ ALLOC3 (size: 8, align: 4) {
-	+     01 00 00 00 02 00 00 00                         │ ........
+	+     00 00 00 01 00 00 00 02                         │ ........
111	  }
112	  
113	
thread '[mir-opt] tests/mir-opt/dataflow-const-prop/tuple.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.64bit.diff
---- [mir-opt] tests/mir-opt/enum_opt.rs stdout ----
67	+ }
68	+ 
69	+ ALLOC0 (size: 16, align: 8) {
-	+     05 20 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ . ..............
+	+     00 00 00 00 00 00 20 05 00 00 00 00 00 00 00 01 │ ...... .........
71	  }
72	  
73	
thread '[mir-opt] tests/mir-opt/enum_opt.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff
---- [mir-opt] tests/mir-opt/gvn.rs stdout ----
179	+ }
180	+ 
181	+ ALLOC1 (size: 16, align: 8) {
-	+     01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 │ ................
+	+     00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 02 │ ................
183	+ }
184	+ 
185	+ ALLOC0 (size: 16, align: 8) {
-	+     01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................
+	+     00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 │ ................
187	  }
188	  
189	
thread '[mir-opt] tests/mir-opt/gvn.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff
---- [mir-opt] tests/mir-opt/pre-codegen/optimizes_into_variable.rs stdout ----
64	+ }
65	+ 
66	+ ALLOC0 (size: 8, align: 4) {
-	+     04 00 00 00 00 __ __ __                         │ .....░░░
+	+     00 00 00 04 00 __ __ __                         │ .....░░░
68	  }
69	  
70	
thread '[mir-opt] tests/mir-opt/pre-codegen/optimizes_into_variable.rs' panicked at src/tools/compiletest/src/runtest.rs:4421:21:
Actual MIR output differs from expected MIR output /builddir/build/BUILD/rust-1.79.0~beta.10-build/rustc-beta-src/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff
failures:
    [mir-opt] tests/mir-opt/const_debuginfo.rs
    [mir-opt] tests/mir-opt/const_prop/address_of_pair.rs
    [mir-opt] tests/mir-opt/const_prop/checked_add.rs
    [mir-opt] tests/mir-opt/const_prop/mutable_variable_aggregate.rs
    [mir-opt] tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs
    [mir-opt] tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs
    [mir-opt] tests/mir-opt/const_prop/return_place.rs
    [mir-opt] tests/mir-opt/const_prop/slice_len.rs
    [mir-opt] tests/mir-opt/const_prop/tuple_literal_propagation.rs
    [mir-opt] tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs
    [mir-opt] tests/mir-opt/dataflow-const-prop/checked.rs
    [mir-opt] tests/mir-opt/dataflow-const-prop/enum.rs
    [mir-opt] tests/mir-opt/dataflow-const-prop/struct.rs
    [mir-opt] tests/mir-opt/dataflow-const-prop/tuple.rs
    [mir-opt] tests/mir-opt/enum_opt.rs
    [mir-opt] tests/mir-opt/gvn.rs
    [mir-opt] tests/mir-opt/pre-codegen/optimizes_into_variable.rs

Some previous fixes for such failures were #115167 and #106046.

@nikic nikic added the C-bug Category: This is a bug. label Jun 11, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 11, 2024
@jieyouxu jieyouxu added A-testsuite Area: The testsuite used to check the correctness of rustc T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. O-SystemZ Target: SystemZ processors (s390x) A-mir-opt Area: MIR optimizations and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 11, 2024
@nikic
Copy link
Contributor Author

nikic commented Jun 11, 2024

Something peculiar about many of these tests is that transforms seem to create ALLOCs that are not actually referenced by MIR. Is that expected?

In terms of fixing this, the existing approach of picking constants that are endianness-independent doesn't seem very scalable. Maybe it would make sense to have a flag that disables dumping the contents of allocations? I think that for most of these tests they are not relevant (especially as the allocations are unused in the first place).

@jieyouxu jieyouxu added the A-compiletest Area: The compiletest test runner label Jun 11, 2024
@DianQK
Copy link
Member

DianQK commented Jun 11, 2024

Something peculiar about many of these tests is that transforms seem to create ALLOCs that are not actually referenced by MIR. Is that expected?

This appears to be an intermediate result of the optimization process, such as: https://rust.godbolt.org/z/ohz1YMqez (tests/mir-opt/const_prop/slice_len.rs).

In terms of fixing this, the existing approach of picking constants that are endianness-independent doesn't seem very scalable. Maybe it would make sense to have a flag that disables dumping the contents of allocations? I think that for most of these tests they are not relevant (especially as the allocations are unused in the first place).

There is an option ignore-endian-big to skip these tests, but I like another option to change the output to be uniformly little-endian.

@cuviper
Copy link
Member

cuviper commented Jun 11, 2024

If these tests don't actually care about the raw bytes in their UI comparisons, then they can use normalize-stderr-test to hide the bytes. There are quite a few tests that already normalize to the string "HEX_DUMP".

@cuviper
Copy link
Member

cuviper commented Jun 14, 2024

Rather than trying to normalize output, I'm proposing an option in #126502 to skip the raw bytes altogether.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 12, 2024
…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
@bors bors closed this as completed in 5d56572 Jul 13, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 13, 2024
Rollup merge of rust-lang#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 rust-lang#126261
@uweigand
Copy link
Contributor

Huh, looks like a new instance has crept in just as the PR was merged. I'm now seeing a new test fail:

---- [mir-opt] tests/mir-opt/dataflow-const-prop/aggregate_copy.rs stdout ----
60      + }
61      + 
62      + ALLOC0 (size: 8, align: 4) {
-       +     05 00 00 00 03 00 00 00                         │ ........
+       +     00 00 00 05 00 00 00 03                         │ ........
64        }

uweigand added a commit to uweigand/rust that referenced this issue Jul 15, 2024
Following on PR rust-lang#126502, add `rustc -Zdump-mir-exclude-alloc-bytes`
to tests/mir-opt/dataflow-const-prop/aggregate_copy.rs as well
to skip writing allocation bytes in MIR dumps.

Fixes rust-lang#126261
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 20, 2024
…rk-Simulacrum

Ignore allocation bytes in one more mir-opt test

Following on PR rust-lang#126502, add `rustc -Zdump-mir-exclude-alloc-bytes` to tests/mir-opt/dataflow-const-prop/aggregate_copy.rs as well to skip writing allocation bytes in MIR dumps.

Fixes rust-lang#126261
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 21, 2024
Rollup merge of rust-lang#127752 - uweigand:s390x-miropt-update, r=Mark-Simulacrum

Ignore allocation bytes in one more mir-opt test

Following on PR rust-lang#126502, add `rustc -Zdump-mir-exclude-alloc-bytes` to tests/mir-opt/dataflow-const-prop/aggregate_copy.rs as well to skip writing allocation bytes in MIR dumps.

Fixes rust-lang#126261
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-mir-opt Area: MIR optimizations A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. O-SystemZ Target: SystemZ processors (s390x) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
6 participants