[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:19:58 PDT 2018


gramanas updated this revision to Diff 159038.
gramanas added a comment.

- typo


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 tailrecurse 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.159038.patch
Type: text/x-patch
Size: 1319 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180803/ce0159a6/attachment.bin>


More information about the llvm-commits mailing list