about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-11-12 15:38:13 +0000
committerbors <bors@rust-lang.org>2017-11-12 15:38:13 +0000
commit3d2dc6e9402824f5fecba4f076d0bf2bcd01cbeb (patch)
treead24d3754466c77d700bb34e5a809400e702b2b8 /src/rustllvm/RustWrapper.cpp
parent4b6f7252a135a3fd1dba6f5e002b9d3d3af034b9 (diff)
parent114252410d72b63bda4eefa62df77727d1f1cc41 (diff)
downloadrust-3d2dc6e9402824f5fecba4f076d0bf2bcd01cbeb.tar.gz
rust-3d2dc6e9402824f5fecba4f076d0bf2bcd01cbeb.zip
Auto merge of #45753 - sinkuu:mir_copyprop_arg, r=arielb1
Fix MIR CopyPropagation errneously propagating assignments to function args

Compiling this code with MIR CopyPropagation activated will result in printing `5`,
because CopyProp errneously propagates the assignment of `5` to all `x`:

```rust
fn bar(mut x: u8) {
    println!("{}", x);
    x = 5;
}

fn main() {
    bar(123);
}

```

If a local is propagated, it will result in an ICE at trans due to an use-before-def:

```rust
fn dummy(x: u8) -> u8 { x }

fn foo(mut x: u8) {
    x = dummy(x); // this will assign a local to `x`
}
```
Currently CopyProp conservatively gives up if there are multiple assignments to a local,
but it is not took into account that arguments are already assigned from the beginning.
This PR fixes the problem by preventing propagation of assignments to function arguments.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions