[llvm] 912e2c4 - [Debuginfo][TailCallElim] Fix #86262: drop the debug location of entry branch (#86269)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 02:37:37 PDT 2024
Author: Shan Huang
Date: 2024-03-28T17:37:33+08:00
New Revision: 912e2c47589d7f4de3e59e99920fe9a60281db2a
URL: https://github.com/llvm/llvm-project/commit/912e2c47589d7f4de3e59e99920fe9a60281db2a
DIFF: https://github.com/llvm/llvm-project/commit/912e2c47589d7f4de3e59e99920fe9a60281db2a.diff
LOG: [Debuginfo][TailCallElim] Fix #86262: drop the debug location of entry branch (#86269)
This pr fixes #86262.
---------
Co-authored-by: Stephen Tozer <Melamoto at gmail.com>
Added:
Modified:
llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
llvm/test/Transforms/TailCallElim/debugloc.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
index 519ff3221a3bc3..34d39f3fe6dcac 100644
--- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -510,7 +510,9 @@ void TailRecursionEliminator::createTailRecurseLoopHeader(CallInst *CI) {
NewEntry->takeName(HeaderBB);
HeaderBB->setName("tailrecurse");
BranchInst *BI = BranchInst::Create(HeaderBB, NewEntry);
- BI->setDebugLoc(CI->getDebugLoc());
+ // If the new branch preserves the debug location of CI, it could result in
+ // misleading stepping, if CI is located in a conditional branch.
+ // So, here we don't give any debug location to BI.
// Move all fixed sized allocas from HeaderBB to NewEntry.
for (BasicBlock::iterator OEBI = HeaderBB->begin(), E = HeaderBB->end(),
diff --git a/llvm/test/Transforms/TailCallElim/debugloc.ll b/llvm/test/Transforms/TailCallElim/debugloc.ll
index 3abbd6552efce3..49957695a421b9 100644
--- a/llvm/test/Transforms/TailCallElim/debugloc.ll
+++ b/llvm/test/Transforms/TailCallElim/debugloc.ll
@@ -4,13 +4,13 @@
define void @foo() {
entry:
; CHECK-LABEL: entry:
-; CHECK: br label %tailrecurse, !dbg ![[DbgLoc:[0-9]+]]
+; CHECK: br label %tailrecurse{{$}}
call void @foo() ;; line 1
ret void
; CHECK-LABEL: tailrecurse:
-; CHECK: br label %tailrecurse, !dbg ![[DbgLoc]]
+; CHECK: br label %tailrecurse, !dbg ![[DbgLoc:[0-9]+]]
}
;; Make sure tailrecurse has the call instruction's DL
More information about the llvm-commits
mailing list