[llvm] 58c3fba - Revert "LowerTypeTests: Fix quadratic complexity."
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 15 16:21:21 PDT 2025
Author: Peter Collingbourne
Date: 2025-04-15T16:20:45-07:00
New Revision: 58c3fba7063eaca926931a412c329e9ac4deefd6
URL: https://github.com/llvm/llvm-project/commit/58c3fba7063eaca926931a412c329e9ac4deefd6
DIFF: https://github.com/llvm/llvm-project/commit/58c3fba7063eaca926931a412c329e9ac4deefd6.diff
LOG: Revert "LowerTypeTests: Fix quadratic complexity."
This reverts commit e4d951d2e42a9124bd87275a864804c4b84b62e3.
Need to investigate some test failures.
Added:
Modified:
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 8e9f24dfc31fa..7cf7d74acfcfa 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1669,55 +1669,61 @@ void LowerTypeTestsModule::buildBitSetsFromFunctionsNative(
lowerTypeTestCalls(TypeIds, JumpTable, GlobalLayout);
- // Build aliases pointing to offsets into the jump table, and replace
- // references to the original functions with references to the aliases.
- for (unsigned I = 0; I != Functions.size(); ++I) {
- Function *F = cast<Function>(Functions[I]->getGlobal());
- bool IsJumpTableCanonical = Functions[I]->isJumpTableCanonical();
+ {
+ ScopedSaveAliaseesAndUsed S(M);
- Constant *CombinedGlobalElemPtr = ConstantExpr::getInBoundsGetElementPtr(
- JumpTableType, JumpTable,
- ArrayRef<Constant *>{ConstantInt::get(IntPtrTy, 0),
- ConstantInt::get(IntPtrTy, I)});
-
- const bool IsExported = Functions[I]->isExported();
- if (!IsJumpTableCanonical) {
- GlobalValue::LinkageTypes LT = IsExported ? GlobalValue::ExternalLinkage
- : GlobalValue::InternalLinkage;
- GlobalAlias *JtAlias = GlobalAlias::create(F->getValueType(), 0, LT,
- F->getName() + ".cfi_jt",
- CombinedGlobalElemPtr, &M);
- if (IsExported)
- JtAlias->setVisibility(GlobalValue::HiddenVisibility);
- else
- appendToUsed(M, {JtAlias});
- }
+ // Build aliases pointing to offsets into the jump table, and replace
+ // references to the original functions with references to the aliases.
+ for (unsigned I = 0; I != Functions.size(); ++I) {
+ Function *F = cast<Function>(Functions[I]->getGlobal());
+ bool IsJumpTableCanonical = Functions[I]->isJumpTableCanonical();
+
+ Constant *CombinedGlobalElemPtr = ConstantExpr::getInBoundsGetElementPtr(
+ JumpTableType, JumpTable,
+ ArrayRef<Constant *>{ConstantInt::get(IntPtrTy, 0),
+ ConstantInt::get(IntPtrTy, I)});
+
+ const bool IsExported = Functions[I]->isExported();
+ if (!IsJumpTableCanonical) {
+ GlobalValue::LinkageTypes LT = IsExported
+ ? GlobalValue::ExternalLinkage
+ : GlobalValue::InternalLinkage;
+ GlobalAlias *JtAlias = GlobalAlias::create(F->getValueType(), 0, LT,
+ F->getName() + ".cfi_jt",
+ CombinedGlobalElemPtr, &M);
+ if (IsExported)
+ JtAlias->setVisibility(GlobalValue::HiddenVisibility);
+ else
+ appendToUsed(M, {JtAlias});
+ }
- if (IsExported) {
- if (IsJumpTableCanonical)
- ExportSummary->cfiFunctionDefs().emplace(F->getName());
- else
- ExportSummary->cfiFunctionDecls().emplace(F->getName());
- }
+ if (IsExported) {
+ if (IsJumpTableCanonical)
+ ExportSummary->cfiFunctionDefs().emplace(F->getName());
+ else
+ ExportSummary->cfiFunctionDecls().emplace(F->getName());
+ }
- if (!IsJumpTableCanonical) {
- if (F->hasExternalWeakLinkage())
- replaceWeakDeclarationWithJumpTablePtr(F, CombinedGlobalElemPtr,
- IsJumpTableCanonical);
- else
- replaceCfiUses(F, CombinedGlobalElemPtr, IsJumpTableCanonical);
- } else {
- assert(F->getType()->getAddressSpace() == 0);
-
- GlobalAlias *FAlias = GlobalAlias::create(
- F->getValueType(), 0, F->getLinkage(), "", CombinedGlobalElemPtr, &M);
- FAlias->setVisibility(F->getVisibility());
- FAlias->takeName(F);
- if (FAlias->hasName())
- F->setName(FAlias->getName() + ".cfi");
- replaceCfiUses(F, FAlias, IsJumpTableCanonical);
- if (!F->hasLocalLinkage())
- F->setVisibility(GlobalVariable::HiddenVisibility);
+ if (!IsJumpTableCanonical) {
+ if (F->hasExternalWeakLinkage())
+ replaceWeakDeclarationWithJumpTablePtr(F, CombinedGlobalElemPtr,
+ IsJumpTableCanonical);
+ else
+ replaceCfiUses(F, CombinedGlobalElemPtr, IsJumpTableCanonical);
+ } else {
+ assert(F->getType()->getAddressSpace() == 0);
+
+ GlobalAlias *FAlias =
+ GlobalAlias::create(F->getValueType(), 0, F->getLinkage(), "",
+ CombinedGlobalElemPtr, &M);
+ FAlias->setVisibility(F->getVisibility());
+ FAlias->takeName(F);
+ if (FAlias->hasName())
+ F->setName(FAlias->getName() + ".cfi");
+ replaceCfiUses(F, FAlias, IsJumpTableCanonical);
+ if (!F->hasLocalLinkage())
+ F->setVisibility(GlobalVariable::HiddenVisibility);
+ }
}
}
@@ -2333,43 +2339,39 @@ bool LowerTypeTestsModule::lower() {
if (GlobalClasses.empty())
return false;
- {
- ScopedSaveAliaseesAndUsed S(M);
- // For each disjoint set we found...
- for (const auto &C : GlobalClasses) {
- if (!C->isLeader())
- continue;
-
- ++NumTypeIdDisjointSets;
- // Build the list of type identifiers in this disjoint set.
- std::vector<Metadata *> TypeIds;
- std::vector<GlobalTypeMember *> Globals;
- std::vector<ICallBranchFunnel *> ICallBranchFunnels;
- for (auto M : GlobalClasses.members(*C)) {
- if (isa<Metadata *>(M))
- TypeIds.push_back(cast<Metadata *>(M));
- else if (isa<GlobalTypeMember *>(M))
- Globals.push_back(cast<GlobalTypeMember *>(M));
- else
- ICallBranchFunnels.push_back(cast<ICallBranchFunnel *>(M));
- }
+ // For each disjoint set we found...
+ for (const auto &C : GlobalClasses) {
+ if (!C->isLeader())
+ continue;
- // Order type identifiers by unique ID for determinism. This ordering is
- // stable as there is a one-to-one mapping between metadata and unique
- // IDs.
- llvm::sort(TypeIds, [&](Metadata *M1, Metadata *M2) {
- return TypeIdInfo[M1].UniqueId < TypeIdInfo[M2].UniqueId;
- });
-
- // Same for the branch funnels.
- llvm::sort(ICallBranchFunnels,
- [&](ICallBranchFunnel *F1, ICallBranchFunnel *F2) {
- return F1->UniqueId < F2->UniqueId;
- });
-
- // Build bitsets for this disjoint set.
- buildBitSetsFromDisjointSet(TypeIds, Globals, ICallBranchFunnels);
+ ++NumTypeIdDisjointSets;
+ // Build the list of type identifiers in this disjoint set.
+ std::vector<Metadata *> TypeIds;
+ std::vector<GlobalTypeMember *> Globals;
+ std::vector<ICallBranchFunnel *> ICallBranchFunnels;
+ for (auto M : GlobalClasses.members(*C)) {
+ if (isa<Metadata *>(M))
+ TypeIds.push_back(cast<Metadata *>(M));
+ else if (isa<GlobalTypeMember *>(M))
+ Globals.push_back(cast<GlobalTypeMember *>(M));
+ else
+ ICallBranchFunnels.push_back(cast<ICallBranchFunnel *>(M));
}
+
+ // Order type identifiers by unique ID for determinism. This ordering is
+ // stable as there is a one-to-one mapping between metadata and unique IDs.
+ llvm::sort(TypeIds, [&](Metadata *M1, Metadata *M2) {
+ return TypeIdInfo[M1].UniqueId < TypeIdInfo[M2].UniqueId;
+ });
+
+ // Same for the branch funnels.
+ llvm::sort(ICallBranchFunnels,
+ [&](ICallBranchFunnel *F1, ICallBranchFunnel *F2) {
+ return F1->UniqueId < F2->UniqueId;
+ });
+
+ // Build bitsets for this disjoint set.
+ buildBitSetsFromDisjointSet(TypeIds, Globals, ICallBranchFunnels);
}
allocateByteArrays();
More information about the llvm-commits
mailing list