Add an insertBefore method for attaching previously unattached instructions,
authorOwen Anderson <resistor@mac.com>
Tue, 17 Jun 2008 18:29:27 +0000 (18:29 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 17 Jun 2008 18:29:27 +0000 (18:29 +0000)
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

include/llvm/Instruction.h
lib/VMCore/Instruction.cpp

index 40d83059fe3d151e403097650ee100390c0517cd..89e3e2349987b70d5fd25dff3ce4e347e061a228 100644 (file)
@@ -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.
index 1fe7a2cc8b147e11d9951d0559352207c340ec35..e8738d2ba72bd755ab7427f8987834bac0781558 100644 (file)
@@ -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.