diff options
author | Devang Patel <dpatel@apple.com> | 2008-10-06 20:36:36 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-10-06 20:36:36 +0000 |
commit | 617fddf51c2aa6822281f0b52e700ffb1f15ed8d (patch) | |
tree | 3e75deb6b1b1914c18b790c5d00eeb8c678e010b | |
parent | a3668afdeeac587b760b8e5f5ae644949a375b0c (diff) | |
download | llvm-617fddf51c2aa6822281f0b52e700ffb1f15ed8d.tar.gz llvm-617fddf51c2aa6822281f0b52e700ffb1f15ed8d.tar.bz2 llvm-617fddf51c2aa6822281f0b52e700ffb1f15ed8d.tar.xz |
Remove interfaces implemented by dead pass from the list of available passes.
Patch By Matthijs Kooijman.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57202 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/PassManager.cpp | 24 | ||||
-rw-r--r-- | test/Other/2008-10-06-RemoveDeadPass.ll | 11 |
2 files changed, 28 insertions, 7 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 29a6df0d6a..e3d1c5364e 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -779,13 +779,23 @@ void PMDataManager::removeDeadPasses(Pass *P, const char *Msg, if (TheTimeInfo) TheTimeInfo->passStarted(*I); (*I)->releaseMemory(); if (TheTimeInfo) TheTimeInfo->passEnded(*I); - - std::map<AnalysisID, Pass*>::iterator Pos = - AvailableAnalysis.find((*I)->getPassInfo()); - - // It is possible that pass is already removed from the AvailableAnalysis - if (Pos != AvailableAnalysis.end()) - AvailableAnalysis.erase(Pos); + if (const PassInfo *PI = (*I)->getPassInfo()) { + std::map<AnalysisID, Pass*>::iterator Pos = + AvailableAnalysis.find(PI); + + // It is possible that pass is already removed from the AvailableAnalysis + if (Pos != AvailableAnalysis.end()) + AvailableAnalysis.erase(Pos); + + // Remove all interfaces this pass implements, for which it is also + // listed as the available implementation. + const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented(); + for (unsigned i = 0, e = II.size(); i != e; ++i) { + Pos = AvailableAnalysis.find(II[i]); + if (Pos != AvailableAnalysis.end() && Pos->second == *I) + AvailableAnalysis.erase(Pos); + } + } } } diff --git a/test/Other/2008-10-06-RemoveDeadPass.ll b/test/Other/2008-10-06-RemoveDeadPass.ll new file mode 100644 index 0000000000..a82d1b6f4b --- /dev/null +++ b/test/Other/2008-10-06-RemoveDeadPass.ll @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | opt -inline -internalize -disable-output +define void @foo() nounwind { + ret void +} + +define void @main(...) nounwind { + call void @foo() + ret void +} + + |