summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-06-17 18:29:27 +0000
committerOwen Anderson <resistor@mac.com>2008-06-17 18:29:27 +0000
commit26bb50ab48c561adfd32d129e0eff0cbf0a04625 (patch)
tree931011ab005e420535a3cca22020397b7d224154
parent2b7470eb54880ce7f74469d6e09eaf7f0864f8ab (diff)
downloadllvm-26bb50ab48c561adfd32d129e0eff0cbf0a04625.tar.gz
llvm-26bb50ab48c561adfd32d129e0eff0cbf0a04625.tar.bz2
llvm-26bb50ab48c561adfd32d129e0eff0cbf0a04625.tar.xz
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.h4
-rw-r--r--lib/VMCore/Instruction.cpp6
2 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index 40d83059fe..89e3e23499 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 1fe7a2cc8b..e8738d2ba7 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.