[PATCH] D91583: [LTO] Prevent devirtualization for symbols dynamically exported

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 15:56:36 PST 2021


MaskRay added a comment.

In D91583#2612525 <https://reviews.llvm.org/D91583#2612525>, @lanza wrote:

>> I see - so just to confirm, when compiling it isn't clear that these symbols are have internal or hidden visibility, but only during linking? Because otherwise clang should already have applied an appropriate vcall_visibility that allows WPD.
>
> Correct, when compiling we don't know what's exported and what's not, so nothing is applied. This is fundamentally similar to a problem you mentioned at a talk last year -- a source file shared between multiple apps might not be used the same everywhere, so you can only know after actually linking how it's used. So we apply stricter visibility via checking what was actually imported from the library. If `_ZTV5Thing` isn't used outside the current library we can mark it as such and then WPD operate with this extra info.

Do you use `local:` version node in a version script to make vtable symbols local in a `-shared` link? LTO does not know the effective binding has become local in that case and can lose devirtualization opportunities.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91583



More information about the llvm-commits mailing list