-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Add FileCheck annotations to mir-opt/copy-prop #135099
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
base: master
Are you sure you want to change the base?
Changes from 14 commits
1b5a744
e6dcb25
78a143f
ab21ba3
4057797
77d5711
f53476b
2d04a63
d0365d3
334d501
d3176d5
ef42830
4627ea1
381466c
1aeeebc
30a656a
0d6fa54
430d888
6eab7c7
7a64137
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 CopyProp does not propagate an assignment to a function argument | ||
// (doing so can break usages of the original argument value) | ||
|
@@ -9,25 +8,43 @@ fn dummy(x: u8) -> u8 { | |
|
||
// EMIT_MIR copy_propagation_arg.foo.CopyProp.diff | ||
fn foo(mut x: u8) { | ||
// CHECK-LABEL: fn foo( | ||
// CHECK: debug x => [[x:_.*]]; | ||
// CHECK: [[three:_.*]] = copy [[x]]; | ||
// CHECK: [[two:_.*]] = dummy(move [[three]]) | ||
// CHECK: [[x]] = move [[two]]; | ||
// 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.CopyProp.diff | ||
fn bar(mut x: u8) { | ||
// CHECK-LABEL: fn bar( | ||
// CHECK: debug x => [[x:_.*]]; | ||
// CHECK: [[three:_.*]] = copy [[x]]; | ||
// CHECK: dummy(move [[three]]) | ||
// CHECK: [[x]] = const 5_u8; | ||
dummy(x); | ||
x = 5; | ||
} | ||
|
||
// EMIT_MIR copy_propagation_arg.baz.CopyProp.diff | ||
fn baz(mut x: i32) -> i32 { | ||
// CHECK-LABEL: fn baz( | ||
// CHECK: debug x => [[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. I'm wondering if we don't need this function for CopyProp. 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. Indeed. Do you mind fixing the comment and adding a 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.
There is no self-copy instruction in the mir file, but it has 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 modified it in 7a64137. Please check if the change matches with your thought 🙏 |
||
// CHECK: _0 = copy [[x]]; | ||
// self-assignment to a function argument should be eliminated | ||
x = x; | ||
x | ||
} | ||
|
||
// EMIT_MIR copy_propagation_arg.arg_src.CopyProp.diff | ||
fn arg_src(mut x: i32) -> i32 { | ||
// CHECK-LABEL: fn arg_src( | ||
// CHECK: debug x => [[x:_.*]]; | ||
// CHECK: debug y => [[y:_.*]]; | ||
// CHECK: [[y]] = copy [[x]]; | ||
// CHECK: [[x]] = const 123_i32; | ||
let y = x; | ||
x = 123; // Don't propagate this assignment to `y` | ||
y | ||
|
Uh oh!
There was an error while loading. Please reload this page.