Index: lib/IR/LegacyPassManager.cpp =================================================================== --- lib/IR/LegacyPassManager.cpp +++ lib/IR/LegacyPassManager.cpp @@ -854,17 +854,30 @@ #ifdef NDEBUG return; #endif + + const PassInfo *PI = TPM->findAnalysisPassInfo(P->getPassID()); + if (!PI || PI->isAnalysis()) { + return; + } + AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P); const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet(); // Verify preserved analysis - for (AnalysisUsage::VectorType::const_iterator I = PreservedSet.begin(), - E = PreservedSet.end(); I != E; ++I) { - AnalysisID AID = *I; - if (Pass *AP = findAnalysisPass(AID, true)) { - TimeRegion PassTimer(getPassTimer(AP)); - AP->verifyAnalysis(); + for (auto I = AvailableAnalysis.begin(), E = AvailableAnalysis.end(); + I != E; ++I) { + AnalysisID AID = I->first; + + if (!AnUsage->getPreservesAll()) { + if (std::find(PreservedSet.begin(), PreservedSet.end(), AID) == + PreservedSet.end()) { + continue; + } } + + Pass *AP = I->second; + TimeRegion PassTimer(getPassTimer(AP)); + AP->verifyAnalysis(); } }