rust/compiler/rustc_codegen_ssa
bors dfdfaa1f04 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
```
2021-01-07 03:13:21 +00:00
..
src Auto merge of #80200 - mahkoh:dst-offset, r=nagisa 2021-01-07 03:13:21 +00:00
Cargo.toml
README.md

Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.