Skip to content

Commit c204231

Browse files
committed
Add FileCheck to copy_propagation_arg.rs
1 parent 3b1e20c commit c204231

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tests/mir-opt/copy-prop/copy_propagation_arg.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// Check that CopyProp does not propagate an assignment to a function argument
43
// (doing so can break usages of the original argument value)
@@ -9,25 +8,46 @@ fn dummy(x: u8) -> u8 {
98

109
// EMIT_MIR copy_propagation_arg.foo.CopyProp.diff
1110
fn foo(mut x: u8) {
11+
// CHECK-LABEL: fn foo(
12+
// CHECK: debug x => [[x:_.*]];
13+
// CHECK: [[three:_.*]] = copy [[x]];
14+
// CHECK: [[two:_.*]] = dummy(move [[three]])
15+
// CHECK: [[x]] = move [[two]];
1216
// calling `dummy` to make a use of `x` that copyprop cannot eliminate
1317
x = dummy(x); // this will assign a local to `x`
1418
}
1519

1620
// EMIT_MIR copy_propagation_arg.bar.CopyProp.diff
1721
fn bar(mut x: u8) {
22+
// CHECK-LABEL: fn bar(
23+
// CHECK: debug x => [[x:_.*]];
24+
// CHECK: [[three:_.*]] = copy [[x]];
25+
// CHECK: dummy(move [[three]])
26+
// CHECK: [[x]] = const 5_u8;
1827
dummy(x);
1928
x = 5;
2029
}
2130

2231
// EMIT_MIR copy_propagation_arg.baz.CopyProp.diff
2332
fn baz(mut x: i32) -> i32 {
24-
// self-assignment to a function argument should be eliminated
33+
// CHECK-LABEL: fn baz(
34+
// CHECK: debug x => [[x:_.*]];
35+
// CHECK: [[x2:_.*]] = copy [[x]];
36+
// CHECK: [[x]] = move [[x2]];
37+
// CHECK: _0 = copy [[x]];
38+
// In the original case for DestProp, the self-assignment to a function argument is eliminated,
39+
// but in CopyProp it is not eliminated.
2540
x = x;
2641
x
2742
}
2843

2944
// EMIT_MIR copy_propagation_arg.arg_src.CopyProp.diff
3045
fn arg_src(mut x: i32) -> i32 {
46+
// CHECK-LABEL: fn arg_src(
47+
// CHECK: debug x => [[x:_.*]];
48+
// CHECK: debug y => [[y:_.*]];
49+
// CHECK: [[y]] = copy [[x]];
50+
// CHECK: [[x]] = const 123_i32;
3151
let y = x;
3252
x = 123; // Don't propagate this assignment to `y`
3353
y

0 commit comments

Comments
 (0)