[llvm-commits] [llvm] r122723 - /llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp

Chris Lattner sabre at nondot.org
Sun Jan 2 17:42:46 PST 2011


Author: lattner
Date: Sun Jan  2 19:42:46 2011
New Revision: 122723

URL: http://llvm.org/viewvc/llvm-project?rev=122723&view=rev
Log:
Allocate nodes for the scoped hash table from a recyling bump pointer
allocator.  This speeds up early cse by about 20%

Modified:
    llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp?rev=122723&r1=122722&r2=122723&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp Sun Jan  2 19:42:46 2011
@@ -21,6 +21,7 @@
 #include "llvm/Target/TargetData.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/RecyclingAllocator.h"
 #include "llvm/ADT/ScopedHashTable.h"
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
@@ -132,7 +133,11 @@
 public:
   const TargetData *TD;
   DominatorTree *DT;
-  ScopedHashTable<InstValue, Instruction*> *AvailableValues;
+  typedef RecyclingAllocator<BumpPtrAllocator,
+                      ScopedHashTableVal<InstValue, Instruction*> > AllocatorTy;
+  typedef ScopedHashTable<InstValue, Instruction*, DenseMapInfo<InstValue>,
+                          AllocatorTy> ScopedHTType;
+  ScopedHTType *AvailableValues;
   
   static char ID;
   explicit EarlyCSE()
@@ -165,11 +170,10 @@
 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
 INITIALIZE_PASS_END(EarlyCSE, "early-cse", "Early CSE", false, false)
 
-// FIXME: Should bump pointer allocate entries in scoped hash table.
-
 bool EarlyCSE::processNode(DomTreeNode *Node) {
   // Define a scope in the scoped hash table.
-  ScopedHashTableScope<InstValue, Instruction*> Scope(*AvailableValues);
+  ScopedHashTableScope<InstValue, Instruction*, DenseMapInfo<InstValue>,
+                       AllocatorTy> Scope(*AvailableValues);
   
   BasicBlock *BB = Node->getBlock();
   
@@ -228,7 +232,7 @@
 bool EarlyCSE::runOnFunction(Function &F) {
   TD = getAnalysisIfAvailable<TargetData>();
   DT = &getAnalysis<DominatorTree>();
-  ScopedHashTable<InstValue, Instruction*> AVTable;
+  ScopedHTType AVTable;
   AvailableValues = &AVTable;
   return processNode(DT->getRootNode());
 }





More information about the llvm-commits mailing list