[llvm-branch-commits] [llvm] 68ed644 - [LegacyPM] Avoid a redundant map lookup in setLastUser. NFC.

Jay Foad via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Nov 27 02:50:28 PST 2020


Author: Jay Foad
Date: 2020-11-27T10:42:01Z
New Revision: 68ed6447855632b954b55f63807481eaa44705df

URL: https://github.com/llvm/llvm-project/commit/68ed6447855632b954b55f63807481eaa44705df
DIFF: https://github.com/llvm/llvm-project/commit/68ed6447855632b954b55f63807481eaa44705df.diff

LOG: [LegacyPM] Avoid a redundant map lookup in setLastUser. NFC.

As a bonus this makes it (IMO) obvious that the iterator is not
invalidated, so remove the comment explaining that.

Added: 
    

Modified: 
    llvm/lib/IR/LegacyPassManager.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index bb2661d36b56..8fd35ef975e2 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -675,11 +675,9 @@ PMTopLevelManager::setLastUser(ArrayRef<Pass*> AnalysisPasses, Pass *P) {
 
     // If AP is the last user of other passes then make P last user of
     // such passes.
-    for (auto LU : LastUser) {
+    for (auto &LU : LastUser) {
       if (LU.second == AP)
-        // DenseMap iterator is not invalidated here because
-        // this is just updating existing entries.
-        LastUser[LU.first] = P;
+        LU.second = P;
     }
   }
 }


        


More information about the llvm-branch-commits mailing list