aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/LegacyPassManager.cpp
diff options
context:
space:
mode:
authorAlexis Engelke <engelke@in.tum.de>2024-08-02 16:14:15 +0200
committerGitHub <noreply@github.com>2024-08-02 16:14:15 +0200
commit293df8afae3ec1f99e44d6bc015e4edf2c165c8d (patch)
treea8c807af1bf2ecea29e5c93355517c02a6c3f4ed /llvm/lib/IR/LegacyPassManager.cpp
parent07aaab8345f1728815575639821ce581590d8479 (diff)
downloadllvm-293df8afae3ec1f99e44d6bc015e4edf2c165c8d.zip
llvm-293df8afae3ec1f99e44d6bc015e4edf2c165c8d.tar.gz
llvm-293df8afae3ec1f99e44d6bc015e4edf2c165c8d.tar.bz2
[LegacyPM] Drop analysis groups (#101670)
This improves the performance of recordAvailableAnalysis and freePass so that they don't need to call getPassInfo(), which acquires a lock on every call. The performance-wise interesting part is only in LegacyPassManager.cpp, everything else is just cleanup.
Diffstat (limited to 'llvm/lib/IR/LegacyPassManager.cpp')
-rw-r--r--llvm/lib/IR/LegacyPassManager.cpp42
1 files changed, 5 insertions, 37 deletions
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index 9c44eff7..f2a83b5 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -808,13 +808,6 @@ void PMTopLevelManager::addImmutablePass(ImmutablePass *P) {
// doing lookups.
AnalysisID AID = P->getPassID();
ImmutablePassMap[AID] = P;
-
- // Also add any interfaces implemented by the immutable pass to the map for
- // fast lookup.
- const PassInfo *PassInf = findAnalysisPassInfo(AID);
- assert(PassInf && "Expected all immutable passes to be initialized");
- for (const PassInfo *ImmPI : PassInf->getInterfacesImplemented())
- ImmutablePassMap[ImmPI->getTypeInfo()] = P;
}
// Print passes managed by this top level manager.
@@ -844,8 +837,7 @@ void PMTopLevelManager::dumpArguments() const {
for (ImmutablePass *P : ImmutablePasses)
if (const PassInfo *PI = findAnalysisPassInfo(P->getPassID())) {
assert(PI && "Expected all immutable passes to be initialized");
- if (!PI->isAnalysisGroup())
- dbgs() << " -" << PI->getPassArgument();
+ dbgs() << " -" << PI->getPassArgument();
}
for (PMDataManager *PM : PassManagers)
PM->dumpPassArguments();
@@ -878,15 +870,6 @@ void PMDataManager::recordAvailableAnalysis(Pass *P) {
AnalysisID PI = P->getPassID();
AvailableAnalysis[PI] = P;
-
- assert(!AvailableAnalysis.empty());
-
- // This pass is the current implementation of all of the interfaces it
- // implements as well.
- const PassInfo *PInf = TPM->findAnalysisPassInfo(PI);
- if (!PInf) return;
- for (const PassInfo *PI : PInf->getInterfacesImplemented())
- AvailableAnalysis[PI->getTypeInfo()] = P;
}
// Return true if P preserves high level analysis used by other
@@ -1004,20 +987,8 @@ void PMDataManager::freePass(Pass *P, StringRef Msg,
P->releaseMemory();
}
- AnalysisID PI = P->getPassID();
- if (const PassInfo *PInf = TPM->findAnalysisPassInfo(PI)) {
- // Remove the pass itself (if it is not already removed).
- AvailableAnalysis.erase(PI);
-
- // Remove all interfaces this pass implements, for which it is also
- // listed as the available implementation.
- for (const PassInfo *PI : PInf->getInterfacesImplemented()) {
- DenseMap<AnalysisID, Pass *>::iterator Pos =
- AvailableAnalysis.find(PI->getTypeInfo());
- if (Pos != AvailableAnalysis.end() && Pos->second == P)
- AvailableAnalysis.erase(Pos);
- }
- }
+ // Remove the pass itself (if it is not already removed).
+ AvailableAnalysis.erase(P->getPassID());
}
/// Add pass P into the PassVector. Update
@@ -1173,11 +1144,8 @@ void PMDataManager::dumpPassArguments() const {
for (Pass *P : PassVector) {
if (PMDataManager *PMD = P->getAsPMDataManager())
PMD->dumpPassArguments();
- else
- if (const PassInfo *PI =
- TPM->findAnalysisPassInfo(P->getPassID()))
- if (!PI->isAnalysisGroup())
- dbgs() << " -" << PI->getPassArgument();
+ else if (const PassInfo *PI = TPM->findAnalysisPassInfo(P->getPassID()))
+ dbgs() << " -" << PI->getPassArgument();
}
}