Skip to content

Commit 73caae4

Browse files
committed
More mir-opt test fixes for big-endian platforms
A number of mir-opt test cases are failing again on big-endian platforms, due to endian-specific binary encodings in the output files that are being checked by the test. To fix those, one of the following two strategies is used: a) Where a binary encoded value directly originates from some immediate constant in the test case source code, change that constant to an endian-invariant value (like 0x11000011). b) Where that is not easily possible or would change the essence of what the test is checking for, disable the test on big-endian platforms. Fixes (again) rust-lang#105383.
1 parent c092b28 commit 73caae4

File tree

52 files changed

+150
-142
lines changed

Some content is hidden

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

52 files changed

+150
-142
lines changed

tests/mir-opt/const_debuginfo.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ test-mir-pass: SingleUseConsts
22
//@ compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN
3+
//@ ignore-endian-big
34

45
#![allow(unused)]
56

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
bb0: {
2323
StorageLive(_2);
24-
- _2 = (const 1_i32, const false);
25-
+ _2 = const (1_i32, false);
24+
- _2 = (const 285212689_i32, const false);
25+
+ _2 = const (285212689_i32, false);
2626
StorageLive(_3);
2727
_3 = &raw mut (_2.1: bool);
28-
- _2 = (const 1_i32, const false);
29-
+ _2 = const (1_i32, false);
28+
- _2 = (const 285212689_i32, const false);
29+
+ _2 = const (285212689_i32, false);
3030
StorageLive(_4);
3131
(*_3) = const true;
3232
_4 = const ();
@@ -47,6 +47,6 @@
4747
+ }
4848
+
4949
+ ALLOC0 (size: 8, align: 4) {
50-
+ 01 00 00 00 00 __ __ __ │ .....░░░
50+
+ 11 00 00 11 00 __ __ __ │ .....░░░
5151
}
5252

tests/mir-opt/const_prop/address_of_pair.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ pub fn fn0() -> bool {
1616
// CHECK-NOT: = const false;
1717
// CHECK-NOT: = const true;
1818
// CHECK: _0 = [[ret]];
19-
let mut pair = (1, false);
19+
let mut pair = (0x11000011, false); // Endian-invariant value.
2020
let ptr = core::ptr::addr_of_mut!(pair.1);
21-
pair = (1, false);
21+
pair = (0x11000011, false);
2222
unsafe {
2323
*ptr = true;
2424
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111

1212
bb0: {
1313
StorageLive(_1);
14-
- _2 = AddWithOverflow(const 1_u32, const 1_u32);
15-
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind unreachable];
16-
+ _2 = const (2_u32, false);
17-
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind unreachable];
14+
- _2 = AddWithOverflow(const 285212689_u32, const 285212689_u32);
15+
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 285212689_u32, const 285212689_u32) -> [success: bb1, unwind unreachable];
16+
+ _2 = const (570425378_u32, false);
17+
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 285212689_u32, const 285212689_u32) -> [success: bb1, unwind unreachable];
1818
}
1919

2020
bb1: {
2121
- _1 = move (_2.0: u32);
22-
+ _1 = const 2_u32;
22+
+ _1 = const 570425378_u32;
2323
_0 = const ();
2424
StorageDead(_1);
2525
return;
2626
}
2727
+ }
2828
+
2929
+ ALLOC0 (size: 8, align: 4) {
30-
+ 02 00 00 00 00 __ __ __ │ .....░░░
30+
+ 22 00 00 22 00 __ __ __ │ "..".░░░
3131
}
3232

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111

1212
bb0: {
1313
StorageLive(_1);
14-
- _2 = AddWithOverflow(const 1_u32, const 1_u32);
15-
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue];
16-
+ _2 = const (2_u32, false);
17-
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue];
14+
- _2 = AddWithOverflow(const 285212689_u32, const 285212689_u32);
15+
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 285212689_u32, const 285212689_u32) -> [success: bb1, unwind continue];
16+
+ _2 = const (570425378_u32, false);
17+
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 285212689_u32, const 285212689_u32) -> [success: bb1, unwind continue];
1818
}
1919

2020
bb1: {
2121
- _1 = move (_2.0: u32);
22-
+ _1 = const 2_u32;
22+
+ _1 = const 570425378_u32;
2323
_0 = const ();
2424
StorageDead(_1);
2525
return;
2626
}
2727
+ }
2828
+
2929
+ ALLOC0 (size: 8, align: 4) {
30-
+ 02 00 00 00 00 __ __ __ │ .....░░░
30+
+ 22 00 00 22 00 __ __ __ │ "..".░░░
3131
}
3232

tests/mir-opt/const_prop/checked_add.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ fn main() {
77
// CHECK-LABEL: fn main(
88
// CHECK: debug x => [[x:_.*]];
99
// CHECK: assert(!const false,
10-
// CHECK: [[x]] = const 2_u32;
11-
let x: u32 = 1 + 1;
10+
// CHECK: [[x]] = const 570425378_u32;
11+
let x: u32 = 0x11000011 + 0x11000011; // Endian-invariant value.
1212
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
bb0: {
1616
StorageLive(_1);
17-
- _1 = (const 42_i32, const 43_i32);
18-
+ _1 = const (42_i32, 43_i32);
17+
- _1 = (const 285212689_i32, const 570425378_i32);
18+
+ _1 = const (285212689_i32, 570425378_i32);
1919
(_1.1: i32) = const 99_i32;
2020
StorageLive(_2);
2121
_2 = _1;
@@ -27,6 +27,6 @@
2727
+ }
2828
+
2929
+ ALLOC0 (size: 8, align: 4) {
30-
+ 2a 00 00 00 2b 00 00 00*...+...
30+
+ 11 00 00 11 22 00 00 22 │ ....".."
3131
}
3232

tests/mir-opt/const_prop/mutable_variable_aggregate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ fn main() {
55
// CHECK-LABEL: fn main(
66
// CHECK: debug x => [[x:_.*]];
77
// CHECK: debug y => [[y:_.*]];
8-
// CHECK: [[x]] = const (42_i32, 43_i32);
8+
// CHECK: [[x]] = const (285212689_i32, 570425378_i32);
99
// CHECK: ([[x]].1: i32) = const 99_i32;
1010
// CHECK: [[y]] = [[x]];
11-
let mut x = (42, 43);
11+
let mut x = (0x11000011, 0x22000022); // Endian-invariant values.
1212
x.1 = 99;
1313
let y = x;
1414
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
bb0: {
2020
StorageLive(_1);
21-
- _1 = (const 42_i32, const 43_i32);
22-
+ _1 = const (42_i32, 43_i32);
21+
- _1 = (const 285212689_i32, const 570425378_i32);
22+
+ _1 = const (285212689_i32, 570425378_i32);
2323
StorageLive(_2);
2424
_2 = &mut _1;
2525
((*_2).1: i32) = const 99_i32;
@@ -34,6 +34,6 @@
3434
+ }
3535
+
3636
+ ALLOC0 (size: 8, align: 4) {
37-
+ 2a 00 00 00 2b 00 00 00*...+...
37+
+ 11 00 00 11 22 00 00 22 │ ....".."
3838
}
3939

tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ fn main() {
66
// CHECK: debug x => [[x:_.*]];
77
// CHECK: debug z => [[z:_.*]];
88
// CHECK: debug y => [[y:_.*]];
9-
// CHECK: [[x]] = const (42_i32, 43_i32);
9+
// CHECK: [[x]] = const (285212689_i32, 570425378_i32);
1010
// CHECK: [[z]] = &mut [[x]];
1111
// CHECK: ((*[[z]]).1: i32) = const 99_i32;
1212
// CHECK: [[y]] = [[x]];
13-
let mut x = (42, 43);
13+
let mut x = (0x11000011, 0x22000022); // Endian-invariant values.
1414
let z = &mut x;
1515
z.1 = 99;
1616
let y = x;

0 commit comments

Comments
 (0)