Make sure the instruction right after an inlined function has a
debug location. This solves a problem where range of an inlined subroutine is emitted wrongly. Patch by Manman Ren. Fixes rdar://problem/12415623 llvm-svn: 180140
This commit is contained in:
@@ -758,8 +758,10 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
|
||||
|
||||
// If the call site was an invoke instruction, add a branch to the normal
|
||||
// destination.
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall))
|
||||
BranchInst::Create(II->getNormalDest(), TheCall);
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
|
||||
BranchInst *NewBr = BranchInst::Create(II->getNormalDest(), TheCall);
|
||||
NewBr->setDebugLoc(Returns[0]->getDebugLoc());
|
||||
}
|
||||
|
||||
// If the return instruction returned a value, replace uses of the call with
|
||||
// uses of the returned value.
|
||||
@@ -787,15 +789,16 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
|
||||
// "starter" and "ender" blocks. How we accomplish this depends on whether
|
||||
// this is an invoke instruction or a call instruction.
|
||||
BasicBlock *AfterCallBB;
|
||||
BranchInst *CreatedBranchToNormalDest = NULL;
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
|
||||
|
||||
// Add an unconditional branch to make this look like the CallInst case...
|
||||
BranchInst *NewBr = BranchInst::Create(II->getNormalDest(), TheCall);
|
||||
CreatedBranchToNormalDest = BranchInst::Create(II->getNormalDest(), TheCall);
|
||||
|
||||
// Split the basic block. This guarantees that no PHI nodes will have to be
|
||||
// updated due to new incoming edges, and make the invoke case more
|
||||
// symmetric to the call case.
|
||||
AfterCallBB = OrigBB->splitBasicBlock(NewBr,
|
||||
AfterCallBB = OrigBB->splitBasicBlock(CreatedBranchToNormalDest,
|
||||
CalledFunc->getName()+".exit");
|
||||
|
||||
} else { // It's a call
|
||||
@@ -874,6 +877,9 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
|
||||
AfterCallBB->getInstList().splice(AfterCallBB->begin(),
|
||||
ReturnBB->getInstList());
|
||||
|
||||
if (CreatedBranchToNormalDest)
|
||||
CreatedBranchToNormalDest->setDebugLoc(Returns[0]->getDebugLoc());
|
||||
|
||||
// Delete the return instruction now and empty ReturnBB now.
|
||||
Returns[0]->eraseFromParent();
|
||||
ReturnBB->eraseFromParent();
|
||||
|
||||
Reference in New Issue
Block a user