aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/TransformInternals.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-03-21 06:24:00 +0000
committerChris Lattner <sabre@nondot.org>2002-03-21 06:24:00 +0000
commit8e86542fb698258a7feaa5703a1cf3918a7198fb (patch)
tree63db68592e03a60852d829dbbeab84ea7a1d71eb /lib/Transforms/TransformInternals.cpp
parent45ef5c26d4c92dcf7a36fa764b22f6b2faed68bf (diff)
Implement the new InsertInstBeforeInst function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1930 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/TransformInternals.cpp')
-rw-r--r--lib/Transforms/TransformInternals.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp
index c09ad3d298..9ea053e040 100644
--- a/lib/Transforms/TransformInternals.cpp
+++ b/lib/Transforms/TransformInternals.cpp
@@ -67,6 +67,20 @@ void ReplaceInstWithInst(Instruction *From, Instruction *To) {
ReplaceInstWithInst(BIL, BI, To);
}
+// InsertInstBeforeInst - Insert 'NewInst' into the basic block that 'Existing'
+// is already in, and put it right before 'Existing'. This instruction should
+// only be used when there is no iterator to Existing already around. The
+// returned iterator points to the new instruction.
+//
+BasicBlock::iterator InsertInstBeforeInst(Instruction *NewInst,
+ Instruction *Existing) {
+ BasicBlock *BB = Existing->getParent();
+ BasicBlock::InstListType &BIL = BB->getInstList();
+ BasicBlock::iterator BI = find(BIL.begin(), BIL.end(), Existing);
+ assert(BI != BIL.end() && "Inst not in it's parents BB!");
+ return BIL.insert(BI, NewInst);
+}
+
// getStructOffsetType - Return a vector of offsets that are to be used to index