diff options
author | Arthur Eubanks <aeubanks@google.com> | 2022-06-30 15:18:04 -0700 |
---|---|---|
committer | Arthur Eubanks <aeubanks@google.com> | 2022-07-26 08:01:08 -0700 |
commit | 2eade1dba4a8d6e1c6867e9127bcd88cf4e55976 (patch) | |
tree | 080ccfec588a3231d14022bc922f5c05e9a11adb /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | |
parent | e43621b09c9741d2e3a8a3d8ed216699af5ff8ba (diff) | |
download | llvm-2eade1dba4a8d6e1c6867e9127bcd88cf4e55976.zip llvm-2eade1dba4a8d6e1c6867e9127bcd88cf4e55976.tar.gz llvm-2eade1dba4a8d6e1c6867e9127bcd88cf4e55976.tar.bz2 |
[WPD] Use new llvm.public.type.test intrinsic for potentially publicly visible classes
Turning on opaque pointers has uncovered an issue with WPD where we currently pattern match away `assume(type.test)` in WPD so that a later LTT doesn't resolve the type test to undef and introduce an `assume(false)`. The pattern matching can fail in cases where we transform two `assume(type.test)`s into `assume(phi(type.test.1, type.test.2))`.
Currently we create `assume(type.test)` for all virtual calls that might be devirtualized. This is to support `-Wl,--lto-whole-program-visibility`.
To prevent this, all virtual calls that may not be in the same LTO module instead use a new `llvm.public.type.test` intrinsic in place of the `llvm.type.test`. Then when we know if `-Wl,--lto-whole-program-visibility` is passed or not, we can either replace all `llvm.public.type.test` with `llvm.type.test`, or replace all `llvm.public.type.test` with `true`. This prevents WPD from trying to pattern match away `assume(type.test)` for public virtual calls when failing the pattern matching will result in miscompiles.
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D128955
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index c52b27a..efe6058 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -164,7 +164,8 @@ static void addIntrinsicToSummary( SetVector<FunctionSummary::ConstVCall> &TypeCheckedLoadConstVCalls, DominatorTree &DT) { switch (CI->getCalledFunction()->getIntrinsicID()) { - case Intrinsic::type_test: { + case Intrinsic::type_test: + case Intrinsic::public_type_test: { auto *TypeMDVal = cast<MetadataAsValue>(CI->getArgOperand(1)); auto *TypeId = dyn_cast<MDString>(TypeMDVal->getMetadata()); if (!TypeId) |