[llvm-commits] CVS: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Chris Lattner sabre at nondot.org
Mon Feb 5 13:59:04 PST 2007



Changes in directory llvm/lib/Transforms/Utils:

PromoteMemoryToRegister.cpp updated: 1.85 -> 1.86
---
Log message:

eliminate some malloc traffic, this speeds up mem2reg by 3.4%.



---
Diffs of the changes:  (+8 -5)

 PromoteMemoryToRegister.cpp |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.85 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.86
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.85	Sun Aug 27 07:54:02 2006
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp	Mon Feb  5 15:58:48 2007
@@ -23,6 +23,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Analysis/AliasSetTracker.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/StableBasicBlockNumbering.h"
@@ -57,7 +58,7 @@
     /// Allocas - The alloca instructions being promoted.
     ///
     std::vector<AllocaInst*> Allocas;
-    std::vector<AllocaInst*> &RetryList;
+    SmallVector<AllocaInst*, 16> &RetryList;
     DominatorTree &DT;
     DominanceFrontier &DF;
     const TargetData &TD;
@@ -90,7 +91,7 @@
 
   public:
     PromoteMem2Reg(const std::vector<AllocaInst*> &A,
-                   std::vector<AllocaInst*> &Retry, DominatorTree &dt,
+                   SmallVector<AllocaInst*, 16> &Retry, DominatorTree &dt,
                    DominanceFrontier &df, const TargetData &td,
                    AliasSetTracker *ast)
       : Allocas(A), RetryList(Retry), DT(dt), DF(df), TD(td), AST(ast) {}
@@ -736,11 +737,12 @@
   // If there is nothing to do, bail out...
   if (Allocas.empty()) return;
 
-  std::vector<AllocaInst*> RetryList;
+  SmallVector<AllocaInst*, 16> RetryList;
   PromoteMem2Reg(Allocas, RetryList, DT, DF, TD, AST).run();
 
   // PromoteMem2Reg may not have been able to promote all of the allocas in one
   // pass, run it again if needed.
+  std::vector<AllocaInst*> NewAllocas;
   while (!RetryList.empty()) {
     // If we need to retry some allocas, this is due to there being no store
     // before a read in a local block.  To counteract this, insert a store of
@@ -752,8 +754,9 @@
                     RetryList[i], ++BBI);
     }
 
-    std::vector<AllocaInst*> NewAllocas;
-    std::swap(NewAllocas, RetryList);
+    NewAllocas.assign(RetryList.begin(), RetryList.end());
+    RetryList.clear();
     PromoteMem2Reg(NewAllocas, RetryList, DT, DF, TD, AST).run();
+    NewAllocas.clear();
   }
 }






More information about the llvm-commits mailing list