1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Check that CopyPropagation does not propagate an assignment to a function argument
12 // (doing so can break usages of the original argument value)
14 fn dummy(x: u8) -> u8 {
19 // calling `dummy` to make an use of `x` that copyprop cannot eliminate
20 x = dummy(x); // this will assign a local to `x`
29 // self-assignment to a function argument should be eliminated
33 fn arg_src(mut x: i32) -> i32 {
35 x = 123; // Don't propagate this assignment to `y`
40 // Make sure the function actually gets instantiated.
48 // START rustc.foo.CopyPropagation.before.mir
52 // _2 = const dummy(move _3) -> bb1;
59 // END rustc.foo.CopyPropagation.before.mir
60 // START rustc.foo.CopyPropagation.after.mir
64 // _2 = const dummy(move _3) -> bb1;
71 // END rustc.foo.CopyPropagation.after.mir
72 // START rustc.bar.CopyPropagation.before.mir
76 // _2 = const dummy(move _3) -> bb1;
84 // END rustc.bar.CopyPropagation.before.mir
85 // START rustc.bar.CopyPropagation.after.mir
89 // _2 = const dummy(move _3) -> bb1;
97 // END rustc.bar.CopyPropagation.after.mir
98 // START rustc.baz.CopyPropagation.before.mir
107 // END rustc.baz.CopyPropagation.before.mir
108 // START rustc.baz.CopyPropagation.after.mir
116 // END rustc.baz.CopyPropagation.after.mir
117 // START rustc.arg_src.CopyPropagation.before.mir
122 // _1 = const 123i32;
128 // END rustc.arg_src.CopyPropagation.before.mir
129 // START rustc.arg_src.CopyPropagation.after.mir
134 // _1 = const 123i32;
140 // END rustc.arg_src.CopyPropagation.after.mir