From 40b6555561f083930a40c5c9e8b1023c81910402 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 5 Feb 2007 21:58:48 +0000 Subject: eliminate some malloc traffic, this speeds up mem2reg by 3.4%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33927 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp') diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index cafbd55219..a25ea6b54d 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -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 @@ namespace { /// Allocas - The alloca instructions being promoted. /// std::vector Allocas; - std::vector &RetryList; + SmallVector &RetryList; DominatorTree &DT; DominanceFrontier &DF; const TargetData &TD; @@ -90,7 +91,7 @@ namespace { public: PromoteMem2Reg(const std::vector &A, - std::vector &Retry, DominatorTree &dt, + SmallVector &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 @@ void llvm::PromoteMemToReg(const std::vector &Allocas, // If there is nothing to do, bail out... if (Allocas.empty()) return; - std::vector RetryList; + SmallVector 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 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 @@ void llvm::PromoteMemToReg(const std::vector &Allocas, RetryList[i], ++BBI); } - std::vector NewAllocas; - std::swap(NewAllocas, RetryList); + NewAllocas.assign(RetryList.begin(), RetryList.end()); + RetryList.clear(); PromoteMem2Reg(NewAllocas, RetryList, DT, DF, TD, AST).run(); + NewAllocas.clear(); } } -- cgit v1.2.3