[llvm] r338917 - [TRE][DebugInfo] Preserve Debug Location in new branch instruction
Anastasis Grammenos via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 3 13:27:13 PDT 2018
Author: gramanas
Date: Fri Aug 3 13:27:13 2018
New Revision: 338917
URL: http://llvm.org/viewvc/llvm-project?rev=338917&view=rev
Log:
[TRE][DebugInfo] Preserve Debug Location in new branch instruction
There are two branch instructions created
so the new test covers them both.
Differential Revision: https://reviews.llvm.org/D50263
Added:
llvm/trunk/test/Transforms/TailCallElim/debugloc.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=338917&r1=338916&r2=338917&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Fri Aug 3 13:27:13 2018
@@ -566,7 +566,8 @@ static bool eliminateRecursiveTailCall(C
BasicBlock *NewEntry = BasicBlock::Create(F->getContext(), "", F, OldEntry);
NewEntry->takeName(OldEntry);
OldEntry->setName("tailrecurse");
- BranchInst::Create(OldEntry, NewEntry);
+ BranchInst *BI = BranchInst::Create(OldEntry, NewEntry);
+ BI->setDebugLoc(CI->getDebugLoc());
// If this tail call is marked 'tail' and if there are any allocas in the
// entry block, move them up to the new entry block.
Added: llvm/trunk/test/Transforms/TailCallElim/debugloc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/debugloc.ll?rev=338917&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/TailCallElim/debugloc.ll (added)
+++ llvm/trunk/test/Transforms/TailCallElim/debugloc.ll Fri Aug 3 13:27:13 2018
@@ -0,0 +1,16 @@
+; RUN: opt < %s -debugify -tailcallelim -S | FileCheck %s
+
+define void @foo() {
+entry:
+; CHECK-LABEL: entry:
+; CHECK: br label %tailrecurse, !dbg ![[DbgLoc:[0-9]+]]
+
+ call void @foo() ;; line 1
+ ret void
+
+; CHECK-LABEL: tailrecurse:
+; CHECK: br label %tailrecurse, !dbg ![[DbgLoc]]
+}
+
+;; Make sure tailrecurse has the call instruction's DL
+; CHECK: ![[DbgLoc]] = !DILocation(line: 1
More information about the llvm-commits
mailing list