mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
dfdfaa1f04
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 ``` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |
Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.