diff options
author | Owen Anderson <resistor@mac.com> | 2008-06-17 18:29:27 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-06-17 18:29:27 +0000 |
commit | c2d50caa7ba89e0614cf21a11d33530c69c084c5 (patch) | |
tree | 931011ab005e420535a3cca22020397b7d224154 | |
parent | 4a85af47f06019931d6efd14165d4d9325051c89 (diff) | |
download | external_llvm-c2d50caa7ba89e0614cf21a11d33530c69c084c5.zip external_llvm-c2d50caa7ba89e0614cf21a11d33530c69c084c5.tar.gz external_llvm-c2d50caa7ba89e0614cf21a11d33530c69c084c5.tar.bz2 |
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
-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. |