[llvm] r193002 - Debug Info: add a newly-created DIE to a parent in the same function.

Manman Ren manman.ren at gmail.com
Fri Oct 18 14:14:19 PDT 2013


Author: mren
Date: Fri Oct 18 16:14:19 2013
New Revision: 193002

URL: http://llvm.org/viewvc/llvm-project?rev=193002&view=rev
Log:
Debug Info: add a newly-created DIE to a parent in the same function.

With this commit, all DIEs created in CompileUnit will be added to parents
inside the same function. Also make getOrCreateTemplateType|Value functions
private.

No functionality change.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=193002&r1=193001&r2=193002&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Fri Oct 18 16:14:19 2013
@@ -782,11 +782,11 @@ void CompileUnit::addTemplateParams(DIE
   for (unsigned i = 0, e = TParams.getNumElements(); i != e; ++i) {
     DIDescriptor Element = TParams.getElement(i);
     if (Element.isTemplateTypeParameter())
-      Buffer.addChild(getOrCreateTemplateTypeParameterDIE(
-                        DITemplateTypeParameter(Element)));
+      getOrCreateTemplateTypeParameterDIE(
+                        DITemplateTypeParameter(Element), Buffer);
     else if (Element.isTemplateValueParameter())
-      Buffer.addChild(getOrCreateTemplateValueParameterDIE(
-                        DITemplateValueParameter(Element)));
+      getOrCreateTemplateValueParameterDIE(
+                        DITemplateValueParameter(Element), Buffer);
   }
 }
 
@@ -1084,10 +1084,8 @@ void CompileUnit::constructTypeDIE(DIE &
     for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
       DIE *ElemDie = NULL;
       DIDescriptor Enum(Elements.getElement(i));
-      if (Enum.isEnumerator()) {
-        ElemDie = constructEnumTypeDIE(DIEnumerator(Enum));
-        Buffer.addChild(ElemDie);
-      }
+      if (Enum.isEnumerator())
+        ElemDie = constructEnumTypeDIE(DIEnumerator(Enum), Buffer);
     }
     DIType DTy = resolve(CTy.getTypeDerivedFrom());
     if (DTy) {
@@ -1161,8 +1159,7 @@ void CompileUnit::constructTypeDIE(DIE &
         } else if (DDTy.isStaticMember()) {
           ElemDie = getOrCreateStaticMemberDIE(DDTy);
         } else {
-          ElemDie = createMemberDIE(DDTy);
-          Buffer.addChild(ElemDie);
+          ElemDie = createMemberDIE(DDTy, Buffer);
         }
       } else if (Element.isObjCProperty()) {
         DIObjCProperty Property(Element);
@@ -1267,12 +1264,14 @@ void CompileUnit::constructTypeDIE(DIE &
 /// getOrCreateTemplateTypeParameterDIE - Find existing DIE or create new DIE
 /// for the given DITemplateTypeParameter.
 DIE *
-CompileUnit::getOrCreateTemplateTypeParameterDIE(DITemplateTypeParameter TP) {
+CompileUnit::getOrCreateTemplateTypeParameterDIE(DITemplateTypeParameter TP,
+                                                 DIE &Buffer) {
   DIE *ParamDIE = getDIE(TP);
   if (ParamDIE)
     return ParamDIE;
 
   ParamDIE = new DIE(dwarf::DW_TAG_template_type_parameter);
+  Buffer.addChild(ParamDIE);
   // Add the type if it exists, it could be void and therefore no type.
   if (TP.getType())
     addType(ParamDIE, resolve(TP.getType()));
@@ -1284,12 +1283,14 @@ CompileUnit::getOrCreateTemplateTypePara
 /// getOrCreateTemplateValueParameterDIE - Find existing DIE or create new DIE
 /// for the given DITemplateValueParameter.
 DIE *
-CompileUnit::getOrCreateTemplateValueParameterDIE(DITemplateValueParameter VP) {
+CompileUnit::getOrCreateTemplateValueParameterDIE(DITemplateValueParameter VP,
+                                                  DIE &Buffer) {
   DIE *ParamDIE = getDIE(VP);
   if (ParamDIE)
     return ParamDIE;
 
   ParamDIE = new DIE(VP.getTag());
+  Buffer.addChild(ParamDIE);
 
   // Add the type if there is one, template template and template parameter
   // packs will not have a type.
@@ -1681,8 +1682,9 @@ void CompileUnit::constructArrayTypeDIE(
 }
 
 /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
-DIE *CompileUnit::constructEnumTypeDIE(DIEnumerator ETy) {
+DIE *CompileUnit::constructEnumTypeDIE(DIEnumerator ETy, DIE &Buffer) {
   DIE *Enumerator = new DIE(dwarf::DW_TAG_enumerator);
+  Buffer.addChild(Enumerator);
   StringRef Name = ETy.getName();
   addString(Enumerator, dwarf::DW_AT_name, Name);
   int64_t Value = ETy.getEnumValue();
@@ -1779,8 +1781,9 @@ DIE *CompileUnit::constructVariableDIE(D
 }
 
 /// createMemberDIE - Create new member DIE.
-DIE *CompileUnit::createMemberDIE(DIDerivedType DT) {
+DIE *CompileUnit::createMemberDIE(DIDerivedType DT, DIE &Buffer) {
   DIE *MemberDie = new DIE(DT.getTag());
+  Buffer.addChild(MemberDie);
   StringRef Name = DT.getName();
   if (!Name.empty())
     addString(MemberDie, dwarf::DW_AT_name, Name);

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=193002&r1=193001&r2=193002&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Fri Oct 18 16:14:19 2013
@@ -290,14 +290,6 @@ public:
   /// given DIType.
   DIE *getOrCreateTypeDIE(const MDNode *N);
 
-  /// getOrCreateTemplateTypeParameterDIE - Find existing DIE or create new DIE
-  /// for the given DITemplateTypeParameter.
-  DIE *getOrCreateTemplateTypeParameterDIE(DITemplateTypeParameter TP);
-
-  /// getOrCreateTemplateValueParameterDIE - Find existing DIE or create
-  /// new DIE for the given DITemplateValueParameter.
-  DIE *getOrCreateTemplateValueParameterDIE(DITemplateValueParameter TVP);
-
   /// getOrCreateContextDIE - Get context owner's DIE.
   DIE *getOrCreateContextDIE(DIScope Context);
 
@@ -328,10 +320,20 @@ private:
   void constructArrayTypeDIE(DIE &Buffer, DICompositeType *CTy);
 
   /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
-  DIE *constructEnumTypeDIE(DIEnumerator ETy);
+  DIE *constructEnumTypeDIE(DIEnumerator ETy, DIE &Buffer);
 
   /// createMemberDIE - Create new member DIE.
-  DIE *createMemberDIE(DIDerivedType DT);
+  DIE *createMemberDIE(DIDerivedType DT, DIE &Buffer);
+
+  /// getOrCreateTemplateTypeParameterDIE - Find existing DIE or create new DIE
+  /// for the given DITemplateTypeParameter.
+  DIE *getOrCreateTemplateTypeParameterDIE(DITemplateTypeParameter TP,
+                                           DIE &Buffer);
+
+  /// getOrCreateTemplateValueParameterDIE - Find existing DIE or create
+  /// new DIE for the given DITemplateValueParameter.
+  DIE *getOrCreateTemplateValueParameterDIE(DITemplateValueParameter TVP,
+                                            DIE &Buffer);
 
   /// getOrCreateStaticMemberDIE - Create new static data member DIE.
   DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);





More information about the llvm-commits mailing list