[llvm] a2f659c - [StructurizeCFG] Avoid repeated hash lookups (NFC) (#107797)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 07:15:16 PDT 2024


Author: Kazu Hirata
Date: 2024-09-09T07:15:12-07:00
New Revision: a2f659c1349cb70c09b183eb214e2a24cf04c2c6

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

LOG: [StructurizeCFG] Avoid repeated hash lookups (NFC) (#107797)

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/StructurizeCFG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
index a6ed58ac9d47f2..aca8225cebb3fd 100644
--- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
+++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
@@ -697,10 +697,9 @@ void StructurizeCFG::findUndefBlocks(
   // undefined value for the PHI being reconstructed.
   while (!Stack.empty()) {
     BasicBlock *Current = Stack.pop_back_val();
-    if (VisitedBlock.contains(Current))
+    if (!VisitedBlock.insert(Current).second)
       continue;
 
-    VisitedBlock.insert(Current);
     if (FlowSet.contains(Current)) {
       for (auto P : predecessors(Current))
         Stack.push_back(P);


        


More information about the llvm-commits mailing list