From 8b11e89b93542a465b4b23197283cc7bbceaaa9a Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 30 Apr 2013 17:08:16 +0000 Subject: Set debug locations for branch instructions created during inlining, even the inlined function has multiple returns. rdar://problem/12415623 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180793 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/InlineFunction.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/Transforms/Utils/InlineFunction.cpp') diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index e9f0e28ad6..ae9300a40a 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -853,11 +853,19 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI, // Add a branch to the merge points and remove return instructions. + ReturnInst *RI; for (unsigned i = 0, e = Returns.size(); i != e; ++i) { - ReturnInst *RI = Returns[i]; - BranchInst::Create(AfterCallBB, RI); + RI = Returns[i]; + BranchInst* BI = BranchInst::Create(AfterCallBB, RI); + BI->setDebugLoc(RI->getDebugLoc()); RI->eraseFromParent(); } + // We need to set the debug location to *somewhere* inside the + // inlined function. The line number may be nonsentical, but the + // instruction will at least be associated with the right + // function. + if (CreatedBranchToNormalDest) + CreatedBranchToNormalDest->setDebugLoc(RI->getDebugLoc()); } else if (!Returns.empty()) { // Otherwise, if there is exactly one return value, just replace anything // using the return value of the call with the computed value. -- cgit v1.2.3