[llvm-commits] [llvm] r40803 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Chris Lattner
sabre at nondot.org
Fri Aug 3 18:07:49 PDT 2007
Author: lattner
Date: Fri Aug 3 20:07:49 2007
New Revision: 40803
URL: http://llvm.org/viewvc/llvm-project?rev=40803&view=rev
Log:
avoid an unneeded vector copy. This speeds up mem2reg on the testcase
in PR1432 by 6%
Modified:
llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=40803&r1=40802&r2=40803&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug 3 20:07:49 2007
@@ -76,11 +76,18 @@
// Data package used by RenamePass()
class VISIBILITY_HIDDEN RenamePassData {
public:
+ RenamePassData() {}
RenamePassData(BasicBlock *B, BasicBlock *P,
const std::vector<Value *> &V) : BB(B), Pred(P), Values(V) {}
BasicBlock *BB;
BasicBlock *Pred;
std::vector<Value *> Values;
+
+ void swap(RenamePassData &RHS) {
+ std::swap(BB, RHS.BB);
+ std::swap(Pred, RHS.Pred);
+ Values.swap(RHS.Values);
+ }
};
struct VISIBILITY_HIDDEN PromoteMem2Reg {
@@ -406,7 +413,8 @@
std::vector<RenamePassData> RenamePassWorkList;
RenamePassWorkList.push_back(RenamePassData(F.begin(), 0, Values));
while(!RenamePassWorkList.empty()) {
- RenamePassData RPD = RenamePassWorkList.back();
+ RenamePassData RPD;
+ RPD.swap(RenamePassWorkList.back());
RenamePassWorkList.pop_back();
// RenamePass may add new worklist entries.
RenamePass(RPD.BB, RPD.Pred, RPD.Values, RenamePassWorkList);
More information about the llvm-commits
mailing list