Stephen Tozer a6edaeb824
[DebugInfo][TailCallElim] Use ret DILocation for return value selects (#134825)
In TailRecursionElimination we may insert a select before the return to
choose the return value if necessary; this select is effectively part of
the return statement, and so should use its DILocation.

Found using https://github.com/llvm/llvm-project/pull/107279.
2025-04-09 12:48:59 +01:00

19 lines
555 B
LLVM

; RUN: opt < %s -passes=debugify,tailcallelim -S | FileCheck %s
define i32 @foo() {
entry:
; CHECK-LABEL: entry:
; CHECK: br label %tailrecurse{{$}}
%ret = call i32 @foo() ;; line 1
ret i32 0 ;; line 2
; CHECK-LABEL: tailrecurse:
; CHECK: select i1 {{.+}}, !dbg ![[DbgLoc2:[0-9]+]]
; CHECK: br label %tailrecurse, !dbg ![[DbgLoc1:[0-9]+]]
}
;; Make sure tailrecurse has the call instruction's DL
; CHECK: ![[DbgLoc1]] = !DILocation(line: 1
; CHECK: ![[DbgLoc2]] = !DILocation(line: 2