aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-08-29 18:18:40 +0000
committerChris Lattner <sabre@nondot.org>2010-08-29 18:18:40 +0000
commitd9a5daeb7719c83136c0dc43d6ef732402d1a1b5 (patch)
tree43238ac1616b333b159bc083e8e015ba9fe06ad1
parent1b9c848d0a680de2aed44f43c85f4594416ff15a (diff)
downloadexternal_llvm-d9a5daeb7719c83136c0dc43d6ef732402d1a1b5.zip
external_llvm-d9a5daeb7719c83136c0dc43d6ef732402d1a1b5.tar.gz
external_llvm-d9a5daeb7719c83136c0dc43d6ef732402d1a1b5.tar.bz2
use moveBefore instead of remove+insert, it avoids some
symtab manipulation, so its faster (in addition to being more elegant) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112450 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/LICM.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index e6a8b2d..5f156db 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -474,9 +474,7 @@ void LICM::sink(Instruction &I) {
} else {
// Move the instruction to the start of the exit block, after any PHI
// nodes in it.
- I.removeFromParent();
- BasicBlock::iterator InsertPt = ExitBlocks[0]->getFirstNonPHI();
- ExitBlocks[0]->getInstList().insert(InsertPt, &I);
+ I.moveBefore(ExitBlocks[0]->getFirstNonPHI());
// This instruction is no longer in the AST for the current loop, because
// we just sunk it out of the loop. If we just sunk it into an outer
@@ -574,12 +572,8 @@ void LICM::hoist(Instruction &I) {
DEBUG(dbgs() << "LICM hoisting to " << Preheader->getName() << ": "
<< I << "\n");
- // Remove the instruction from its current basic block... but don't delete the
- // instruction.
- I.removeFromParent();
-
- // Insert the new node in Preheader, before the terminator.
- Preheader->getInstList().insert(Preheader->getTerminator(), &I);
+ // Move the new node to the Preheader, before its terminator.
+ I.moveBefore(Preheader->getTerminator());
if (isa<LoadInst>(I)) ++NumMovedLoads;
else if (isa<CallInst>(I)) ++NumMovedCalls;