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

Add FileCheck annotations to dataflow-const-prop tests #119759

Merged
merged 19 commits into from
Feb 5, 2024
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
18 changes: 17 additions & 1 deletion tests/mir-opt/dataflow-const-prop/if.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
// skip-filecheck
// unit-test: DataflowConstProp

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

let a = 1;

// CHECK: switchInt(const true) -> [0: {{bb[0-9]+}}, otherwise: [[bb_first_true:bb[0-9]+]]];
sfzhu93 marked this conversation as resolved.
Show resolved Hide resolved
// CHECK: [[bb_first_true]]: {
// CHECK: [[b]] = const 2_i32;
sfzhu93 marked this conversation as resolved.
Show resolved Hide resolved
let b = if a == 1 { 2 } else { 3 };

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

// CHECK: switchInt(const true) -> [0: {{bb[0-9]+}}, otherwise: [[bb_second_true:bb[0-9]+]]];
sfzhu93 marked this conversation as resolved.
Show resolved Hide resolved
// CHECK: [[bb_second_true]]: {
// CHECK: [[d]] = const 1_i32;
let d = if a == 1 { a } else { a + 1 };

// CHECK: [[e]] = const 2_i32;
let e = d + 1;
}
5 changes: 4 additions & 1 deletion tests/mir-opt/dataflow-const-prop/inherit_overflow.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: DataflowConstProp
// compile-flags: -Zmir-enable-passes=+Inline

// EMIT_MIR inherit_overflow.main.DataflowConstProp.diff
// CHECK-LABEL: fn main(
fn main() {
// After inlining, this will contain a `CheckedBinaryOp`.
// Propagating the overflow is ok as codegen will just skip emitting the panic.

// CHECK: {{_.*}} = const (0_u8, true);
// CHECK-LABEL: assert(!const true,
sfzhu93 marked this conversation as resolved.
Show resolved Hide resolved
let _ = <u8 as std::ops::Add>::add(255, 1);
}
5 changes: 4 additions & 1 deletion tests/mir-opt/dataflow-const-prop/issue_81605.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// skip-filecheck
// unit-test: DataflowConstProp
sfzhu93 marked this conversation as resolved.
Show resolved Hide resolved

// EMIT_MIR issue_81605.f.DataflowConstProp.diff

// CHECK-LABEL: fn f
fn f() -> usize {
// CHECK: switchInt(const true) -> [0: {{bb[0-9]+}}, otherwise: {{bb[0-9]+}}];
1 + if true { 1 } else { 2 }
// CHECK: _0 = const 2_usize;
}

fn main() {
Expand Down