[PATCH] D63932: [GlobalDCE] Dead Virtual Function Elimination

Oliver Stannard (Linaro) via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 1 07:08:18 PDT 2019


ostannard added a comment.

> Partial linking will indeed prevent dropping the virtual functions, but it should not prevent clearing the pointer to the virtual function in the vtable. The linker should then be able to drop the virtual function body as part of `--gc-sections` during the final link.

If partial linking isn't doing internalisation, I'd expect that to prevent a lot of other LTO optimisations, not just VFE. Is this a common use-case which we need to care about?

> I think I would favour something closer to your first suggestion, but instead of telling GlobalDCE specifically about this, we represent the "post-link" flag in the IR (e.g. as a module flag) in order to keep the IR self-contained. LTO would then be taught to add this flag at the right time, and the logic inside GlobalDCE would be:
> 
> - If post-link flag not set, allow VFE if linkage <= TranslationUnit.
> - If post-link flag set, allow VFE if linkage <= LinkageUnit.
> 
>   This would also help address a correctness issue with the CFI and WPD passes, which is that it is currently unsound to run them at compile time. If we let them run at compile time, we would in principle be able to do CFI and WPD on internal linkage types without LTO.

Ok, sounds reasonable, though I suspect WPD and CFI will need a slightly different definition of type visibility - they care about the possibility of unseen code adding new derived classes, so the visibility of base classes isn't important, and they might be able to make use of the final specifier.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63932/new/

https://reviews.llvm.org/D63932





More information about the cfe-commits mailing list