1- // skip-filecheck
21// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32// Check that DestinationPropagation does not propagate an assignment to a function argument
43// (doing so can break usages of the original argument value)
@@ -9,25 +8,42 @@ fn dummy(x: u8) -> u8 {
98
109// EMIT_MIR copy_propagation_arg.foo.DestinationPropagation.diff
1110fn foo ( mut x : u8 ) {
11+ // CHECK-LABEL: fn foo(
12+ // CHECK: debug x => [[x:_.*]];
13+ // CHECK: dummy(move [[x]])
14+ // CHECK: [[x]] = move {{_.*}};
1215 // calling `dummy` to make a use of `x` that copyprop cannot eliminate
1316 x = dummy ( x) ; // this will assign a local to `x`
1417}
1518
1619// EMIT_MIR copy_propagation_arg.bar.DestinationPropagation.diff
1720fn bar ( mut x : u8 ) {
21+ // CHECK-LABEL: fn bar(
22+ // CHECK: debug x => [[x:_.*]];
23+ // CHECK: dummy(move [[x]])
24+ // CHECK: [[x]] = const 5_u8;
1825 dummy ( x) ;
1926 x = 5 ;
2027}
2128
2229// EMIT_MIR copy_propagation_arg.baz.DestinationPropagation.diff
2330fn baz ( mut x : i32 ) -> i32 {
31+ // CHECK-LABEL: fn baz(
32+ // CHECK: debug x => [[x:_.*]];
33+ // CHECK-NOT: [[x]] = {{_.*}}
2434 // self-assignment to a function argument should be eliminated
2535 x = x;
2636 x
2737}
2838
2939// EMIT_MIR copy_propagation_arg.arg_src.DestinationPropagation.diff
3040fn arg_src ( mut x : i32 ) -> i32 {
41+ // CHECK-LABEL: fn arg_src(
42+ // CHECK: debug x => [[x:_.*]];
43+ // CHECK: debug y => [[y:_.*]];
44+ // CHECK: [[y]] = [[x]]
45+ // CHECK: [[x]] = const 123_i32;
46+ // CHECK-NOT: {{_.*}} = [[y]];
3147 let y = x;
3248 x = 123 ; // Don't propagate this assignment to `y`
3349 y
0 commit comments