-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #118550 - cjgillot:filecheck-const-prop, r=Mark-Simulacrum
- Loading branch information
Showing
52 changed files
with
290 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Oops, something went wrong.