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,43 @@ fn dummy(x: u8) -> u8 {
98
109// EMIT_MIR copy_propagation_arg.foo.CopyProp.diff
1110fn 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
1721fn 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
2332fn baz ( mut x : i32 ) -> i32 {
33+ // CHECK-LABEL: fn baz(
34+ // CHECK: debug x => [[x:_.*]];
35+ // CHECK: _0 = copy [[x]];
2436 // self-assignment to a function argument should be eliminated
2537 x = x;
2638 x
2739}
2840
2941// EMIT_MIR copy_propagation_arg.arg_src.CopyProp.diff
3042fn arg_src ( mut x : i32 ) -> i32 {
43+ // CHECK-LABEL: fn arg_src(
44+ // CHECK: debug x => [[x:_.*]];
45+ // CHECK: debug y => [[y:_.*]];
46+ // CHECK: [[y]] = copy [[x]];
47+ // CHECK: [[x]] = const 123_i32;
3148 let y = x;
3249 x = 123 ; // Don't propagate this assignment to `y`
3350 y
0 commit comments