about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/back/write.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-07 03:13:21 +0000
committerbors <bors@rust-lang.org>2021-01-07 03:13:21 +0000
commitdfdfaa1f0442dac516ba87d274d832c00464b3c2 (patch)
tree8ecdbe8bcb15082946680c8d6083ba395f38889c /compiler/rustc_codegen_llvm/src/back/write.rs
parent5b3d52414e0d7786b8c79479938b2543521719be (diff)
parentbe1511408edbae0deb9b6aceed7cf22aa5ca8e76 (diff)
downloadrust-dfdfaa1f0442dac516ba87d274d832c00464b3c2.tar.gz
rust-dfdfaa1f0442dac516ba87d274d832c00464b3c2.zip
Auto merge of #80200 - mahkoh:dst-offset, r=nagisa
Optimize DST field access

For

    struct X<T: ?Sized>(T)
    struct Y<T: ?Sized>(u8, T)

the offset of the unsized field is

    0
    mem::align_of_val(&self.1)

respectively. This patch changes the expression used to compute these
offsets so that the optimizer can perform this optimization.

Consider

```rust
fn f(x: &X<dyn Any>) -> &dyn Any {
    &x.0
}
```

Before:

```asm
test:
	movq	%rsi, %rdx
	movq	16(%rsi), %rax
	leaq	-1(%rax), %rcx
	negq	%rax
	andq	%rcx, %rax
	addq	%rdi, %rax
	retq
```

After:

```asm
test:
	movq	%rsi, %rdx
	movq	%rdi, %rax
	retq
```
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/back/write.rs')
0 files changed, 0 insertions, 0 deletions