summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/const_prop
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /tests/mir-opt/const_prop
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/const_prop')
-rw-r--r--tests/mir-opt/const_prop/address_of_pair.rs15
-rw-r--r--tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir49
-rw-r--r--tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir49
-rw-r--r--tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir36
-rw-r--r--tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir36
-rw-r--r--tests/mir-opt/const_prop/aggregate.rs18
-rw-r--r--tests/mir-opt/const_prop/array_index.rs6
-rw-r--r--tests/mir-opt/const_prop/bad_op_div_by_zero.rs10
-rw-r--r--tests/mir-opt/const_prop/bad_op_mod_by_zero.rs9
-rw-r--r--tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs5
-rw-r--r--tests/mir-opt/const_prop/boolean_identities.rs12
-rw-r--r--tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff32
-rw-r--r--tests/mir-opt/const_prop/boxes.rs6
-rw-r--r--tests/mir-opt/const_prop/cast.rs7
-rw-r--r--tests/mir-opt/const_prop/checked_add.rs5
-rw-r--r--tests/mir-opt/const_prop/const_prop_fails_gracefully.rs12
-rw-r--r--tests/mir-opt/const_prop/discriminant.rs15
-rw-r--r--tests/mir-opt/const_prop/indirect.rs4
-rw-r--r--tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff2
-rw-r--r--tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff2
-rw-r--r--tests/mir-opt/const_prop/inherit_overflow.rs9
-rw-r--r--tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff11
-rw-r--r--tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff11
-rw-r--r--tests/mir-opt/const_prop/issue_66971.rs4
-rw-r--r--tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff3
-rw-r--r--tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff3
-rw-r--r--tests/mir-opt/const_prop/issue_67019.rs4
-rw-r--r--tests/mir-opt/const_prop/mult_by_zero.rs7
-rw-r--r--tests/mir-opt/const_prop/mutable_variable.rs7
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate.rs7
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs9
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs8
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_no_prop.rs9
-rw-r--r--tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs14
-rw-r--r--tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff (renamed from tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff)0
-rw-r--r--tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff (renamed from tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff)0
-rw-r--r--tests/mir-opt/const_prop/pointer_expose_address.rs18
-rw-r--r--tests/mir-opt/const_prop/read_immutable_static.rs4
-rw-r--r--tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff5
-rw-r--r--tests/mir-opt/const_prop/ref_deref.rs8
-rw-r--r--tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff5
-rw-r--r--tests/mir-opt/const_prop/ref_deref_project.rs9
-rw-r--r--tests/mir-opt/const_prop/reify_fn_ptr.rs5
-rw-r--r--tests/mir-opt/const_prop/repeat.rs4
-rw-r--r--tests/mir-opt/const_prop/return_place.rs3
-rw-r--r--tests/mir-opt/const_prop/scalar_literal_propagation.rs4
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff5
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff5
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff5
-rw-r--r--tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff5
-rw-r--r--tests/mir-opt/const_prop/slice_len.rs9
-rw-r--r--tests/mir-opt/const_prop/switch_int.rs9
-rw-r--r--tests/mir-opt/const_prop/tuple_literal_propagation.rs5
-rw-r--r--tests/mir-opt/const_prop/while_let_loops.rs3
54 files changed, 292 insertions, 255 deletions
diff --git a/tests/mir-opt/const_prop/address_of_pair.rs b/tests/mir-opt/const_prop/address_of_pair.rs
index 169469a07..730ebe2ca 100644
--- a/tests/mir-opt/const_prop/address_of_pair.rs
+++ b/tests/mir-opt/const_prop/address_of_pair.rs
@@ -1,8 +1,21 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR address_of_pair.fn0.ConstProp.diff
pub fn fn0() -> bool {
+ // CHECK-LABEL: fn fn0(
+ // CHECK: debug pair => [[pair:_.*]];
+ // CHECK: debug ptr => [[ptr:_.*]];
+ // CHECK: debug ret => [[ret:_.*]];
+ // CHECK: (*[[ptr]]) = const true;
+ // CHECK-NOT: = const false;
+ // CHECK-NOT: = const true;
+ // CHECK: [[tmp:_.*]] = ([[pair]].1: bool);
+ // CHECK-NOT: = const false;
+ // CHECK-NOT: = const true;
+ // CHECK: [[ret]] = Not(move [[tmp]]);
+ // CHECK-NOT: = const false;
+ // CHECK-NOT: = const true;
+ // CHECK: _0 = [[ret]];
let mut pair = (1, false);
let ptr = core::ptr::addr_of_mut!(pair.1);
pair = (1, false);
diff --git a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir
deleted file mode 100644
index b9c5859ca..000000000
--- a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir
+++ /dev/null
@@ -1,49 +0,0 @@
-// MIR for `foo` after PreCodegen
-
-fn foo(_1: u8) -> () {
- debug x => _1;
- let mut _0: ();
- let _2: i32;
- let mut _3: i32;
- let mut _4: (i32, u8);
- let mut _5: u8;
- let mut _7: i32;
- let mut _8: (u8, i32);
- let mut _9: u8;
- scope 1 {
- debug first => _2;
- let _6: i32;
- scope 2 {
- debug second => _6;
- }
- }
-
- bb0: {
- StorageLive(_2);
- StorageLive(_3);
- StorageLive(_4);
- StorageLive(_5);
- _5 = _1;
- _4 = (const 0_i32, move _5);
- StorageDead(_5);
- _3 = const 0_i32;
- _2 = const 1_i32;
- StorageDead(_3);
- StorageDead(_4);
- StorageLive(_6);
- StorageLive(_7);
- StorageLive(_8);
- StorageLive(_9);
- _9 = _1;
- _8 = (move _9, const 1_i32);
- StorageDead(_9);
- _7 = const 1_i32;
- _6 = const 3_i32;
- StorageDead(_7);
- StorageDead(_8);
- _0 = const ();
- StorageDead(_6);
- StorageDead(_2);
- return;
- }
-}
diff --git a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir
deleted file mode 100644
index b9c5859ca..000000000
--- a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir
+++ /dev/null
@@ -1,49 +0,0 @@
-// MIR for `foo` after PreCodegen
-
-fn foo(_1: u8) -> () {
- debug x => _1;
- let mut _0: ();
- let _2: i32;
- let mut _3: i32;
- let mut _4: (i32, u8);
- let mut _5: u8;
- let mut _7: i32;
- let mut _8: (u8, i32);
- let mut _9: u8;
- scope 1 {
- debug first => _2;
- let _6: i32;
- scope 2 {
- debug second => _6;
- }
- }
-
- bb0: {
- StorageLive(_2);
- StorageLive(_3);
- StorageLive(_4);
- StorageLive(_5);
- _5 = _1;
- _4 = (const 0_i32, move _5);
- StorageDead(_5);
- _3 = const 0_i32;
- _2 = const 1_i32;
- StorageDead(_3);
- StorageDead(_4);
- StorageLive(_6);
- StorageLive(_7);
- StorageLive(_8);
- StorageLive(_9);
- _9 = _1;
- _8 = (move _9, const 1_i32);
- StorageDead(_9);
- _7 = const 1_i32;
- _6 = const 3_i32;
- StorageDead(_7);
- StorageDead(_8);
- _0 = const ();
- StorageDead(_6);
- StorageDead(_2);
- return;
- }
-}
diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir
deleted file mode 100644
index 44a85a563..000000000
--- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir
+++ /dev/null
@@ -1,36 +0,0 @@
-// MIR for `main` after PreCodegen
-
-fn main() -> () {
- let mut _0: ();
- let _1: u8;
- let mut _2: u8;
- let mut _3: (i32, u8, i32);
- let _4: ();
- let mut _5: u8;
- scope 1 {
- debug x => _1;
- }
-
- bb0: {
- StorageLive(_1);
- StorageLive(_2);
- StorageLive(_3);
- _3 = (const 0_i32, const 1_u8, const 2_i32);
- _2 = const 1_u8;
- _1 = const 1_u8;
- StorageDead(_2);
- StorageDead(_3);
- StorageLive(_4);
- StorageLive(_5);
- _5 = const 1_u8;
- _4 = foo(const 1_u8) -> [return: bb1, unwind unreachable];
- }
-
- bb1: {
- StorageDead(_5);
- StorageDead(_4);
- _0 = const ();
- StorageDead(_1);
- return;
- }
-}
diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir
deleted file mode 100644
index 2c7bdbb50..000000000
--- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir
+++ /dev/null
@@ -1,36 +0,0 @@
-// MIR for `main` after PreCodegen
-
-fn main() -> () {
- let mut _0: ();
- let _1: u8;
- let mut _2: u8;
- let mut _3: (i32, u8, i32);
- let _4: ();
- let mut _5: u8;
- scope 1 {
- debug x => _1;
- }
-
- bb0: {
- StorageLive(_1);
- StorageLive(_2);
- StorageLive(_3);
- _3 = (const 0_i32, const 1_u8, const 2_i32);
- _2 = const 1_u8;
- _1 = const 1_u8;
- StorageDead(_2);
- StorageDead(_3);
- StorageLive(_4);
- StorageLive(_5);
- _5 = const 1_u8;
- _4 = foo(const 1_u8) -> [return: bb1, unwind continue];
- }
-
- bb1: {
- StorageDead(_5);
- StorageDead(_4);
- _0 = const ();
- StorageDead(_1);
- return;
- }
-}
diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs
index 2e043af08..fa716b084 100644
--- a/tests/mir-opt/const_prop/aggregate.rs
+++ b/tests/mir-opt/const_prop/aggregate.rs
@@ -1,19 +1,29 @@
-// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// compile-flags: -O
// EMIT_MIR aggregate.main.ConstProp.diff
-// EMIT_MIR aggregate.main.PreCodegen.after.mir
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK-NOT: = Add(
+ // CHECK: [[x]] = const 1_u8;
+ // CHECK-NOT: = Add(
+ // CHECK: foo(const 1_u8)
let x = (0, 1, 2).1 + 0;
foo(x);
}
+// Verify that we still propagate if part of the aggregate is not known.
// EMIT_MIR aggregate.foo.ConstProp.diff
-// EMIT_MIR aggregate.foo.PreCodegen.after.mir
fn foo(x: u8) {
- // Verify that we still propagate if part of the aggregate is not known.
+ // CHECK-LABEL: fn foo(
+ // CHECK: debug first => [[first:_.*]];
+ // CHECK: debug second => [[second:_.*]];
+ // CHECK-NOT: = Add(
+ // CHECK: [[first]] = const 1_i32;
+ // CHECK-NOT: = Add(
+ // CHECK: [[second]] = const 3_i32;
let first = (0, x).0 + 1;
let second = (x, 1).1 + 2;
}
diff --git a/tests/mir-opt/const_prop/array_index.rs b/tests/mir-opt/const_prop/array_index.rs
index 3bd232165..c4c46d78f 100644
--- a/tests/mir-opt/const_prop/array_index.rs
+++ b/tests/mir-opt/const_prop/array_index.rs
@@ -1,9 +1,11 @@
-// skip-filecheck
-// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR array_index.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: [[x]] = const 2_u32;
let x: u32 = [0, 1, 2, 3][2];
}
diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs
index ab41f64a5..0e8765a07 100644
--- a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs
+++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs
@@ -1,9 +1,15 @@
-// skip-filecheck
-// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+
// EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff
#[allow(unconditional_panic)]
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: debug _z => [[z:_.*]];
+ // CHECK: assert(!const true, "attempt to divide `{}` by zero", const 1_i32)
+ // CHECK: assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, const 0_i32)
+ // CHECK: [[z]] = Div(const 1_i32, const 0_i32);
let y = 0;
let _z = 1 / y;
}
diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs
index e747b21cf..d895d9e21 100644
--- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs
+++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs
@@ -1,9 +1,16 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+
// EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff
#[allow(unconditional_panic)]
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: debug _z => [[z:_.*]];
+ // CHECK: assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of
+ // zero", const 1_i32)
+ // CHECK: assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32)
+ // CHECK: [[z]] = Rem(const 1_i32, const 0_i32);
let y = 0;
let _z = 1 % y;
}
diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs
index 38c97a4cf..266105c11 100644
--- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs
+++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs
@@ -1,4 +1,3 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
@@ -6,6 +5,10 @@
// EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff
#[allow(unconditional_panic)]
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: debug _b => [[b:_.*]];
+ // CHECK: [[b]] = (*[[a]])[3 of 4];
let a: *const [_] = &[1, 2, 3];
unsafe {
let _b = (*a)[3];
diff --git a/tests/mir-opt/const_prop/boolean_identities.rs b/tests/mir-opt/const_prop/boolean_identities.rs
index 781cce8c7..2aa038034 100644
--- a/tests/mir-opt/const_prop/boolean_identities.rs
+++ b/tests/mir-opt/const_prop/boolean_identities.rs
@@ -1,10 +1,16 @@
-// skip-filecheck
// unit-test: ConstProp
-// compile-flags: -O -Zmir-opt-level=4
// EMIT_MIR boolean_identities.test.ConstProp.diff
pub fn test(x: bool, y: bool) -> bool {
- (y | true) & (x & false)
+ // CHECK-LABEL: fn test(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: debug b => [[b:_.*]];
+ // CHECK: [[a]] = const true;
+ // CHECK: [[b]] = const false;
+ // CHECK: _0 = const false;
+ let a = (y | true);
+ let b = (x & false);
+ a & b
}
fn main() {
diff --git a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff b/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff
index d80534199..41e1acdff 100644
--- a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff
+++ b/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff
@@ -5,20 +5,42 @@
debug x => _1;
debug y => _2;
let mut _0: bool;
- let mut _3: bool;
+ let _3: bool;
let mut _4: bool;
- let mut _5: bool;
let mut _6: bool;
+ let mut _7: bool;
+ let mut _8: bool;
+ scope 1 {
+ debug a => _3;
+ let _5: bool;
+ scope 2 {
+ debug b => _5;
+ }
+ }
bb0: {
StorageLive(_3);
-- _3 = BitOr(_2, const true);
+ StorageLive(_4);
+ _4 = _2;
+- _3 = BitOr(move _4, const true);
+ _3 = const true;
+ StorageDead(_4);
StorageLive(_5);
-- _5 = BitAnd(_1, const false);
-- _0 = BitAnd(move _3, move _5);
+ StorageLive(_6);
+ _6 = _1;
+- _5 = BitAnd(move _6, const false);
+ _5 = const false;
+ StorageDead(_6);
+ StorageLive(_7);
+- _7 = _3;
++ _7 = const true;
+ StorageLive(_8);
+- _8 = _5;
+- _0 = BitAnd(move _7, move _8);
++ _8 = const false;
+ _0 = const false;
+ StorageDead(_8);
+ StorageDead(_7);
StorageDead(_5);
StorageDead(_3);
return;
diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs
index c6807ece1..90a8e33e8 100644
--- a/tests/mir-opt/const_prop/boxes.rs
+++ b/tests/mir-opt/const_prop/boxes.rs
@@ -1,4 +1,3 @@
-// skip-filecheck
// unit-test: ConstProp
// compile-flags: -O
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
@@ -9,6 +8,11 @@
// EMIT_MIR boxes.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: (*{{_.*}}) = const 42_i32;
+ // CHECK: [[tmp:_.*]] = (*{{_.*}});
+ // CHECK: [[x]] = Add(move [[tmp]], const 0_i32);
let x = *(#[rustc_box]
Box::new(42))
+ 0;
diff --git a/tests/mir-opt/const_prop/cast.rs b/tests/mir-opt/const_prop/cast.rs
index 3d543bada..b81c2740a 100644
--- a/tests/mir-opt/const_prop/cast.rs
+++ b/tests/mir-opt/const_prop/cast.rs
@@ -1,9 +1,12 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR cast.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = const 42_u32;
+ // CHECK: [[y]] = const 42_u8;
let x = 42u8 as u32;
-
let y = 42u32 as u8;
}
diff --git a/tests/mir-opt/const_prop/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs
index 6a53aced0..571a5cc4e 100644
--- a/tests/mir-opt/const_prop/checked_add.rs
+++ b/tests/mir-opt/const_prop/checked_add.rs
@@ -1,9 +1,12 @@
-// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// compile-flags: -C overflow-checks=on
// EMIT_MIR checked_add.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: assert(!const false,
+ // CHECK: [[x]] = const 2_u32;
let x: u32 = 1 + 1;
}
diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs b/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs
deleted file mode 100644
index 5bd4731bf..000000000
--- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// skip-filecheck
-// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
-// unit-test: ConstProp
-#[inline(never)]
-fn read(_: usize) { }
-
-// EMIT_MIR const_prop_fails_gracefully.main.ConstProp.diff
-fn main() {
- const FOO: &i32 = &1;
- let x = FOO as *const i32 as usize;
- read(x);
-}
diff --git a/tests/mir-opt/const_prop/discriminant.rs b/tests/mir-opt/const_prop/discriminant.rs
index 11405f38b..0ed683d62 100644
--- a/tests/mir-opt/const_prop/discriminant.rs
+++ b/tests/mir-opt/const_prop/discriminant.rs
@@ -1,6 +1,4 @@
-// skip-filecheck
// unit-test: ConstProp
-// compile-flags: -O
// FIXME(wesleywiser): Ideally, we could const-prop away all of this and just be left with
// `let x = 42` but that doesn't work because const-prop doesn't support `Operand::Indirect`
@@ -10,5 +8,18 @@
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR discriminant.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: bb0: {
+ // CHECK: switchInt(const 1_isize) -> [1: bb1, otherwise: bb3];
+ // CHECK: bb1: {
+ // CHECK: switchInt(const true) -> [0: bb3, otherwise: bb2];
+ // CHECK: bb2: {
+ // CHECK: [[tmp:_.*]] = const 42_i32;
+ // CHECK: goto -> bb4;
+ // CHECK: bb3: {
+ // CHECK: [[tmp]] = const 10_i32;
+ // CHECK: goto -> bb4;
+ // CHECK: bb4: {
+ // CHECK: {{_.*}} = Add(move [[tmp]], const 0_i32);
let x = (if let Some(true) = Some(true) { 42 } else { 10 }) + 0;
}
diff --git a/tests/mir-opt/const_prop/indirect.rs b/tests/mir-opt/const_prop/indirect.rs
index 0e6e1d78d..d3c42e3eb 100644
--- a/tests/mir-opt/const_prop/indirect.rs
+++ b/tests/mir-opt/const_prop/indirect.rs
@@ -1,9 +1,11 @@
-// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// compile-flags: -C overflow-checks=on
// EMIT_MIR indirect.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: [[x]] = const 3_u8;
let x = (2u32 as u8) + 1;
}
diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff
index b30deb2a4..11cdf9e09 100644
--- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff
+++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff
@@ -8,7 +8,7 @@
let mut _3: u8;
scope 1 {
}
- scope 2 (inlined <u8 as Add>::add) {
+ scope 2 (inlined #[track_caller] <u8 as Add>::add) {
debug self => _2;
debug other => _3;
let mut _4: (u8, bool);
diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff
index 47c51196c..181a2f287 100644
--- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff
@@ -8,7 +8,7 @@
let mut _3: u8;
scope 1 {
}
- scope 2 (inlined <u8 as Add>::add) {
+ scope 2 (inlined #[track_caller] <u8 as Add>::add) {
debug self => _2;
debug other => _3;
let mut _4: (u8, bool);
diff --git a/tests/mir-opt/const_prop/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs
index 41989462d..5b561ae14 100644
--- a/tests/mir-opt/const_prop/inherit_overflow.rs
+++ b/tests/mir-opt/const_prop/inherit_overflow.rs
@@ -1,11 +1,14 @@
-// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// compile-flags: -Zmir-enable-passes=+Inline
+// After inlining, this will contain a `CheckedBinaryOp`.
+// Propagating the overflow is ok as codegen will just skip emitting the panic.
// EMIT_MIR inherit_overflow.main.ConstProp.diff
fn main() {
- // After inlining, this will contain a `CheckedBinaryOp`.
- // Propagating the overflow is ok as codegen will just skip emitting the panic.
+ // CHECK-LABEL: fn main(
+ // CHECK: {{_.*}} = const (0_u8, true);
+ // CHECK: assert(!const true,
+ // CHECK: {{_.*}} = const 0_u8;
let _ = <u8 as std::ops::Add>::add(255, 1);
}
diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff
index 6484b4b67..ff93c85e5 100644
--- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff
+++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff
@@ -5,17 +5,24 @@
let mut _0: ();
let _1: ();
let mut _2: ((), u8, u8);
+ let mut _3: ();
bb0: {
+ StorageLive(_1);
StorageLive(_2);
-- _2 = (const (), const 0_u8, const 0_u8);
-- _1 = encode(move _2) -> [return: bb1, unwind unreachable];
+ StorageLive(_3);
+ _3 = ();
+- _2 = (move _3, const 0_u8, const 0_u8);
+ _2 = const ((), 0_u8, 0_u8);
+ StorageDead(_3);
+- _1 = encode(move _2) -> [return: bb1, unwind unreachable];
+ _1 = encode(const ((), 0_u8, 0_u8)) -> [return: bb1, unwind unreachable];
}
bb1: {
StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
return;
}
+ }
diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff
index b02f04078..8790aad45 100644
--- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff
@@ -5,17 +5,24 @@
let mut _0: ();
let _1: ();
let mut _2: ((), u8, u8);
+ let mut _3: ();
bb0: {
+ StorageLive(_1);
StorageLive(_2);
-- _2 = (const (), const 0_u8, const 0_u8);
-- _1 = encode(move _2) -> [return: bb1, unwind continue];
+ StorageLive(_3);
+ _3 = ();
+- _2 = (move _3, const 0_u8, const 0_u8);
+ _2 = const ((), 0_u8, 0_u8);
+ StorageDead(_3);
+- _1 = encode(move _2) -> [return: bb1, unwind continue];
+ _1 = encode(const ((), 0_u8, 0_u8)) -> [return: bb1, unwind continue];
}
bb1: {
StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
return;
}
+ }
diff --git a/tests/mir-opt/const_prop/issue_66971.rs b/tests/mir-opt/const_prop/issue_66971.rs
index 386c95b5b..49d598ff2 100644
--- a/tests/mir-opt/const_prop/issue_66971.rs
+++ b/tests/mir-opt/const_prop/issue_66971.rs
@@ -1,7 +1,5 @@
-// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
-// compile-flags: -Z mir-opt-level=3
// Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected
// outputs below, after ConstProp this is how _2 would look like with the bug:
@@ -16,5 +14,7 @@ fn encode(this: ((), u8, u8)) {
// EMIT_MIR issue_66971.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: = encode(const ((), 0_u8, 0_u8))
encode(((), 0, 0));
}
diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff
index c1ef453e9..3de9cdd79 100644
--- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff
+++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff
@@ -8,6 +8,7 @@
let mut _3: (u8, u8);
bb0: {
+ StorageLive(_1);
StorageLive(_2);
StorageLive(_3);
- _3 = (const 1_u8, const 2_u8);
@@ -21,6 +22,8 @@
bb1: {
StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
return;
}
+ }
diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff
index 53cdcc181..72cf48b5c 100644
--- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff
@@ -8,6 +8,7 @@
let mut _3: (u8, u8);
bb0: {
+ StorageLive(_1);
StorageLive(_2);
StorageLive(_3);
- _3 = (const 1_u8, const 2_u8);
@@ -21,6 +22,8 @@
bb1: {
StorageDead(_2);
+ StorageDead(_1);
+ _0 = const ();
return;
}
+ }
diff --git a/tests/mir-opt/const_prop/issue_67019.rs b/tests/mir-opt/const_prop/issue_67019.rs
index 2f61298bb..f0a09e6e8 100644
--- a/tests/mir-opt/const_prop/issue_67019.rs
+++ b/tests/mir-opt/const_prop/issue_67019.rs
@@ -1,7 +1,5 @@
-// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
-// compile-flags: -Z mir-opt-level=3
// This used to ICE in const-prop
@@ -11,5 +9,7 @@ fn test(this: ((u8, u8),)) {
// EMIT_MIR issue_67019.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: = test(const ((1_u8, 2_u8),))
test(((1, 2),));
}
diff --git a/tests/mir-opt/const_prop/mult_by_zero.rs b/tests/mir-opt/const_prop/mult_by_zero.rs
index 47e15205e..2e9c63a1c 100644
--- a/tests/mir-opt/const_prop/mult_by_zero.rs
+++ b/tests/mir-opt/const_prop/mult_by_zero.rs
@@ -1,9 +1,10 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR mult_by_zero.test.ConstProp.diff
-fn test(x : i32) -> i32 {
- x * 0
+fn test(x: i32) -> i32 {
+ // CHECK: fn test(
+ // CHECK: _0 = const 0_i32;
+ x * 0
}
fn main() {
diff --git a/tests/mir-opt/const_prop/mutable_variable.rs b/tests/mir-opt/const_prop/mutable_variable.rs
index 175d63d46..6c74ea5b9 100644
--- a/tests/mir-opt/const_prop/mutable_variable.rs
+++ b/tests/mir-opt/const_prop/mutable_variable.rs
@@ -1,8 +1,13 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR mutable_variable.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = const 42_i32;
+ // CHECK: [[x]] = const 99_i32;
+ // CHECK: [[y]] = const 99_i32;
let mut x = 42;
x = 99;
let y = x;
diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs
index f926771ae..a38296502 100644
--- a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs
+++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs
@@ -1,8 +1,13 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = const (42_i32, 43_i32);
+ // CHECK: ([[x]].1: i32) = const 99_i32;
+ // CHECK: [[y]] = const (42_i32, 99_i32);
let mut x = (42, 43);
x.1 = 99;
let y = x;
diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs
index a81aa7b49..60f414ae2 100644
--- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs
+++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs
@@ -1,8 +1,15 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug z => [[z:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = (const 42_i32, const 43_i32);
+ // CHECK: [[z]] = &mut [[x]];
+ // CHECK: ((*[[z]]).1: i32) = const 99_i32;
+ // CHECK: [[y]] = [[x]];
let mut x = (42, 43);
let z = &mut x;
z.1 = 99;
diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs
index 54a5d9223..888fcde2d 100644
--- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs
+++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs
@@ -1,9 +1,15 @@
-// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = foo()
+ // CHECK: ([[x]].1: i32) = const 99_i32;
+ // CHECK: ([[x]].0: i32) = const 42_i32;
+ // CHECK: [[y]] = const 99_i32;
let mut x: (i32, i32) = foo();
x.1 = 99;
x.0 = 42;
diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs
index a7aeeccd8..49e9a7015 100644
--- a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs
+++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs
@@ -1,10 +1,17 @@
-// skip-filecheck
// unit-test: ConstProp
+// Verify that we do not propagate the contents of this mutable static.
static mut STATIC: u32 = 0x42424242;
// EMIT_MIR mutable_variable_no_prop.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: [[x]] = const 42_u32;
+ // CHECK: [[tmp:_.*]] = (*{{_.*}});
+ // CHECK: [[x]] = move [[tmp]];
+ // CHECK: [[y]] = [[x]];
let mut x = 42;
unsafe {
x = STATIC;
diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs
index 6bdb136a9..04e347fc0 100644
--- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs
+++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs
@@ -1,14 +1,24 @@
-// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: debug y => [[y:_.*]];
+ // CHECK: debug z => [[z:_.*]];
+ // CHECK: [[a]] = foo()
+ // CHECK: [[x]] = const (1_i32, 2_i32);
+ // CHECK: [[tmp:_.*]] = [[a]];
+ // CHECK: ([[x]].1: i32) = move [[tmp]];
+ // CHECK: [[y]] = ([[x]].1: i32);
+ // CHECK: [[z]] = const 1_i32;
let a = foo();
let mut x: (i32, i32) = (1, 2);
x.1 = a;
let y = x.1;
- let z = x.0; // this could theoretically be allowed, but we can't handle it right now
+ let z = x.0;
}
#[inline(never)]
diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff
index bd1de7476..bd1de7476 100644
--- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-abort.diff
+++ b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff
diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff
index 850b743fe..850b743fe 100644
--- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff
diff --git a/tests/mir-opt/const_prop/pointer_expose_address.rs b/tests/mir-opt/const_prop/pointer_expose_address.rs
new file mode 100644
index 000000000..631aac901
--- /dev/null
+++ b/tests/mir-opt/const_prop/pointer_expose_address.rs
@@ -0,0 +1,18 @@
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// unit-test: ConstProp
+
+#[inline(never)]
+fn read(_: usize) { }
+
+// EMIT_MIR pointer_expose_address.main.ConstProp.diff
+fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: [[ptr:_.*]] = const _;
+ // CHECK: [[ref:_.*]] = &raw const (*[[ptr]]);
+ // CHECK: [[x:_.*]] = move [[ref]] as usize (PointerExposeAddress);
+ // CHECK: [[arg:_.*]] = [[x]];
+ // CHECK: = read(move [[arg]])
+ const FOO: &i32 = &1;
+ let x = FOO as *const i32 as usize;
+ read(x);
+}
diff --git a/tests/mir-opt/const_prop/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs
index a8d8cfacc..0fa18dd10 100644
--- a/tests/mir-opt/const_prop/read_immutable_static.rs
+++ b/tests/mir-opt/const_prop/read_immutable_static.rs
@@ -1,9 +1,11 @@
-// skip-filecheck
// unit-test: ConstProp
static FOO: u8 = 2;
// EMIT_MIR read_immutable_static.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: [[x]] = const 4_u8;
let x = FOO + FOO;
}
diff --git a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff
index 6b897a881..a54ae8d2f 100644
--- a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff
+++ b/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff
@@ -7,6 +7,9 @@
let mut _2: &i32;
let _3: i32;
let mut _4: &i32;
+ scope 1 {
+ debug a => _1;
+ }
bb0: {
StorageLive(_1);
@@ -15,8 +18,8 @@
_2 = &(*_4);
_1 = (*_2);
StorageDead(_2);
- StorageDead(_1);
_0 = const ();
+ StorageDead(_1);
return;
}
}
diff --git a/tests/mir-opt/const_prop/ref_deref.rs b/tests/mir-opt/const_prop/ref_deref.rs
index f2fa024f7..5bceae749 100644
--- a/tests/mir-opt/const_prop/ref_deref.rs
+++ b/tests/mir-opt/const_prop/ref_deref.rs
@@ -1,7 +1,9 @@
-// skip-filecheck
// unit-test: ConstProp
-// EMIT_MIR ref_deref.main.ConstProp.diff
+// EMIT_MIR ref_deref.main.ConstProp.diff
fn main() {
- *(&4);
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: [[a]] = (*{{_.*}});
+ let a = *(&4);
}
diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff
index 7f6161665..05a4e1774 100644
--- a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff
+++ b/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff
@@ -7,6 +7,9 @@
let mut _2: &i32;
let _3: (i32, i32);
let mut _4: &(i32, i32);
+ scope 1 {
+ debug a => _1;
+ }
bb0: {
StorageLive(_1);
@@ -15,8 +18,8 @@
_2 = &((*_4).1: i32);
_1 = (*_2);
StorageDead(_2);
- StorageDead(_1);
_0 = const ();
+ StorageDead(_1);
return;
}
}
diff --git a/tests/mir-opt/const_prop/ref_deref_project.rs b/tests/mir-opt/const_prop/ref_deref_project.rs
index 1b9e0acb2..4b5c67303 100644
--- a/tests/mir-opt/const_prop/ref_deref_project.rs
+++ b/tests/mir-opt/const_prop/ref_deref_project.rs
@@ -1,7 +1,10 @@
-// skip-filecheck
+// This does not currently propagate (#67862)
// unit-test: ConstProp
-// EMIT_MIR ref_deref_project.main.ConstProp.diff
+// EMIT_MIR ref_deref_project.main.ConstProp.diff
fn main() {
- *(&(4, 5).1); // This does not currently propagate (#67862)
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: [[a]] = (*{{_.*}});
+ let a = *(&(4, 5).1);
}
diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.rs b/tests/mir-opt/const_prop/reify_fn_ptr.rs
index da7de80c5..33fdd4142 100644
--- a/tests/mir-opt/const_prop/reify_fn_ptr.rs
+++ b/tests/mir-opt/const_prop/reify_fn_ptr.rs
@@ -1,7 +1,10 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR reify_fn_ptr.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: [[ptr:_.*]] = main as fn() (PointerCoercion(ReifyFnPointer));
+ // CHECK: [[addr:_.*]] = move [[ptr]] as usize (PointerExposeAddress);
+ // CHECK: [[back:_.*]] = move [[addr]] as *const fn() (PointerFromExposedAddress);
let _ = main as usize as *const fn();
}
diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs
index 92194d6bb..9f688bbb5 100644
--- a/tests/mir-opt/const_prop/repeat.rs
+++ b/tests/mir-opt/const_prop/repeat.rs
@@ -1,9 +1,11 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR repeat.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: debug x => [[x:_.*]];
+ // CHECK: [[x]] = const 42_u32;
let x: u32 = [42; 8][2] + 0;
}
diff --git a/tests/mir-opt/const_prop/return_place.rs b/tests/mir-opt/const_prop/return_place.rs
index 1263de793..286543abb 100644
--- a/tests/mir-opt/const_prop/return_place.rs
+++ b/tests/mir-opt/const_prop/return_place.rs
@@ -1,4 +1,3 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// compile-flags: -C overflow-checks=on
@@ -6,6 +5,8 @@
// EMIT_MIR return_place.add.ConstProp.diff
// EMIT_MIR return_place.add.PreCodegen.before.mir
fn add() -> u32 {
+ // CHECK-LABEL: fn add(
+ // CHECK: _0 = const 4_u32;
2 + 2
}
diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.rs b/tests/mir-opt/const_prop/scalar_literal_propagation.rs
index 9dcddf7c7..782cd35d4 100644
--- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs
+++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs
@@ -1,8 +1,10 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+
// EMIT_MIR scalar_literal_propagation.main.ConstProp.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: = consume(const 1_u32)
let x = 1;
consume(x);
}
diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff
index c2e1288b4..7d5d036f4 100644
--- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff
+++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff
@@ -12,6 +12,9 @@
let mut _7: usize;
let mut _8: bool;
let mut _9: &[u32; 3];
+ scope 1 {
+ debug a => _1;
+ }
bb0: {
StorageLive(_1);
@@ -39,8 +42,8 @@
StorageDead(_6);
StorageDead(_4);
StorageDead(_2);
- StorageDead(_1);
_0 = const ();
+ StorageDead(_1);
return;
}
}
diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff
index 23646c3c9..fa4c5a71b 100644
--- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff
@@ -12,6 +12,9 @@
let mut _7: usize;
let mut _8: bool;
let mut _9: &[u32; 3];
+ scope 1 {
+ debug a => _1;
+ }
bb0: {
StorageLive(_1);
@@ -39,8 +42,8 @@
StorageDead(_6);
StorageDead(_4);
StorageDead(_2);
- StorageDead(_1);
_0 = const ();
+ StorageDead(_1);
return;
}
}
diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff
index c2e1288b4..7d5d036f4 100644
--- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff
+++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff
@@ -12,6 +12,9 @@
let mut _7: usize;
let mut _8: bool;
let mut _9: &[u32; 3];
+ scope 1 {
+ debug a => _1;
+ }
bb0: {
StorageLive(_1);
@@ -39,8 +42,8 @@
StorageDead(_6);
StorageDead(_4);
StorageDead(_2);
- StorageDead(_1);
_0 = const ();
+ StorageDead(_1);
return;
}
}
diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff
index 23646c3c9..fa4c5a71b 100644
--- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff
+++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff
@@ -12,6 +12,9 @@
let mut _7: usize;
let mut _8: bool;
let mut _9: &[u32; 3];
+ scope 1 {
+ debug a => _1;
+ }
bb0: {
StorageLive(_1);
@@ -39,8 +42,8 @@
StorageDead(_6);
StorageDead(_4);
StorageDead(_2);
- StorageDead(_1);
_0 = const ();
+ StorageDead(_1);
return;
}
}
diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs
index 3b551b6b1..0bf442726 100644
--- a/tests/mir-opt/const_prop/slice_len.rs
+++ b/tests/mir-opt/const_prop/slice_len.rs
@@ -1,10 +1,13 @@
-// skip-filecheck
-// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: ConstProp
// compile-flags: -Zmir-enable-passes=+InstSimplify
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR slice_len.main.ConstProp.diff
fn main() {
- (&[1u32, 2, 3] as &[u32])[1];
+ // CHECK-LABEL: fn main(
+ // CHECK: debug a => [[a:_.*]];
+ // CHECK: assert(const true,
+ // CHECK: [[a]] = const 2_u32;
+ let a = (&[1u32, 2, 3] as &[u32])[1];
}
diff --git a/tests/mir-opt/const_prop/switch_int.rs b/tests/mir-opt/const_prop/switch_int.rs
index 7ec56e11e..d1cbaae49 100644
--- a/tests/mir-opt/const_prop/switch_int.rs
+++ b/tests/mir-opt/const_prop/switch_int.rs
@@ -1,13 +1,20 @@
-// skip-filecheck
// unit-test: ConstProp
// compile-flags: -Zmir-enable-passes=+SimplifyConstCondition-after-const-prop
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+
#[inline(never)]
fn foo(_: i32) { }
// EMIT_MIR switch_int.main.ConstProp.diff
// EMIT_MIR switch_int.main.SimplifyConstCondition-after-const-prop.diff
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: bb0: {
+ // CHECK-NOT: switchInt(
+ // CHECK: goto -> [[bb:bb.*]];
+ // CHECK: [[bb]]: {
+ // CHECK-NOT: _0 = foo(const -1_i32)
+ // CHECK: _0 = foo(const 0_i32)
match 1 {
1 => foo(0),
_ => foo(-1),
diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs
index e0bc6e1be..dfc4a6f3f 100644
--- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs
+++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs
@@ -1,10 +1,11 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR tuple_literal_propagation.main.ConstProp.diff
+
fn main() {
+ // CHECK-LABEL: fn main(
+ // CHECK: = consume(const (1_u32, 2_u32))
let x = (1, 2);
-
consume(x);
}
diff --git a/tests/mir-opt/const_prop/while_let_loops.rs b/tests/mir-opt/const_prop/while_let_loops.rs
index 39081c355..8b2a73438 100644
--- a/tests/mir-opt/const_prop/while_let_loops.rs
+++ b/tests/mir-opt/const_prop/while_let_loops.rs
@@ -1,8 +1,9 @@
-// skip-filecheck
// unit-test: ConstProp
// EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff
pub fn change_loop_body() {
+ // CHECK-LABEL: fn change_loop_body(
+ // CHECK: switchInt(const 0_isize)
let mut _x = 0;
while let Some(0u32) = None {
_x = 1;