Elide unnecessary ret slot allocas
When there is only a single store to the ret slot that dominates the load that gets the value for the "ret" instruction, we can elide the ret slot and directly return the operand of the dominating store instruction. This is the same thing that clang does, except for a special case that doesn't seem to affect us. Fixes #8238
This commit is contained in:
parent
e81e81f234
commit
4b74b8dca4
7 changed files with 255 additions and 4 deletions
14
src/test/codegen/single-return-value.cc
Normal file
14
src/test/codegen/single-return-value.cc
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
extern "C"
|
||||
int test() {
|
||||
return 5;
|
||||
}
|
||||
14
src/test/codegen/single-return-value.rs
Normal file
14
src/test/codegen/single-return-value.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[no_mangle]
|
||||
fn test() -> int {
|
||||
5
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue