rust/compiler/rustc_codegen_ssa/src/mir
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
..
analyze.rs use PlaceRef more consistently instead of loosely coupled local+projection 2021-01-03 14:14:55 +01:00
block.rs where possible, pass slices instead of &Vec or &String (clippy::ptr_arg) 2020-12-30 13:11:52 +01:00
constant.rs [mir-opt] Allow debuginfo to be generated for a constant or a Place 2020-12-06 20:48:25 -05:00
coverageinfo.rs Addressed all feedback to date 2020-11-05 18:24:17 -08:00
debuginfo.rs Rename kw::Invalid -> kw::Empty 2020-12-30 09:50:02 -05:00
intrinsic.rs Use pointer type in AtomicPtr::swap implementation 2020-12-20 00:00:00 +00:00
mod.rs [mir-opt] Allow debuginfo to be generated for a constant or a Place 2020-12-06 20:48:25 -05:00
operand.rs compiler: fold by value 2020-11-16 22:34:57 +01:00
place.rs Auto merge of #80200 - mahkoh:dst-offset, r=nagisa 2021-01-07 03:13:21 +00:00
rvalue.rs Lower discriminant_value intrinsic 2020-12-11 03:25:40 +01:00
statement.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00