From 24c3dabef4436ec6436fb80e0672577ec52159ba Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 17 Aug 2020 18:17:38 -0700 Subject: [PATCH] DebugInfo: Emit class template parameters first, before members This reads more like what you'd expect the DWARF to look like (from the lexical order of C++ - template parameters come before members, etc), and also happens to make it easier to tickle (& thus test) a bug related to type units and Split DWARF I'm about to fix. --- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 11 +++++------ .../test/DebugInfo/Generic/template-recursive-void.ll | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 3dfd57c82f89a..11729842ff710 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -891,6 +891,11 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) { } } + // Add template parameters to a class, structure or union types. + if (Tag == dwarf::DW_TAG_class_type || + Tag == dwarf::DW_TAG_structure_type || Tag == dwarf::DW_TAG_union_type) + addTemplateParams(Buffer, CTy->getTemplateParams()); + // Add elements to structure type. DINodeArray Elements = CTy->getElements(); for (const auto *Element : Elements) { @@ -960,12 +965,6 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) { if (CTy->isObjcClassComplete()) addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type); - // Add template parameters to a class, structure or union types. - // FIXME: The support isn't in the metadata for this yet. - if (Tag == dwarf::DW_TAG_class_type || - Tag == dwarf::DW_TAG_structure_type || Tag == dwarf::DW_TAG_union_type) - addTemplateParams(Buffer, CTy->getTemplateParams()); - // Add the type's non-standard calling convention. uint8_t CC = 0; if (CTy->isTypePassByValue()) diff --git a/llvm/test/DebugInfo/Generic/template-recursive-void.ll b/llvm/test/DebugInfo/Generic/template-recursive-void.ll index 0b70f218b3567..4718b7a159112 100644 --- a/llvm/test/DebugInfo/Generic/template-recursive-void.ll +++ b/llvm/test/DebugInfo/Generic/template-recursive-void.ll @@ -14,7 +14,7 @@ ; CHECK: DW_TAG_template_type_parameter [{{.*}}] ; CHECK-NEXT: DW_AT_name{{.*}}"T" ; CHECK-NOT: DW_AT_type -; CHECK: NULL +; CHECK: {{DW_TAG|NULL}} source_filename = "test/DebugInfo/Generic/template-recursive-void.ll"