[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)
dzhidzhoev updated this revision to Diff 522140. dzhidzhoev added a comment. Rebased. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144006/new/ https://reviews.llvm.org/D144006 Files: clang/test/CodeGen/debug-info-codeview-unnamed.c clang/test/CodeGen/debug-info-unused-types.c clang/test/CodeGen/debug-info-unused-types.cpp clang/test/CodeGenCXX/debug-info-access.cpp clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp clang/test/CodeGenCXX/debug-lambda-this.cpp llvm/include/llvm/IR/DIBuilder.h llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/Verifier.cpp llvm/test/DebugInfo/Generic/inlined-local-type.ll llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll llvm/test/DebugInfo/Generic/lexical-block-types.ll llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll llvm/test/DebugInfo/X86/set.ll Index: llvm/test/DebugInfo/X86/set.ll === --- llvm/test/DebugInfo/X86/set.ll +++ llvm/test/DebugInfo/X86/set.ll @@ -68,11 +68,11 @@ !llvm.module.flags = !{!18, !19, !20} !0 = !{!"versions- cm3: d5.10.0 llvm: 9.0"} -!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3) +!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) !2 = !DIFile(filename: "Main.m3", directory: "/home/cm3/settest/src") !3 = !{!4} !4 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", scope: !5, file: !2, line: 11, size: 8, align: 8, elements: !9) -!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !8) +!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !3) !6 = !DISubroutineType(types: !7) !7 = !{null} !8 = !{} Index: llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll === --- llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll +++ llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll @@ -38,7 +38,7 @@ define void @invalid_retained_nodes_list() !dbg !10 { ret void } !10 = distinct !DISubprogram(retainedNodes: !0) -; CHECK: invalid retained nodes, expected DILocalVariable, DILabel or DIImportedEntity +; CHECK: invalid retained nodes, expected DILocalVariable, DILabel, DIImportedEntity or DIType define void @invalid_retained_nodes_expected() !dbg !11 { ret void } !11 = distinct !DISubprogram(retainedNodes: !{!0}) Index: llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll @@ -0,0 +1,160 @@ +; RUN: %llc_dwarf -O0 -filetype=obj < %s \ +; RUN: | llvm-dwarfdump --show-children --name=foo - \ +; RUN: | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s + +; The test ensures that AsmPrinter doesn't crashed compiling this. +; It also demostrates misplacement for a local type (see PR55680 for details). + +; The test compiled from: + +; template +; struct A { +; A(T &in) : a(in) {} +; T a; +; }; +; +; __attribute__((always_inline)) +; void foo() { +; struct B { int i; }; +; B objB; +; A objA(objB); +; } +; +; int main() { +; foo(); +; } + +; Concrete out-of-line tree of foo(). +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_abstract_origin {{.*}} "_Z3foov" +; +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin {{.*}} "objB" +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin {{.*}} "objA" + +; FIXME: 'struct B' should be in the abstract tree below, not here. +; CHECK: DW_TAG_structure_type +; CHECK: DW_AT_name ("B") +; CHECK: DW_TAG_member +; CHECK: NULL + +; CHECK: NULL + +; Abstract tree of foo(). +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_name ("foo") +; CHECK: DW_AT_inline (DW_INL_inlined) + +; CHECK: DW_TAG_variable +; CHECK: DW_AT_name ("objB") +; CHECK: DW_TAG_variable +; CHECK: DW_AT_name ("objA") + +; CHECK: NULL + +; CHECK: DW_TAG_inlined_subroutine +; CHECK: DW_AT_abstract_origin {{.*}} "_Z3foov" +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin {{.*}} "objB" +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin {{.*}} "objA" +; CHECK: NULL + +%struc
[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)
dzhidzhoev commandeered this revision. dzhidzhoev added a reviewer: krisb. dzhidzhoev added a comment. See https://reviews.llvm.org/D143984#4341780 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144006/new/ https://reviews.llvm.org/D144006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)
dblaikie added inline comments. Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:712-714 + assert(!getAbstractScopeDIEs().count(DS) && + "Abstract DIE for this scope exists!"); + getAbstractScopeDIEs()[DS] = ScopeDIE; jmmartinez wrote: > krisb wrote: > > jmmartinez wrote: > > > NIT: You could use `insert/try_emplace` instead of using `count` and > > > `operator[]`. The assertion would become something like: > > > ``` > > > auto Inserted = getAbstractScopeDIEs().try_emplace(DS, ScopeDIE); > > > assert(Inserted.second && "Abstract DIE for this scope exists!"); > > > return ScopeDIE; > > > ``` > > I'd slightly prefer to keep the original code as it looks a bit more > > readable to me (in your example, there should be another line to void out > > unused `Inserted` variable, otherwise it'd cause a warning). > > Additional `count()` call in the `assert()` doesn't seem too expensive to > > me, but if you still think `try_emplace()` is better, I'll change to it. > Ok for me. If the use of count was outside the assert I would have argued > against. FWIW I'd lean towards avoiding the extra lookup in the +Asserts build (by using emplace or try_emplace, etc - yeah, with the extra void cast for the non-asserts-unused variable), but wouldn't insist on it. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144006/new/ https://reviews.llvm.org/D144006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)
jmmartinez accepted this revision. jmmartinez added inline comments. This revision is now accepted and ready to land. Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:712-714 + assert(!getAbstractScopeDIEs().count(DS) && + "Abstract DIE for this scope exists!"); + getAbstractScopeDIEs()[DS] = ScopeDIE; krisb wrote: > jmmartinez wrote: > > NIT: You could use `insert/try_emplace` instead of using `count` and > > `operator[]`. The assertion would become something like: > > ``` > > auto Inserted = getAbstractScopeDIEs().try_emplace(DS, ScopeDIE); > > assert(Inserted.second && "Abstract DIE for this scope exists!"); > > return ScopeDIE; > > ``` > I'd slightly prefer to keep the original code as it looks a bit more readable > to me (in your example, there should be another line to void out unused > `Inserted` variable, otherwise it'd cause a warning). > Additional `count()` call in the `assert()` doesn't seem too expensive to me, > but if you still think `try_emplace()` is better, I'll change to it. Ok for me. If the use of count was outside the assert I would have argued against. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144006/new/ https://reviews.llvm.org/D144006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)
krisb updated this revision to Diff 504608. krisb marked an inline comment as done. krisb added a comment. Apply review comments and rebase. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144006/new/ https://reviews.llvm.org/D144006 Files: clang/test/CodeGen/debug-info-codeview-unnamed.c clang/test/CodeGen/debug-info-unused-types.c clang/test/CodeGen/debug-info-unused-types.cpp clang/test/CodeGenCXX/debug-info-access.cpp clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp clang/test/CodeGenCXX/debug-lambda-this.cpp llvm/include/llvm/IR/DIBuilder.h llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/Verifier.cpp llvm/test/DebugInfo/Generic/inlined-local-type.ll llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll llvm/test/DebugInfo/Generic/lexical-block-types.ll llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll llvm/test/DebugInfo/X86/set.ll Index: llvm/test/DebugInfo/X86/set.ll === --- llvm/test/DebugInfo/X86/set.ll +++ llvm/test/DebugInfo/X86/set.ll @@ -68,11 +68,11 @@ !llvm.module.flags = !{!18, !19, !20} !0 = !{!"versions- cm3: d5.10.0 llvm: 9.0"} -!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3) +!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) !2 = !DIFile(filename: "Main.m3", directory: "/home/cm3/settest/src") !3 = !{!4} !4 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", scope: !5, file: !2, line: 11, size: 8, align: 8, elements: !9) -!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !8) +!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !3) !6 = !DISubroutineType(types: !7) !7 = !{null} !8 = !{} Index: llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll === --- llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll +++ llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll @@ -38,7 +38,7 @@ define void @invalid_retained_nodes_list() !dbg !10 { ret void } !10 = distinct !DISubprogram(retainedNodes: !0) -; CHECK: invalid retained nodes, expected DILocalVariable, DILabel or DIImportedEntity +; CHECK: invalid retained nodes, expected DILocalVariable, DILabel, DIImportedEntity or DIType define void @invalid_retained_nodes_expected() !dbg !11 { ret void } !11 = distinct !DISubprogram(retainedNodes: !{!0}) Index: llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll @@ -0,0 +1,160 @@ +; RUN: %llc_dwarf -O0 -filetype=obj < %s \ +; RUN: | llvm-dwarfdump --show-children --name=foo - \ +; RUN: | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s + +; The test ensures that AsmPrinter doesn't crashed compiling this. +; It also demostrates misplacement for a local type (see PR55680 for details). + +; The test compiled from: + +; template +; struct A { +; A(T &in) : a(in) {} +; T a; +; }; +; +; __attribute__((always_inline)) +; void foo() { +; struct B { int i; }; +; B objB; +; A objA(objB); +; } +; +; int main() { +; foo(); +; } + +; Concrete out-of-line tree of foo(). +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_abstract_origin {{.*}} "_Z3foov" +; +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin {{.*}} "objB" +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin {{.*}} "objA" + +; FIXME: 'struct B' should be in the abstract tree below, not here. +; CHECK: DW_TAG_structure_type +; CHECK: DW_AT_name ("B") +; CHECK: DW_TAG_member +; CHECK: NULL + +; CHECK: NULL + +; Abstract tree of foo(). +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_name ("foo") +; CHECK: DW_AT_inline (DW_INL_inlined) + +; CHECK: DW_TAG_variable +; CHECK: DW_AT_name ("objB") +; CHECK: DW_TAG_variable +; CHECK: DW_AT_name ("objA") + +; CHECK: NULL + +; CHECK: DW_TAG_inlined_subroutine +; CHECK: DW_AT_abstract_origin {{.*}} "_Z3foov" +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin {{.*}} "objB" +; CHECK: DW_TAG_variable +; CHECK: DW_AT_a
[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)
krisb marked 2 inline comments as done. krisb added inline comments. Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:698 + // an inlined function: if a local variable has a templated type with + // a function-local type as a template parameter. See PR55680 for details. + if (!Scope->isAbstractScope() && !Scope->getInlinedAt()) { jmmartinez wrote: > I cannot find the link to PR55680. Would you mind sharing it? > > You could also reference `local-type-as-template-parameter.ll`, your test > depicts the issue very clearly. > I cannot find the link to PR55680. Would you mind sharing it? > > You could also reference `local-type-as-template-parameter.ll`, your test > depicts the issue very clearly. Here is the link to the issue https://github.com/llvm/llvm-project/issues/55680. Mentioned the test in the comment. Thank you! Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:712-714 + assert(!getAbstractScopeDIEs().count(DS) && + "Abstract DIE for this scope exists!"); + getAbstractScopeDIEs()[DS] = ScopeDIE; jmmartinez wrote: > NIT: You could use `insert/try_emplace` instead of using `count` and > `operator[]`. The assertion would become something like: > ``` > auto Inserted = getAbstractScopeDIEs().try_emplace(DS, ScopeDIE); > assert(Inserted.second && "Abstract DIE for this scope exists!"); > return ScopeDIE; > ``` I'd slightly prefer to keep the original code as it looks a bit more readable to me (in your example, there should be another line to void out unused `Inserted` variable, otherwise it'd cause a warning). Additional `count()` call in the `assert()` doesn't seem too expensive to me, but if you still think `try_emplace()` is better, I'll change to it. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144006/new/ https://reviews.llvm.org/D144006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)
jmmartinez added a comment. Just a few minor comments. Everything else seems good to me. Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:698 + // an inlined function: if a local variable has a templated type with + // a function-local type as a template parameter. See PR55680 for details. + if (!Scope->isAbstractScope() && !Scope->getInlinedAt()) { I cannot find the link to PR55680. Would you mind sharing it? You could also reference `local-type-as-template-parameter.ll`, your test depicts the issue very clearly. Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:700-701 + if (!Scope->isAbstractScope() && !Scope->getInlinedAt()) { +if (LexicalBlockDIEs.count(DS)) { + ScopeDIE = LexicalBlockDIEs[DS]; + assert(!ScopeDIE->findAttribute(dwarf::DW_AT_low_pc) && NIT: You could use `find` to avoid searching in `LexicalBlockDIEs` twice. Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:712-714 + assert(!getAbstractScopeDIEs().count(DS) && + "Abstract DIE for this scope exists!"); + getAbstractScopeDIEs()[DS] = ScopeDIE; NIT: You could use `insert/try_emplace` instead of using `count` and `operator[]`. The assertion would become something like: ``` auto Inserted = getAbstractScopeDIEs().try_emplace(DS, ScopeDIE); assert(Inserted.second && "Abstract DIE for this scope exists!"); return ScopeDIE; ``` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144006/new/ https://reviews.llvm.org/D144006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)
krisb created this revision. Herald added a subscriber: hiraditya. Herald added a project: All. krisb edited the summary of this revision. krisb added reviewers: dblaikie, jmmartinez. krisb added projects: LLVM, debug-info. krisb published this revision for review. Herald added a project: clang. Herald added subscribers: llvm-commits, cfe-commits. RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Similar to imported declarations, the patch tracks function-local types in DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance with the aforementioned metadata change and provided a support of function-local types scoped within a lexical block. The patch assumes that DICompileUnit's 'enums field' no longer tracks local types and DwarfDebug would assert if any locally-scoped types get placed there. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144006 Files: clang/test/CodeGen/debug-info-codeview-unnamed.c clang/test/CodeGen/debug-info-unused-types.c clang/test/CodeGen/debug-info-unused-types.cpp clang/test/CodeGenCXX/debug-info-access.cpp clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp clang/test/CodeGenCXX/debug-lambda-this.cpp llvm/include/llvm/IR/DIBuilder.h llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/Verifier.cpp llvm/test/DebugInfo/Generic/inlined-local-type.ll llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll llvm/test/DebugInfo/Generic/lexical-block-types.ll llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll llvm/test/DebugInfo/X86/set.ll Index: llvm/test/DebugInfo/X86/set.ll === --- llvm/test/DebugInfo/X86/set.ll +++ llvm/test/DebugInfo/X86/set.ll @@ -68,11 +68,11 @@ !llvm.module.flags = !{!18, !19, !20} !0 = !{!"versions- cm3: d5.10.0 llvm: 9.0"} -!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3) +!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) !2 = !DIFile(filename: "Main.m3", directory: "/home/cm3/settest/src") !3 = !{!4} !4 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", scope: !5, file: !2, line: 11, size: 8, align: 8, elements: !9) -!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !8) +!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !3) !6 = !DISubroutineType(types: !7) !7 = !{null} !8 = !{} Index: llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll === --- llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll +++ llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll @@ -38,7 +38,7 @@ define void @invalid_retained_nodes_list() !dbg !10 { ret void } !10 = distinct !DISubprogram(retainedNodes: !0) -; CHECK: invalid retained nodes, expected DILocalVariable, DILabel or DIImportedEntity +; CHECK: invalid retained nodes, expected DILocalVariable, DILabel, DIImportedEntity or DIType define void @invalid_retained_nodes_expected() !dbg !11 { ret void } !11 = distinct !DISubprogram(retainedNodes: !{!0}) Index: llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll === --- /dev/null +++ llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll @@ -0,0 +1,160 @@ +; RUN: %llc_dwarf -O0 -filetype=obj < %s \ +; RUN: | llvm-dwarfdump --show-children --name=foo - \ +; RUN: | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s + +; The test ensures that AsmPrinter doesn't crashed compiling this. +; It also demostrates misplacement for a local type (see PR55680 for details). + +; The test compiled from: + +; template +; struct A { +; A(T &in) : a(in) {} +; T a; +; }; +; +; __attribute__((always_inline)) +; void foo() { +; struct B { int i; }; +; B objB; +; A objA(objB); +; } +; +; int main() { +; foo(); +; } + +; Concrete out-of-line tree of foo(). +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_abstract_origin {{.*}} "_Z3foov" +; +; CHECK: DW_TAG_variable +; CHECK: DW_AT_abstract_origin {{.*}} "objB" +; CHECK: DW_TAG_variable +; CHECK: D