diff options
author | Andrew Trick <atrick@apple.com> | 2011-06-29 23:01:52 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2011-06-29 23:01:52 +0000 |
commit | e98e9a154036d6f25c1e0c9a62962932f601c05c (patch) | |
tree | bb7577dc71db7b3654b40a28d0b77cd1d8a0cf28 | |
parent | f0f9f450876027d3d1991568852caba785f12059 (diff) | |
download | bcm5719-llvm-e98e9a154036d6f25c1e0c9a62962932f601c05c.tar.gz bcm5719-llvm-e98e9a154036d6f25c1e0c9a62962932f601c05c.zip |
Added IRBuilder::SetInsertPoint(Use) to find a valid insertion point
that dominates the given Use.
llvm-svn: 134111
-rw-r--r-- | llvm/include/llvm/Support/IRBuilder.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/IRBuilder.h b/llvm/include/llvm/Support/IRBuilder.h index 9058e3e2535..94592800fe4 100644 --- a/llvm/include/llvm/Support/IRBuilder.h +++ b/llvm/include/llvm/Support/IRBuilder.h @@ -90,6 +90,19 @@ public: InsertPt = IP; } + /// SetInsertPoint(Use) - Find the nearest point that dominates this use, and + /// specify that created instructions should be inserted at this point. + void SetInsertPoint(Use &U) { + Instruction *UseInst = cast<Instruction>(U.getUser()); + if (PHINode *Phi = dyn_cast<PHINode>(UseInst)) { + BasicBlock *PredBB = Phi->getIncomingBlock(U); + assert(U != PredBB->getTerminator() && "critical edge not split"); + SetInsertPoint(PredBB, PredBB->getTerminator()); + return; + } + SetInsertPoint(UseInst); + } + /// SetCurrentDebugLocation - Set location information used by debugging /// information. void SetCurrentDebugLocation(const DebugLoc &L) { @@ -342,6 +355,12 @@ public: SetCurrentDebugLocation(IP->getDebugLoc()); } + explicit IRBuilder(Use &U) + : IRBuilderBase(U->getContext()), Folder() { + SetInsertPoint(U); + SetCurrentDebugLocation(cast<Instruction>(U.getUser())->getDebugLoc()); + } + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F) : IRBuilderBase(TheBB->getContext()), Folder(F) { SetInsertPoint(TheBB, IP); |