Stop reallocating SunkAddrs for each basic block. When we move to an instruction
authorCameron Zwarich <zwarich@apple.com>
Thu, 6 Jan 2011 00:42:50 +0000 (00:42 +0000)
committerCameron Zwarich <zwarich@apple.com>
Thu, 6 Jan 2011 00:42:50 +0000 (00:42 +0000)
worklist, the key will need to become std::pair<BasicBlock*, Value*>.

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

lib/Transforms/Scalar/CodeGenPrepare.cpp

index 1f842fb4f8f6a49f479dac0446b409d191480938..c15bd8a4268902b2b117537f9198658f7d06978b 100644 (file)
@@ -71,6 +71,12 @@ namespace {
     /// BackEdges - Keep a set of all the loop back edges.
     ///
     SmallSet<std::pair<const BasicBlock*, const BasicBlock*>, 8> BackEdges;
+
+    // Keeps track of non-local addresses that have been sunk into a block. This
+    // allows us to avoid inserting duplicate code for blocks with multiple
+    // load/stores of the same address.
+    DenseMap<Value*, Value*> SunkAddrs;
+
   public:
     static char ID; // Pass identification, replacement for typeid
     explicit CodeGenPrepare(const TargetLowering *tli = 0)
@@ -141,6 +147,9 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
       MadeChange |= OptimizeBlock(*BB);
     EverMadeChange |= MadeChange;
   }
+
+  SunkAddrs.clear();
+
   return EverMadeChange;
 }
 
@@ -968,10 +977,7 @@ bool CodeGenPrepare::OptimizeBlock(BasicBlock &BB) {
     }
   }
 
-  // Keep track of non-local addresses that have been sunk into this block.
-  // This allows us to avoid inserting duplicate code for blocks with multiple
-  // load/stores of the same address.
-  DenseMap<Value*, Value*> SunkAddrs;
+  SunkAddrs.clear();
 
   for (BasicBlock::iterator BBI = BB.begin(), E = BB.end(); BBI != E; ) {
     Instruction *I = BBI++;