about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-27 02:35:11 +0000
committerbors <bors@rust-lang.org>2020-09-27 02:35:11 +0000
commit62fe055aba3ddac5e5d113920cf5fd80522104e2 (patch)
tree4545619f936a4860e19494c8f68720e366b44e90 /compiler/rustc_codegen_llvm/src
parent1ec980d225fff2346a1a631a7ffc88b37e9e18af (diff)
parentcc2ba3bd2753ec94adc93ec4aa9d8d093129cd2d (diff)
downloadrust-62fe055aba3ddac5e5d113920cf5fd80522104e2.tar.gz
rust-62fe055aba3ddac5e5d113920cf5fd80522104e2.zip
Auto merge of #76986 - jonas-schievink:ret-in-reg, r=nagisa
Return values up to 128 bits in registers

This fixes https://github.com/rust-lang/rust/issues/26494#issuecomment-619506345 by making Rust's default ABI pass return values up to 128 bits in size in registers, just like the System V ABI.

The result is that these methods from the comment linked above now generate the same code, making the Rust ABI as efficient as the `"C"` ABI:

```rust
pub struct Stats { x: u32, y: u32, z: u32, }

pub extern "C" fn sum_c(a: &Stats, b: &Stats) -> Stats {
    return Stats {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
}

pub fn sum_rust(a: &Stats, b: &Stats) -> Stats {
    return Stats {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
}
```

```asm
sum_rust:
	movl	(%rsi), %eax
	addl	(%rdi), %eax
	movl	4(%rsi), %ecx
	addl	4(%rdi), %ecx
	movl	8(%rsi), %edx
	addl	8(%rdi), %edx
	shlq	$32, %rcx
	orq	%rcx, %rax
	retq
```
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions