-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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/copy-prop #135099
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
dummy(x); | ||
x = 5; | ||
} | ||
|
||
// EMIT_MIR copy_propagation_arg.baz.CopyProp.diff | ||
fn baz(mut x: i32) -> i32 { | ||
// CHECK-LABEL: fn baz( |
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.
I'm wondering if we don't need this function for CopyProp.
I guess this test file originally from dest-prop, and in dest-prop the self-assignment is eliminated. But in copy-prop, it is not eliminated.
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.
Indeed. Do you mind fixing the comment and adding a CHECK: [[x]] = copy [[x]];
?
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.
and adding a CHECK: [[x]] = copy [[x]];?
There is no self-copy instruction in the mir file, but it has _2 = copy _1
and _0 = copy _1
(I already added).
Do you mean that I should add CHECK: _2 = copy [[x]];
?
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.
I modified it in 7a64137. Please check if the change matches with your thought 🙏
@@ -9,6 +8,9 @@ use core::intrinsics::mir::*; | |||
// EMIT_MIR partial_init.main.CopyProp.diff | |||
#[custom_mir(dialect = "runtime", phase = "post-cleanup")] | |||
pub fn main() { | |||
// CHECK-LABEL: fn main( |
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.
I added this FileCheck annotations, but actually this test case doesn't need them since it checks if rustc compiles the function with CopyProp.
I'd like to confirm that we should keep skip-filecheck
, or go forward with those annotations.
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.
The annotations you put are enough.
r? @cjgillot |
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.
Thanks a lot for the great work. A few nits.
// CHECK-NOT: StorageLive(_1); | ||
// CHECK-NOT: _1 = dummy(const 5_u8) | ||
// CHECK-NOT: _0 = copy _1; | ||
// CHECK-NOT: StorageDead(_1); |
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.
Do you mind adding a CHECK: _0 = dummy(const 5_u8)
?
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.
Addressed in 1aeeebc
let y = dummy(5); // this should get NRVO | ||
y | ||
} | ||
|
||
// EMIT_MIR calls.multiple_edges.CopyProp.diff | ||
#[custom_mir(dialect = "runtime", phase = "initial")] | ||
fn multiple_edges(t: bool) -> u8 { | ||
// CHECK-LABEL: fn multiple_edges( | ||
// CHECK: bb2: { | ||
// CHECK: _0 = copy _2; |
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.
Do you mind adding a CHECK: _2 = dummy(const 13_u8)
?
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.
Added in 1aeeebc
dummy(x); | ||
x = 5; | ||
} | ||
|
||
// EMIT_MIR copy_propagation_arg.baz.CopyProp.diff | ||
fn baz(mut x: i32) -> i32 { | ||
// CHECK-LABEL: fn baz( |
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.
Indeed. Do you mind fixing the comment and adding a CHECK: [[x]] = copy [[x]];
?
tests/mir-opt/copy-prop/cycle.rs
Outdated
@@ -8,6 +7,16 @@ fn val() -> i32 { | |||
|
|||
// EMIT_MIR cycle.main.CopyProp.diff | |||
fn main() { | |||
// CHECK-LABEL: fn main( | |||
// CHECK: debug z => _2; |
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.
Could you add the debug info for x
and y
too?
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.
Added in 30a656a
@@ -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. |
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.
The compile-flags are not up-to-date. They should specify DeadStoreElimination-initial
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.
Modified in 0d6fa54
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY | ||
//@ test-mir-pass: CopyProp | ||
|
||
// EMIT_MIR issue_107511.main.CopyProp.diff | ||
fn main() { | ||
// CHECK-LABEL: fn main( | ||
// CHECK-NOT: StorageLive(_16); |
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.
Could you add debuginfo for _16
, so we understand what happens?
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.
Added in 430d888
// CHECK: bb0: { | ||
// CHECK-NOT: _2 = copy [[a]]; | ||
// CHECK-NOT: _3 = move (_2.0: u8); | ||
// CHECK: _3 = copy ([[a]].0: u8); |
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.
Could you add the CHECK: _0 = opaque(copy [[a]])
and CHECK: _0 = opaque(move _3)
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.
Addressed in 6eab7c7
@@ -9,6 +8,9 @@ use core::intrinsics::mir::*; | |||
// EMIT_MIR partial_init.main.CopyProp.diff | |||
#[custom_mir(dialect = "runtime", phase = "post-cleanup")] | |||
pub fn main() { | |||
// CHECK-LABEL: fn main( |
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.
The annotations you put are enough.
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
…-initial Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
This resolves a part of #116971 .
This PR adds FileCheck annotations to test files under mir-opt/copy-prop.