[llvm] 24c3dab - DebugInfo: Emit class template parameters first, before members

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 21:42:13 PDT 2020


Author: David Blaikie
Date: 2020-08-17T21:42:00-07:00
New Revision: 24c3dabef4436ec6436fb80e0672577ec52159ba

URL: https://github.com/llvm/llvm-project/commit/24c3dabef4436ec6436fb80e0672577ec52159ba
DIFF: https://github.com/llvm/llvm-project/commit/24c3dabef4436ec6436fb80e0672577ec52159ba.diff

LOG: 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.

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    llvm/test/DebugInfo/Generic/template-recursive-void.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 3dfd57c82f89..11729842ff71 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 0b70f218b356..4718b7a15911 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"
 


        


More information about the llvm-commits mailing list