diff options
author | Chris Lattner <sabre@nondot.org> | 2007-08-04 01:07:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-08-04 01:07:49 +0000 |
commit | 63cdcaa3d6c33cc1923797259bb8e5d9d9a899b1 (patch) | |
tree | 27d16e0633b3887d289bc8497e9f91942d1fd549 /lib/Transforms/Utils | |
parent | ac4aa4be9b25ca40e131bb30c2f8e5fd6fbd2615 (diff) | |
download | external_llvm-63cdcaa3d6c33cc1923797259bb8e5d9d9a899b1.zip external_llvm-63cdcaa3d6c33cc1923797259bb8e5d9d9a899b1.tar.gz external_llvm-63cdcaa3d6c33cc1923797259bb8e5d9d9a899b1.tar.bz2 |
avoid an unneeded vector copy. This speeds up mem2reg on the testcase
in PR1432 by 6%
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40803 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index e4d541a..bb4b599 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -76,11 +76,18 @@ namespace { // 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 @@ void PromoteMem2Reg::run() { 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); |