1
Fork 0
rust/compiler/rustc_codegen_ssa/src/mir
bors 2d1e075079 Auto merge of #96285 - flip1995:pk-vfe, r=nagisa
Introduce `-Zvirtual-function-elimination` codegen flag

Fixes #68262

This PR adds a codegen flag `-Zvirtual-function-elimination` to enable the VFE optimization in LLVM. To make this work, additonal  information has to be added to vtables ([`!vcall_visibility` metadata](https://llvm.org/docs/TypeMetadata.html#vcall-visibility-metadata) and a `typeid` of the trait). Furthermore, instead of just `load`ing functions, the [`llvm.type.checked.load` intrinsic](https://llvm.org/docs/LangRef.html#llvm-type-checked-load-intrinsic) has to be used to map functions to vtables.

For technical details of the changes, see the commit messages.

I also tested this flag on https://github.com/tock/tock on different boards to verify that this fixes the issue https://github.com/tock/tock/issues/2594. This flag is able to improve the size of the resulting binary by about 8k-9k bytes by removing the unused debug print functions.

[Rendered documentation update](https://github.com/flip1995/rust/blob/pk-vfe/src/doc/rustc/src/codegen-options/index.md#virtual-function-elimination)
2022-06-14 21:37:11 +00:00
..
analyze.rs Change Successors to impl Iterator<Item = BasicBlock> 2022-05-17 08:41:01 +08:00
block.rs Add llvm.type.checked.load intrinsic 2022-06-14 14:50:52 +02:00
constant.rs implement valtrees as the type-system representation for constant values 2022-06-14 16:07:11 +02:00
coverageinfo.rs coverageinfo query needs to use the same MIR as codegen 2021-05-12 20:27:07 -07:00
debuginfo.rs not need Option for dbg_scope 2022-04-26 21:00:19 +08:00
intrinsic.rs rustc_codegen_ssa: cleanup AtomicOrdering 2022-05-25 10:34:35 +02:00
mod.rs Eliminate duplication of RPO calculation for mir 2022-04-30 03:42:57 +08:00
operand.rs Mark scalar layout unions so that backends that do not support partially initialized scalars can special case them. 2022-04-05 13:18:21 +00:00
place.rs clippy::complexity fixes 2022-05-26 13:14:24 +02:00
rvalue.rs comment 2022-06-02 11:12:12 -04:00
statement.rs Add new Deinit statement kind 2022-04-11 08:55:03 -04:00