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.