diff options
author | Teresa Johnson <tejohnson@google.com> | 2020-02-05 19:25:38 -0800 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2020-02-05 19:27:32 -0800 |
commit | 25aa2eef993e17708889abf56ed1ffad5074a9f4 (patch) | |
tree | ae8353624082428ec835ff124eafdc4488d40ccb /llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | |
parent | ccf900fc932098c1bbaa6e43a94b4423c60bf53e (diff) | |
download | llvm-25aa2eef993e17708889abf56ed1ffad5074a9f4.zip llvm-25aa2eef993e17708889abf56ed1ffad5074a9f4.tar.gz llvm-25aa2eef993e17708889abf56ed1ffad5074a9f4.tar.bz2 |
Revert "[WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP"
This reverts commit 748bb5a0f1964d20dfb3891b0948ab6c66236c70.
Due to Chromium CFI+ThinLTO test crashes reported on patch.
Diffstat (limited to 'llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp index 03e1fdd3..bbc1433a 100644 --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -510,9 +510,7 @@ struct DevirtModule { bool areRemarksEnabled(); - void - scanTypeTestUsers(Function *TypeTestFunc, - DenseMap<Metadata *, std::set<TypeMemberInfo>> &TypeIdMap); + void scanTypeTestUsers(Function *TypeTestFunc); void scanTypeCheckedLoadUsers(Function *TypeCheckedLoadFunc); void buildTypeIdentifierMap( @@ -1668,9 +1666,7 @@ bool DevirtModule::areRemarksEnabled() { return false; } -void DevirtModule::scanTypeTestUsers( - Function *TypeTestFunc, - DenseMap<Metadata *, std::set<TypeMemberInfo>> &TypeIdMap) { +void DevirtModule::scanTypeTestUsers(Function *TypeTestFunc) { // Find all virtual calls via a virtual table pointer %p under an assumption // of the form llvm.assume(llvm.type.test(%p, %md)). This indicates that %p // points to a member of the type identifier %md. Group calls by (type ID, @@ -1690,10 +1686,10 @@ void DevirtModule::scanTypeTestUsers( auto &DT = LookupDomTree(*CI->getFunction()); findDevirtualizableCallsForTypeTest(DevirtCalls, Assumes, CI, DT); - Metadata *TypeId = - cast<MetadataAsValue>(CI->getArgOperand(1))->getMetadata(); // If we found any, add them to CallSlots. if (!Assumes.empty()) { + Metadata *TypeId = + cast<MetadataAsValue>(CI->getArgOperand(1))->getMetadata(); Value *Ptr = CI->getArgOperand(0)->stripPointerCasts(); for (DevirtCallSite Call : DevirtCalls) { // Only add this CallSite if we haven't seen it before. The vtable @@ -1706,13 +1702,6 @@ void DevirtModule::scanTypeTestUsers( } } - // If we have any uses on type metadata, keep the type test assumes for - // later analysis. Otherwise remove as they aren't useful, and - // LowerTypeTests will think they are Unsat and lower to False, which - // breaks any uses on assumes. - if (TypeIdMap.count(TypeId)) - continue; - // We no longer need the assumes or the type test. for (auto Assume : Assumes) Assume->eraseFromParent(); @@ -1911,13 +1900,8 @@ bool DevirtModule::run() { (!TypeCheckedLoadFunc || TypeCheckedLoadFunc->use_empty())) return false; - // Rebuild type metadata into a map for easy lookup. - std::vector<VTableBits> Bits; - DenseMap<Metadata *, std::set<TypeMemberInfo>> TypeIdMap; - buildTypeIdentifierMap(Bits, TypeIdMap); - if (TypeTestFunc && AssumeFunc) - scanTypeTestUsers(TypeTestFunc, TypeIdMap); + scanTypeTestUsers(TypeTestFunc); if (TypeCheckedLoadFunc) scanTypeCheckedLoadUsers(TypeCheckedLoadFunc); @@ -1939,6 +1923,10 @@ bool DevirtModule::run() { return true; } + // Rebuild type metadata into a map for easy lookup. + std::vector<VTableBits> Bits; + DenseMap<Metadata *, std::set<TypeMemberInfo>> TypeIdMap; + buildTypeIdentifierMap(Bits, TypeIdMap); if (TypeIdMap.empty()) return true; @@ -1995,17 +1983,14 @@ bool DevirtModule::run() { // function implementation at offset S.first.ByteOffset, and add to // TargetsForSlot. std::vector<VirtualCallTarget> TargetsForSlot; - WholeProgramDevirtResolution *Res = nullptr; - if (ExportSummary && isa<MDString>(S.first.TypeID)) - // Create the type id summary resolution regardlness of whether we can - // devirtualize, so that lower type tests knows the type id is used on - // a global and not Unsat. - Res = &ExportSummary - ->getOrInsertTypeIdSummary( - cast<MDString>(S.first.TypeID)->getString()) - .WPDRes[S.first.ByteOffset]; if (tryFindVirtualCallTargets(TargetsForSlot, TypeIdMap[S.first.TypeID], S.first.ByteOffset)) { + WholeProgramDevirtResolution *Res = nullptr; + if (ExportSummary && isa<MDString>(S.first.TypeID)) + Res = &ExportSummary + ->getOrInsertTypeIdSummary( + cast<MDString>(S.first.TypeID)->getString()) + .WPDRes[S.first.ByteOffset]; if (!trySingleImplDevirt(ExportSummary, TargetsForSlot, S.second, Res)) { DidVirtualConstProp |= @@ -2119,14 +2104,11 @@ void DevirtIndex::run() { std::vector<ValueInfo> TargetsForSlot; auto TidSummary = ExportSummary.getTypeIdCompatibleVtableSummary(S.first.TypeID); assert(TidSummary); - // Create the type id summary resolution regardlness of whether we can - // devirtualize, so that lower type tests knows the type id is used on - // a global and not Unsat. - WholeProgramDevirtResolution *Res = - &ExportSummary.getOrInsertTypeIdSummary(S.first.TypeID) - .WPDRes[S.first.ByteOffset]; if (tryFindVirtualCallTargets(TargetsForSlot, *TidSummary, S.first.ByteOffset)) { + WholeProgramDevirtResolution *Res = + &ExportSummary.getOrInsertTypeIdSummary(S.first.TypeID) + .WPDRes[S.first.ByteOffset]; if (!trySingleImplDevirt(TargetsForSlot, S.first, S.second, Res, DevirtTargets)) |