-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DebugInfo][TailCallElim] Use ret DILocation for return value selects #134825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-debuginfo Author: Stephen Tozer (SLTozer) ChangesIn 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 #107279. Full diff: https://github.com/llvm/llvm-project/pull/134825.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
index 3f27166080d5a..7dd6c60370ed9 100644
--- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -725,6 +725,7 @@ bool TailRecursionEliminator::eliminateCall(CallInst *CI) {
SelectInst *SI =
SelectInst::Create(RetKnownPN, RetPN, Ret->getReturnValue(),
"current.ret.tr", Ret->getIterator());
+ SI->setDebugLoc(Ret->getDebugLoc());
RetSelects.push_back(SI);
RetPN->addIncoming(SI, BB);
diff --git a/llvm/test/Transforms/TailCallElim/debugloc.ll b/llvm/test/Transforms/TailCallElim/debugloc.ll
index 1670b832e9d97..7a3a8f90cb6af 100644
--- a/llvm/test/Transforms/TailCallElim/debugloc.ll
+++ b/llvm/test/Transforms/TailCallElim/debugloc.ll
@@ -1,16 +1,18 @@
; RUN: opt < %s -passes=debugify,tailcallelim -S | FileCheck %s
-define void @foo() {
+define i32 @foo() {
entry:
; CHECK-LABEL: entry:
; CHECK: br label %tailrecurse{{$}}
- call void @foo() ;; line 1
- ret void
+ %ret = call i32 @foo() ;; line 1
+ ret i32 0 ;; line 2
; CHECK-LABEL: tailrecurse:
-; CHECK: br label %tailrecurse, !dbg ![[DbgLoc:[0-9]+]]
+; 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: ![[DbgLoc]] = !DILocation(line: 1
+; CHECK: ![[DbgLoc1]] = !DILocation(line: 1
+; CHECK: ![[DbgLoc2]] = !DILocation(line: 2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding these, seems like your technique is working well! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you have found a lot of cases where the missing debug locations are caused by newly created instructions that are not assigned any location. That's great!
…llvm#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 llvm#107279.
…llvm#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 llvm#107279.
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 #107279.