I wrote up an update on the virtual function elimination feature
github.com/rust-lang/rust/issu…
When using `&dyn Trait`, this feature removes virtual functions that never get called, and may turn virtual calls back into direct calls if there is only one possible option. The idea is that you get the upsides of `dyn Trait` with less of the downsides.
But, rustc currently gives incomplete information to LLVM, causing it to miscompile. The LLVM implementation is also clearly meant for C++, and doesn't handle what rust gives it well in all cases.
So, let's fix that!
Support whole program devirtualization · Issue #68262 · rust-lang/rust
When doing LTO, LLVM supports a devirtualization pass that converts some indirect calls to static, inlineable calls. This can unlock a lot of optimizations when dynamic dispatch is used frequently ...tmandry (GitHub)