[llvm] 497506f - [Analysis] Avoid repeated hash lookups (NFC) (#126678)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 09:08:23 PST 2025


Author: Kazu Hirata
Date: 2025-02-11T09:08:15-08:00
New Revision: 497506f6f454272e7c4921b3143768c6927738e4

URL: https://github.com/llvm/llvm-project/commit/497506f6f454272e7c4921b3143768c6927738e4
DIFF: https://github.com/llvm/llvm-project/commit/497506f6f454272e7c4921b3143768c6927738e4.diff

LOG: [Analysis] Avoid repeated hash lookups (NFC) (#126678)

Added: 
    

Modified: 
    llvm/lib/Analysis/DDG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/DDG.cpp b/llvm/lib/Analysis/DDG.cpp
index a0774096c5129..0907a7fb021fc 100644
--- a/llvm/lib/Analysis/DDG.cpp
+++ b/llvm/lib/Analysis/DDG.cpp
@@ -241,9 +241,10 @@ bool DataDependenceGraph::addNode(DDGNode &N) {
 }
 
 const PiBlockDDGNode *DataDependenceGraph::getPiBlock(const NodeType &N) const {
-  if (!PiBlockMap.contains(&N))
+  auto It = PiBlockMap.find(&N);
+  if (It == PiBlockMap.end())
     return nullptr;
-  auto *Pi = PiBlockMap.find(&N)->second;
+  auto *Pi = It->second;
   assert(!PiBlockMap.contains(Pi) && "Nested pi-blocks detected.");
   return Pi;
 }


        


More information about the llvm-commits mailing list