]> granicus.if.org Git - llvm/commitdiff
[PM] Don't walk the AM's ResultsList if nothing was invalidated.
authorJustin Lebar <jlebar@google.com>
Sat, 3 Dec 2016 19:49:23 +0000 (19:49 +0000)
committerJustin Lebar <jlebar@google.com>
Sat, 3 Dec 2016 19:49:23 +0000 (19:49 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288595 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/PassManager.h

index 92984861c7bb4fd0f1a58cd43a4c319aa6bab1a4..b7e60471700c12ed6ebbbed0a3c2166644754ce3 100644 (file)
@@ -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: