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

Grigory Pastukhov via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 9 10:24:22 PDT 2025


================
@@ -639,10 +639,10 @@ static DIType *solveDIType(DIBuilder &Builder, Type *Ty,
     SmallVector<Metadata *, 16> Elements;
     for (unsigned I = 0; I < StructTy->getNumElements(); I++) {
       DIType *DITy = solveDIType(Builder, StructTy->getElementType(I), Layout,
-                                 Scope, LineNum, DITypeCache);
+                                 DIStruct, LineNum, DITypeCache);
       assert(DITy);
       Elements.push_back(Builder.createMemberType(
-          Scope, DITy->getName(), Scope->getFile(), LineNum,
+          DIStruct, DITy->getName(), DIStruct->getFile(), LineNum,
----------------
grigorypas wrote:

Actually, the first change (on line 642) is what resolves the crash. When Builder.createStructType is called, the code below expects it to be newly created object. The code generates the same generic name for un-named structs. Thus, if the Scope is inherited from the top level function,  Builder.createStructType might return previously cached object for different un-named struct. 

DWARF supports nested structs. See for example here https://github.com/llvm/llvm-project/blob/main/llvm/test/DebugInfo/Generic/tu-composite.ll#L142C1-L146C154.  

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


More information about the llvm-commits mailing list