diff options
-rw-r--r-- | include/llvm/Instruction.h | 4 | ||||
-rw-r--r-- | lib/VMCore/Instruction.cpp | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 40d8305..89e3e23 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 1fe7a2c..e8738d2 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. |