[llvm-dev] RFC: Safe Whole Program Devirtualization Enablement
Iurii Gribov via llvm-dev
llvm-dev at lists.llvm.org
Tue Dec 17 07:36:26 PST 2019
(cc list this time)
Apologies if this has been discussed before but ...
> The LTO visibility of a class is derived at compile time from the class’s symbol visibility.
> Generally, only classes that are internal at the source level (e.g. declared in an anonymous namespace) receive hidden LTO visibility.
> Compiling with -fvisibility=hidden tells the compiler that, unless
> otherwise marked, symbols are assumed to have hidden visibility, which
> also implies that all classes have hidden LTO visibility (unless decorated with a public visibility attribute).
> This results in much more aggressive devirtualization.
Note that by default, unlike GCC, LLVM is liberal on visibility-constrained optimizations. In particular it freely performs inlining, IPA and cloning on them (see https://lists.llvm.org/pipermail/llvm-dev/2016-November/107625.html which also suggested adding -fsemantic-interposition to actually respect visibility in optimizations). It's unclear why devirtualization should behave differently than other optimizations (at least by default).
More information about the llvm-dev