diff options
| author | bors <bors@rust-lang.org> | 2020-12-02 15:17:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-12-02 15:17:32 +0000 |
| commit | a094ff9590b83c8f94d898f92c2964a5803ded06 (patch) | |
| tree | 9012a5007c09a4a7c1412ad69c5e008db08f3758 /compiler/rustc_middle/src | |
| parent | d37afad0cc87bf709ad10c85319296ac53030f03 (diff) | |
| parent | 53943d6debc78efafa037744774d3216d22a10ad (diff) | |
| download | rust-a094ff9590b83c8f94d898f92c2964a5803ded06.tar.gz rust-a094ff9590b83c8f94d898f92c2964a5803ded06.zip | |
Auto merge of #79547 - erikdesjardins:byval, r=nagisa
Pass arguments up to 2*usize by value In https://github.com/rust-lang/rust/pull/77434#discussion_r498719533, `@eddyb` said: > I wonder if it makes sense to limit this to returns [...] Let's do a perf run and find out. It seems the `extern "C"` ABI will pass arguments up to 2*usize in registers: https://godbolt.org/z/n8E6zc. (modified from https://github.com/rust-lang/rust/issues/26494#issuecomment-619506345) r? `@nagisa`
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 00fea91fdfc..d6b3afb3be3 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -2848,7 +2848,7 @@ where || abi == SpecAbi::RustIntrinsic || abi == SpecAbi::PlatformIntrinsic { - let fixup = |arg: &mut ArgAbi<'tcx, Ty<'tcx>>, is_ret: bool| { + let fixup = |arg: &mut ArgAbi<'tcx, Ty<'tcx>>| { if arg.is_ignore() { return; } @@ -2886,9 +2886,9 @@ where _ => return, } - // Return structures up to 2 pointers in size by value, matching `ScalarPair`. LLVM - // will usually return these in 2 registers, which is more efficient than by-ref. - let max_by_val_size = if is_ret { Pointer.size(cx) * 2 } else { Pointer.size(cx) }; + // Pass and return structures up to 2 pointers in size by value, matching `ScalarPair`. + // LLVM will usually pass these in 2 registers, which is more efficient than by-ref. + let max_by_val_size = Pointer.size(cx) * 2; let size = arg.layout.size; if arg.layout.is_unsized() || size > max_by_val_size { @@ -2900,9 +2900,9 @@ where arg.cast_to(Reg { kind: RegKind::Integer, size }); } }; - fixup(&mut self.ret, true); + fixup(&mut self.ret); for arg in &mut self.args { - fixup(arg, false); + fixup(arg); } return; } |
