diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index a5a98f53131..3a28f913303 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -161,6 +161,10 @@ public: /// virtual void releaseMemory() {} + /// verifyAnalysis() - This member can be implemented by a analysis pass to + /// check state of analysis information. + virtual void verifyAnalysis() {} + // dumpPassStructure - Implement the -debug-passes=PassStructure option virtual void dumpPassStructure(unsigned Offset = 0); diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index af3cfb025dc..8d780e98d02 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -598,11 +598,18 @@ bool PMDataManager::preserveHigherLevelAnalysis(Pass *P) { void PMDataManager::removeNotPreservedAnalysis(Pass *P) { AnalysisUsage AnUsage; P->getAnalysisUsage(AnUsage); + const std::vector &PreservedSet = AnUsage.getPreservedSet(); + // Verify preserved analysis + for (std::map::iterator I = AvailableAnalysis.begin(), + E = AvailableAnalysis.end(); I != E; ++I) { + Pass *AP = I->second; + AP->verifyAnalysis(); + } + if (AnUsage.getPreservesAll()) return; - const std::vector &PreservedSet = AnUsage.getPreservedSet(); for (std::map::iterator I = AvailableAnalysis.begin(), E = AvailableAnalysis.end(); I != E; ) { std::map::iterator Info = I++;