From: Owen Anderson Date: Tue, 17 Jun 2008 18:29:27 +0000 (+0000) Subject: Add an insertBefore method for attaching previously unattached instructions, X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=26bb50ab48c561adfd32d129e0eff0cbf0a04625;p=oota-llvm.git Add an insertBefore method for attaching previously unattached instructions, such as those created by clone(), to a basic block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52424 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 40d83059fe3..89e3e234998 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -102,6 +102,10 @@ public: /// void eraseFromParent(); + /// insertBefore - Insert an unlinked instructions into a basic block + /// immediately before the specified instruction. + void insertBefore(Instruction *InsertPos); + /// moveBefore - Unlink this instruction from its current basic block and /// insert it into the basic block that MovePos lives in, right before /// MovePos. diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 1fe7a2cc8b1..e8738d2ba72 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -68,6 +68,12 @@ void Instruction::eraseFromParent() { getParent()->getInstList().erase(this); } +/// insertBefore - Insert an unlinked instructions into a basic block +/// immediately before the specified instruction. +void Instruction::insertBefore(Instruction *InsertPos) { + InsertPos->getParent()->getInstList().insert(InsertPos, this); +} + /// moveBefore - Unlink this instruction from its current basic block and /// insert it into the basic block that MovePos lives in, right before /// MovePos.