[llvm] 380b8a6 - [DFAJumpThreading] Use SmallPtrSet for Visited (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 2 12:30:35 PDT 2021


Author: Nikita Popov
Date: 2021-08-02T21:30:25+02:00
New Revision: 380b8a603c6e8997819726b15a76b8f6c94aa21a

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

LOG: [DFAJumpThreading] Use SmallPtrSet for Visited (NFC)

This set is only used for contains checks, so there is no need to
use std::set.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index b252c4229387..2d34ba226290 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -349,7 +349,7 @@ struct ClonedBlock {
 
 typedef std::deque<BasicBlock *> PathType;
 typedef std::vector<PathType> PathsType;
-typedef std::set<const BasicBlock *> VisitedBlocks;
+typedef SmallPtrSet<const BasicBlock *, 8> VisitedBlocks;
 typedef std::vector<ClonedBlock> CloneList;
 
 // This data structure keeps track of all blocks that have been cloned.  If two
@@ -631,7 +631,7 @@ struct AllSwitchPaths {
       }
 
       // We have encountered a cycle, do not get caught in it
-      if (Visited.find(Succ) != Visited.end())
+      if (Visited.contains(Succ))
         continue;
 
       PathsType SuccPaths = paths(Succ, Visited, PathDepth + 1);


        


More information about the llvm-commits mailing list