[llvm] [coro] Fix crash due to DILabel in `LineTableOnly` mode (PR #148095)

Adrian Vogelsgesang via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 10 18:21:13 PDT 2025


https://github.com/vogelsgesang updated https://github.com/llvm/llvm-project/pull/148095

>From bc96976c770634c0ae412a8a80eebe9243bd8cba Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang <avogelsgesang at salesforce.com>
Date: Fri, 11 Jul 2025 01:11:53 +0000
Subject: [PATCH] [coro] Fix crash due to DILabel in `LineTableOnly` mode

Since the recent commit de3c8410d8, 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.
---
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 077dbe697a87e..f1e17ff01a4a2 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -1484,12 +1484,9 @@ struct SwitchCoroutineSplitter {
     // If there is no DISubprogram for F, it implies the function is compiled
     // 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));
+    bool AddDebugLabels = DIS && DIS->getUnit() &&
+                          (DIS->getUnit()->getEmissionKind() ==
+                           DICompileUnit::DebugEmissionKind::FullDebug);
 
     // resume.entry:
     //  %index.addr = getelementptr inbounds %f.Frame, %f.Frame* %FramePtr, i32



More information about the llvm-commits mailing list