Skip to content

Commit 47fa7fa

Browse files
authored
Rollup merge of #106046 - uweigand:s390x-test-bigendian-mir, r=Mark-Simulacrum
Fix mir-opt tests for big-endian platforms The test cases src/test/mir-opt/building/custom/consts.rs and src/test/mir-opt/const_prop/mutable_variable_no_prop.rs are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the MIR test files. Fix this by choosing constant values that have the same encoding on big- and little-endian platforms. The test case src/test/mir-opt/issues/issue_75439.rs is failing as well, but since the purpose of the test is to validate handling of big-endian integer encodings on a little-endian platform, it does not make much sense to run it on big-endian platforms in the first place - we can just ignore it there. Fixed part of #105383.
2 parents 44a500c + 6885733 commit 47fa7fa

6 files changed

+9
-8
lines changed

tests/mir-opt/building/custom/consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ fn consts<const C: u32>() {
1818
})
1919
}
2020

21-
static S: i32 = 5;
22-
static mut T: i32 = 10;
21+
static S: i32 = 0x05050505;
22+
static mut T: i32 = 0x0a0a0a0a;
2323
// EMIT_MIR consts.statics.built.after.mir
2424
#[custom_mir(dialect = "built")]
2525
fn statics() {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ fn statics() -> () {
1919
}
2020

2121
alloc2 (static: T, size: 4, align: 4) {
22-
0a 00 00 00 │ ....
22+
0a 0a 0a 0a │ ....
2323
}
2424

2525
alloc1 (static: S, size: 4, align: 4) {
26-
05 00 00 00 │ ....
26+
05 05 05 05 │ ....
2727
}

tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
}
3939

4040
alloc1 (static: STATIC, size: 4, align: 4) {
41-
2a 00 00 00*...
41+
42 42 42 42BBBB
4242
}
4343

tests/mir-opt/const_prop/mutable_variable_no_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// unit-test
22
// compile-flags: -O
33

4-
static mut STATIC: u32 = 42;
4+
static mut STATIC: u32 = 0x42424242;
55

66
// EMIT_MIR mutable_variable_no_prop.main.ConstProp.diff
77
fn main() {

tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
_3 = _1; // scope 2 at $DIR/issue_75439.rs:+2:47: +2:52
2727
_2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue_75439.rs:+2:37: +2:53
2828
// mir::Constant
29-
// + span: $DIR/issue_75439.rs:7:37: 7:46
29+
// + span: $DIR/issue_75439.rs:8:37: 8:46
3030
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn([u8; 16]) -> [u32; 4] {transmute::<[u8; 16], [u32; 4]>}, val: Value(<ZST>) }
3131
}
3232

@@ -49,7 +49,7 @@
4949
_6 = _4; // scope 4 at $DIR/issue_75439.rs:+5:33: +5:35
5050
_5 = transmute::<u32, [u8; 4]>(move _6) -> bb7; // scope 4 at $DIR/issue_75439.rs:+5:23: +5:36
5151
// mir::Constant
52-
// + span: $DIR/issue_75439.rs:10:23: 10:32
52+
// + span: $DIR/issue_75439.rs:11:23: 11:32
5353
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) -> [u8; 4] {transmute::<u32, [u8; 4]>}, val: Value(<ZST>) }
5454
}
5555

tests/mir-opt/issues/issue_75439.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff
2+
// ignore-endian-big
23

34
use std::mem::transmute;
45

0 commit comments

Comments
 (0)