Skip to content

Commit 912e2c4

Browse files
ApochensSLTozer
andauthored
[Debuginfo][TailCallElim] Fix #86262: drop the debug location of entry branch (#86269)
This pr fixes #86262. --------- Co-authored-by: Stephen Tozer <[email protected]>
1 parent 8d77d36 commit 912e2c4

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,9 @@ void TailRecursionEliminator::createTailRecurseLoopHeader(CallInst *CI) {
510510
NewEntry->takeName(HeaderBB);
511511
HeaderBB->setName("tailrecurse");
512512
BranchInst *BI = BranchInst::Create(HeaderBB, NewEntry);
513-
BI->setDebugLoc(CI->getDebugLoc());
513+
// If the new branch preserves the debug location of CI, it could result in
514+
// misleading stepping, if CI is located in a conditional branch.
515+
// So, here we don't give any debug location to BI.
514516

515517
// Move all fixed sized allocas from HeaderBB to NewEntry.
516518
for (BasicBlock::iterator OEBI = HeaderBB->begin(), E = HeaderBB->end(),

llvm/test/Transforms/TailCallElim/debugloc.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
define void @foo() {
55
entry:
66
; CHECK-LABEL: entry:
7-
; CHECK: br label %tailrecurse, !dbg ![[DbgLoc:[0-9]+]]
7+
; CHECK: br label %tailrecurse{{$}}
88

99
call void @foo() ;; line 1
1010
ret void
1111

1212
; CHECK-LABEL: tailrecurse:
13-
; CHECK: br label %tailrecurse, !dbg ![[DbgLoc]]
13+
; CHECK: br label %tailrecurse, !dbg ![[DbgLoc:[0-9]+]]
1414
}
1515

1616
;; Make sure tailrecurse has the call instruction's DL

0 commit comments

Comments
 (0)