-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[coro] Fix crash due to DILabel in LineTableOnly mode
#148095
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
[coro] Fix crash due to DILabel in LineTableOnly mode
#148095
Conversation
|
@llvm/pr-subscribers-coroutines @llvm/pr-subscribers-llvm-transforms Author: Adrian Vogelsgesang (vogelsgesang) ChangesSince the recent commit de3c841, the Unfortunately, it turns out that the DWARF backend does not expect to find any DILabel debug metadata if the emission kind is set to LineTableOnly. The Dwarf backend simply runs into an assertion in that case. This commit fixes the issue by only adding Full diff: https://github.com/llvm/llvm-project/pull/148095.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 077dbe697a87e..6e5a017238c20 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -1485,11 +1485,9 @@ struct SwitchCoroutineSplitter {
// without debug info. So we also don't generate debug info for the
// suspension points.
bool AddDebugLabels =
- (DIS && DIS->getUnit() &&
- (DIS->getUnit()->getEmissionKind() ==
- DICompileUnit::DebugEmissionKind::FullDebug ||
- DIS->getUnit()->getEmissionKind() ==
- DICompileUnit::DebugEmissionKind::LineTablesOnly));
+ DIS && DIS->getUnit() &&
+ (DIS->getUnit()->getEmissionKind() ==
+ DICompileUnit::DebugEmissionKind::FullDebug);
// resume.entry:
// %index.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Since the recent commit de3c841, the `CoroSplit` pass adds `DILabel`s to help find the location of a suspension point from its suspension point id. Those labels are added in both `DebugEmissionKind::FullDebug` and `DebugEmissionKind::LineTableOnly` mode. The idea was that this information is necessary to reconstruct async stack traces and should hence also be available for LineTableOnly. Unfortunately, it turns out that the DWARF backend does not expect to find any DILabel debug metadata if the emission kind is set to LineTableOnly. The Dwarf backend simply runs into an assertion in that case. This commit fixes the issue by only adding `DILabel` for FullDebug.
c2e0eb3 to
bc96976
Compare
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 just verified that the crash we were seeing is fixed with this change.
Thank you!
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.
Please add a regression test.
Added a test case. Let me know if you are happy with that. |
Thanks! This looks good to me. I'd probably add a test from #141937 (comment) or a similar one that makes clang without this fix crash, but that can be done separately from this fix, which I would prefer to submit now to unblock our testing. |
Since the recent commit de3c841, the
CoroSplitpass addsDILabels to help find the location of a suspension point from its suspension point id. Those labels are added in bothDebugEmissionKind::FullDebugandDebugEmissionKind::LineTableOnlymode. The idea was that this information is necessary to reconstruct async stack traces and should hence also be available for LineTableOnly.Unfortunately, it turns out that the DWARF backend does not expect to find any DILabel debug metadata if the emission kind is set to LineTableOnly. The Dwarf backend simply runs into an assertion in that case.
This commit fixes the issue by only adding
DILabelfor FullDebug.