Skip to content

Conversation

@vogelsgesang
Copy link
Member

Since the recent commit de3c841, the CoroSplit pass adds DILabels 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.

@llvmbot
Copy link
Member

llvmbot commented Jul 11, 2025

@llvm/pr-subscribers-coroutines

@llvm/pr-subscribers-llvm-transforms

Author: Adrian Vogelsgesang (vogelsgesang)

Changes

Since the recent commit de3c841, the CoroSplit pass adds DILabels 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.


Full diff: https://github.com/llvm/llvm-project/pull/148095.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Coroutines/CoroSplit.cpp (+3-5)
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

@github-actions
Copy link

github-actions bot commented Jul 11, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@vogelsgesang vogelsgesang requested review from alexfh, bgra8 and pogo59 July 11, 2025 01:20
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.
@vogelsgesang vogelsgesang force-pushed the avogelsgesang-fix-coro-label-crash branch from c2e0eb3 to bc96976 Compare July 11, 2025 01:21
Copy link
Contributor

@bgra8 bgra8 left a 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!

Copy link
Contributor

@alexfh alexfh left a 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.

@alexfh alexfh requested a review from dwblaikie July 11, 2025 13:12
@vogelsgesang
Copy link
Member Author

Please add a regression test.

Added a test case. Let me know if you are happy with that.
If you are happy with the test case, feel free to hit "Squash and Merge" on my behalf. I would not be planning any other changes and this PR would be ready for merging. (Assuming that CI comes back green, of course. But it passed on my local machine, at least)

@alexfh
Copy link
Contributor

alexfh commented Jul 11, 2025

Please add a regression test.

Added a test case. Let me know if you are happy with that. If you are happy with the test case, feel free to hit "Squash and Merge" on my behalf. I would not be planning any other changes and this PR would be ready for merging. (Assuming that CI comes back green, of course. But it passed on my local machine, at least)

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.

@alexfh alexfh merged commit 18a182b into llvm:main Jul 11, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants