[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:16:40 PDT 2025


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

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.

>From c2e0eb345d5be92a063084630e5acbe1290f16be 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 | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

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



More information about the llvm-commits mailing list