-
Notifications
You must be signed in to change notification settings - Fork 13k
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 mir-opt/dest-prop tests #122300
Changes from 5 commits
6bd68fc
f238eba
853311c
0692090
f0f867e
2d5a483
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// skip-filecheck | ||
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY | ||
// Check that DestinationPropagation does not propagate an assignment to a function argument | ||
// (doing so can break usages of the original argument value) | ||
|
@@ -9,25 +8,42 @@ fn dummy(x: u8) -> u8 { | |
|
||
// EMIT_MIR copy_propagation_arg.foo.DestinationPropagation.diff | ||
fn foo(mut x: u8) { | ||
// CHECK-LABEL: fn foo( | ||
// CHECK: debug x => [[x:_.*]]; | ||
// CHECK: dummy(move [[x]]) | ||
// CHECK: [[x]] = move {{_.*}}; | ||
// calling `dummy` to make a use of `x` that copyprop cannot eliminate | ||
x = dummy(x); // this will assign a local to `x` | ||
} | ||
|
||
// EMIT_MIR copy_propagation_arg.bar.DestinationPropagation.diff | ||
fn bar(mut x: u8) { | ||
// CHECK-LABEL: fn bar( | ||
// CHECK: debug x => [[x:_.*]]; | ||
// CHECK: dummy(move [[x]]) | ||
// CHECK: [[x]] = const 5_u8; | ||
dummy(x); | ||
x = 5; | ||
} | ||
|
||
// EMIT_MIR copy_propagation_arg.baz.DestinationPropagation.diff | ||
fn baz(mut x: i32) -> i32 { | ||
// CHECK-LABEL: fn baz( | ||
// CHECK: debug x => [[x:_.*]]; | ||
// CHECK-NOT: [[x]] = {{_.*}} | ||
// self-assignment to a function argument should be eliminated | ||
x = x; | ||
x | ||
} | ||
|
||
// EMIT_MIR copy_propagation_arg.arg_src.DestinationPropagation.diff | ||
fn arg_src(mut x: i32) -> i32 { | ||
// CHECK-LABEL: fn arg_src( | ||
// CHECK: debug x => [[x:_.*]]; | ||
// CHECK: debug y => [[y:_.*]]; | ||
// CHECK: [[y]] = [[x]] | ||
// CHECK: [[x]] = const 123_i32; | ||
// CHECK-NOT: {{_.*}} = [[y]]; | ||
let y = x; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we directly give them their names, aka There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm for me, it feels easier to read the test because you can more easily read the checks directly referencing the variable names (x and y), but maybe I'm misunderstanding something. |
||
x = 123; // Don't propagate this assignment to `y` | ||
y | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// skip-filecheck | ||
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY | ||
// This is a copy of the `dead_stores_79191` test, except that we turn on DSE. This demonstrates | ||
// that that pass enables this one to do more optimizations. | ||
|
@@ -12,6 +11,13 @@ fn id<T>(x: T) -> T { | |
|
||
// EMIT_MIR dead_stores_better.f.DestinationPropagation.after.mir | ||
pub fn f(mut a: usize) -> usize { | ||
// CHECK-LABEL: fn f( | ||
// CHECK: debug a => [[a:_.*]]; | ||
// CHECK: debug b => [[b:_.*]]; | ||
// CHECK: [[b]] = [[a]]; | ||
// CHECK: [[a]] = const 5_usize; | ||
// CHECK: [[a]] = move [[b]]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't DSE have removed this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was surprised too, but the test was like this |
||
// CHECK: id::<usize>(move [[a]]) | ||
let b = a; | ||
a = 5; | ||
a = b; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
// skip-filecheck | ||
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY | ||
//! Copy of `nrvo-simple.rs`, to ensure that full dest-prop handles it too. | ||
//@ unit-test: DestinationPropagation | ||
// EMIT_MIR simple.nrvo.DestinationPropagation.diff | ||
fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] { | ||
// CHECK-LABEL: fn nrvo( | ||
// CHECK: debug init => [[init:_.*]]; | ||
// CHECK-NOT: {{_.*}} = [[init]]; | ||
// CHECK: move [[init]](move {{_.*}}) | ||
let mut buf = [0; 1024]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, the point of this test is to track what happens to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed that, because there were no changes to |
||
init(&mut buf); | ||
buf | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be on the safe side.