[llvm-commits] [llvm] r53007 - /llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp

Devang Patel dpatel at apple.com
Tue Jul 1 18:44:30 PDT 2008


Author: dpatel
Date: Tue Jul  1 20:44:29 2008
New Revision: 53007

URL: http://llvm.org/viewvc/llvm-project?rev=53007&view=rev
Log:
reuse vectors.

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

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=53007&r1=53006&r2=53007&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Jul  1 20:44:29 2008
@@ -85,6 +85,13 @@
     /// OrigLoopExitMap - This is used to map loop exiting block with 
     /// corresponding loop exit block, before updating CFG.
     DenseMap<BasicBlock *, BasicBlock *> OrigLoopExitMap;
+
+    // LoopBlocks contains all of the basic blocks of the loop, including the
+    // preheader of the loop, the body of the loop, and the exit blocks of the 
+    // loop, in that order.
+    std::vector<BasicBlock*> LoopBlocks;
+    // NewBlocks contained cloned copy of basic blocks from LoopBlocks.
+    std::vector<BasicBlock*> NewBlocks;
   public:
     static char ID; // Pass ID, replacement for typeid
     explicit LoopUnswitch(bool Os = false) : 
@@ -761,10 +768,8 @@
        << " blocks] in Function " << F->getName()
        << " when '" << *Val << "' == " << *LIC << "\n";
 
-  // LoopBlocks contains all of the basic blocks of the loop, including the
-  // preheader of the loop, the body of the loop, and the exit blocks of the 
-  // loop, in that order.
-  std::vector<BasicBlock*> LoopBlocks;
+  LoopBlocks.clear();
+  NewBlocks.clear();
 
   // First step, split the preheader and exit blocks, and add these blocks to
   // the LoopBlocks list.
@@ -792,7 +797,6 @@
   // Next step, clone all of the basic blocks that make up the loop (including
   // the loop preheader and exit blocks), keeping track of the mapping between
   // the instructions and blocks.
-  std::vector<BasicBlock*> NewBlocks;
   NewBlocks.reserve(LoopBlocks.size());
   DenseMap<const Value*, Value*> ValueMap;
   for (unsigned i = 0, e = LoopBlocks.size(); i != e; ++i) {





More information about the llvm-commits mailing list