[WPD] Fix incorrect devirtualization after indirect call promotion
authorTeresa Johnson <tejohnson@google.com>
Thu, 27 Sep 2018 14:55:32 +0000 (14:55 +0000)
committerTeresa Johnson <tejohnson@google.com>
Thu, 27 Sep 2018 14:55:32 +0000 (14:55 +0000)
commitf24136f17ac15ea6b07a3fe4aa8e1b690a3cd950
tree3d8de3fe2d4d805361d0df35c799f3c77a5d2058
parenta9a5eee1694833989739fc31045b48bdaacafaff
[WPD] Fix incorrect devirtualization after indirect call promotion

Summary:
Add a dominance check to ensure that the possible devirtualizable
call is actually dominated by the type test/checked load intrinsic being
analyzed. With PGO, after indirect call promotion is performed during
the compile step, followed by inlining, we may have a type test in the
promoted and inlined sequence that allows an indirect call in that
sequence to be devirtualized. That indirect call (inserted by inlining
after promotion) will share the same vtable pointer as the fallback
indirect call that cannot be devirtualized.

Before this patch the code was incorrectly devirtualizing the fallback
indirect call.

See the new test and the example described there for more details.

Reviewers: pcc, vitalybuka

Subscribers: mehdi_amini, Prazek, eraman, steven_wu, dexonsmith, llvm-commits

Differential Revision: https://reviews.llvm.org/D52514

llvm-svn: 343226
llvm/include/llvm/Analysis/TypeMetadataUtils.h
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/lib/Analysis/TypeMetadataUtils.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/test/ThinLTO/X86/devirt-after-icp.ll [new file with mode: 0644]