switch MarkAliveBlocks over to using SmallPtrSet instead of std::set, speeding
authorChris Lattner <sabre@nondot.org>
Sun, 4 Mar 2007 04:20:48 +0000 (04:20 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 4 Mar 2007 04:20:48 +0000 (04:20 +0000)
up simplifycfg by 20%

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

lib/Transforms/Scalar/SimplifyCFG.cpp

index 97ea9f4ce55df651856b45ca2e04b77a7ff46426..659f34f2ef95629a6430c60ee59c14d269769413 100644 (file)
@@ -27,8 +27,8 @@
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Pass.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/Statistic.h"
-#include <set>
 using namespace llvm;
 
 STATISTIC(NumSimpl, "Number of blocks simplified");
@@ -45,9 +45,9 @@ FunctionPass *llvm::createCFGSimplificationPass() {
   return new CFGSimplifyPass();
 }
 
-static bool MarkAliveBlocks(BasicBlock *BB, std::set<BasicBlock*> &Reachable) {
-  if (Reachable.count(BB)) return false;
-  Reachable.insert(BB);
+static bool MarkAliveBlocks(BasicBlock *BB,
+                            SmallPtrSet<BasicBlock*, 16> &Reachable) {
+  if (!Reachable.insert(BB)) return false;
 
   // Do a quick scan of the basic block, turning any obviously unreachable
   // instructions into LLVM unreachable insts.  The instruction combining pass
@@ -85,7 +85,7 @@ static bool MarkAliveBlocks(BasicBlock *BB, std::set<BasicBlock*> &Reachable) {
 // simplify the CFG.
 //
 bool CFGSimplifyPass::runOnFunction(Function &F) {
-  std::set<BasicBlock*> Reachable;
+  SmallPtrSet<BasicBlock*, 16> Reachable;
   bool Changed = MarkAliveBlocks(F.begin(), Reachable);
 
   // If there are unreachable blocks in the CFG...