diff options
| author | Julian Orth <ju.orth@gmail.com> | 2020-12-19 19:08:03 +0100 |
|---|---|---|
| committer | Julian Orth <ju.orth@gmail.com> | 2020-12-19 20:43:15 +0100 |
| commit | be1511408edbae0deb9b6aceed7cf22aa5ca8e76 (patch) | |
| tree | 9d7cacbcc0f85ec877e3a115db46766bc49d27ba /compiler/rustc_codegen_llvm/src/back/write.rs | |
| parent | 8bb302d34dde36cc78a288cb5beb4af7fe30ba41 (diff) | |
| download | rust-be1511408edbae0deb9b6aceed7cf22aa5ca8e76.tar.gz rust-be1511408edbae0deb9b6aceed7cf22aa5ca8e76.zip | |
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 test(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
