From 64631f5d3bb5141f1c5c3b43a3e0d46e9fa5c33c Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Sat, 3 Dec 2016 19:49:23 +0000 Subject: [PATCH] [PM] Don't walk the AM's ResultsList if nothing was invalidated. Summary: Previously in AnalysisManager::invalidate(), we would walk the full ResultsList even if we knew that nothing was invalidated. Reviewers: chandlerc Subscribers: silvas, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D27371 llvm-svn: 288595 --- llvm/include/llvm/IR/PassManager.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index 92984861c7bb..b7e60471700c 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -619,24 +619,25 @@ public: } // Now erase the results that were marked above as invalidated. - for (auto I = ResultsList.begin(), E = ResultsList.end(); I != E;) { - AnalysisKey *ID = I->first; - if (!IsResultInvalidated.lookup(ID)) { - ++I; - continue; + if (!IsResultInvalidated.empty()) { + for (auto I = ResultsList.begin(), E = ResultsList.end(); I != E;) { + AnalysisKey *ID = I->first; + if (!IsResultInvalidated.lookup(ID)) { + ++I; + continue; + } + + if (DebugLogging) + dbgs() << "Invalidating analysis: " << this->lookUpPass(ID).name() + << "\n"; + + I = ResultsList.erase(I); + AnalysisResults.erase({ID, &IR}); } - - if (DebugLogging) - dbgs() << "Invalidating analysis: " << this->lookupPass(ID).name() - << "\n"; - - I = ResultsList.erase(I); - AnalysisResults.erase({ID, &IR}); } + if (ResultsList.empty()) AnalysisResultLists.erase(&IR); - - return; } private: