Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion tests/mir-opt/dataflow-const-prop/checked.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
// skip-filecheck
// unit-test: DataflowConstProp
// compile-flags: -Coverflow-checks=on
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY

// EMIT_MIR checked.main.DataflowConstProp.diff
#[allow(arithmetic_overflow)]

// CHECK-LABEL: fn main(
fn main() {
// CHECK: debug a => [[a:_.*]];
// CHECK: debug b => [[b:_.*]];
// CHECK: debug c => [[c:_.*]];
// CHECK: debug d => [[d:_.*]];
// CHECK: debug e => [[e:_.*]];

// CHECK: [[a]] = const 1_i32;
let a = 1;

// CHECK: [[b]] = const 2_i32;
let b = 2;

// CHECK: [[c]] = const 3_i32;
let c = a + b;

// CHECK: [[d]] = const _;
let d = i32::MAX;

// CHECK: [[e]] = const i32::MIN;
let e = d + 1;
}
13 changes: 12 additions & 1 deletion tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// skip-filecheck
// unit-test: DataflowConstProp
// compile-flags: -Zmir-enable-passes=+GVN,+Inline
// ignore-debug assertions change the output MIR
Expand All @@ -11,8 +10,20 @@ struct A {

// EMIT_MIR default_boxed_slice.main.GVN.diff
// EMIT_MIR default_boxed_slice.main.DataflowConstProp.diff

// CHECK-LABEL: fn main(
fn main() {
// ConstProp will create a constant of type `Box<[bool]>`.
// Verify that `DataflowConstProp` does not ICE trying to dereference it directly.

// CHECK: debug a => [[a:_.*]];
// CHECK: scope {{[0-9]+}} (inlined <Box<[bool]> as Default>::default) {
// CHECK: scope {{[0-9]+}} (inlined Unique::<[bool; 0]>::dangling) {
// CHECK: scope {{[0-9]+}} (inlined NonNull::<[bool; 0]>::dangling) {
// We may check other inlined functions as well...

// CHECK: bb{{[0-9]+}}: {
// CHECK: [[box_obj:_.*]] = Box::<[bool]>(_3, const std::alloc::Global);
// CHECK: [[a]] = A { foo: move [[box_obj]] };
let a: A = A { foo: Box::default() };
}