[PATCH] D97126: [WPD] Fix handling of pure virtual base class

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 20 14:20:09 PST 2021


tejohnson created this revision.
tejohnson added a reviewer: MaskRay.
Herald added subscribers: steven_wu, hiraditya, Prazek.
tejohnson requested review of this revision.
Herald added a project: LLVM.

The fix in 3c4c205060c9398da705eb71b63ddd8a04999de9 <https://reviews.llvm.org/rG3c4c205060c9398da705eb71b63ddd8a04999de9> caused an assert in
the case of a pure virtual base class. In that case, the vTableFuncs
list on the summary will be empty, so we were hitting the new assert
that the linkage type was not available_externally.

In the case of pure virtual, we do not want to assert, and additionally
need to set VS so that we don't treat it conservatively and quit the
analysis of the type id early.

This exposed a pre-existing issue where we were not updating the vcall
visibility on pure virtual functions when whole program visibility was
specified. We were skipping updating the visibility on any global vars
that didn't have any vTableFuncs, which meant all pure virtual were not
updated, and the later analysis would block any devirtualization of
calls that had a type id used on those pure virtual vtables (see the
handling in the other code modified in this patch). Simply remove that
check. It will mean that we may update the vcall visibility on global
vars that aren't vtables, but that setting is ignored for any global
vars that didn't have type metadata anyway.

Added a new test case that asserted without removing the assert, and
that requires the other fixes in this patch to get a successful
devirtualization with index-only WPD. I added cases to test hybrid and
regular LTO for completeness, although those already worked without the
fixes here.

With this final fix, a clang multistage bootstrap with WPD builds and
runs all tests successfully.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97126

Files:
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/ThinLTO/X86/devirt_pure_virtual_base.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97126.325244.patch
Type: text/x-patch
Size: 7611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210220/3c48df14/attachment.bin>


More information about the llvm-commits mailing list