[PATCH] D50263: [TRE][DebugInfo] Preserve Debug Location in new branch instruction
Anastasis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 3 10:18:30 PDT 2018
gramanas created this revision.
gramanas added a reviewer: vsk.
Herald added subscribers: llvm-commits, JDevlieghere.
https://bugs.llvm.org/show_bug.cgi?id=38179
The DL is the one from the call instruction.
There are two branch instructions created
so the new test covers them both.
Repository:
rL LLVM
https://reviews.llvm.org/D50263
Files:
lib/Transforms/Scalar/TailRecursionElimination.cpp
test/Transforms/TailCallElim/debugloc.ll
Index: test/Transforms/TailCallElim/debugloc.ll
===================================================================
--- /dev/null
+++ test/Transforms/TailCallElim/debugloc.ll
@@ -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 tailrecurs has the call instruction's DL
+; CHECK: ![[DbgLoc]] = !DILocation(line: 1
Index: lib/Transforms/Scalar/TailRecursionElimination.cpp
===================================================================
--- lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -566,7 +566,8 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50263.159035.patch
Type: text/x-patch
Size: 1318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180803/06fae179/attachment.bin>
More information about the llvm-commits
mailing list