[llvm] [Coroutines] Fix debug info scoping for nested structs in coroutine frames (PR #147622)

Adrian Vogelsgesang via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 8 19:10:55 PDT 2025


================
@@ -0,0 +1,50 @@
+; RUN: opt < %s -passes='cgscc(coro-split)' -S | FileCheck %s
+
+; Test that nested structs in coroutine frames have correct debug info scoping.
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Minimal nested struct types that trigger the scoping issue
+%"struct.Inner" = type { i32, ptr }
+%"struct.Outer" = type { %"struct.Inner", i64 }
+%"class.Promise" = type { %"struct.Outer" }
+
+define void @test_coro_function() presplitcoroutine !dbg !10 {
+entry:
+  %__promise = alloca %"class.Promise", align 8
+  %0 = call token @llvm.coro.id(i32 0, ptr %__promise, ptr null, ptr null)
+  %1 = call ptr @llvm.coro.begin(token %0, ptr null)
+  %2 = call token @llvm.coro.save(ptr null)
+  ret void
+}
+
+; The test passes if the debug info is generated without crashing
+; CHECK: define void @test_coro_function()
+
+; Check that frame debug info is generated
+; CHECK: ![[FRAME_TYPE:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{{.*}}.coro_frame_ty"
----------------
vogelsgesang wrote:

the test expectations only verify the nesting of the `DICompositeType`. Afaict, the root cause of the crash was not the nesting of the `DICompositeType` but rather of the `DIDerivedType`s representing the members of the composite type, though?

https://github.com/llvm/llvm-project/pull/147622


More information about the llvm-commits mailing list