Change global descriptor names to provide name, full name and linkage name.
authorJim Laskey <jlaskey@mac.com>
Thu, 30 Nov 2006 14:35:45 +0000 (14:35 +0000)
committerJim Laskey <jlaskey@mac.com>
Thu, 30 Nov 2006 14:35:45 +0000 (14:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32036 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineDebugInfo.h
lib/CodeGen/DwarfWriter.cpp
lib/CodeGen/MachineDebugInfo.cpp

index 46078d25efa0b609b282b722140f99315650a3fd..aa968f49a80f1e711e9e1d7569f6b6ae2d3ca39e 100644 (file)
@@ -53,7 +53,8 @@ class StructType;
 // Debug info constants.
 
 enum {
-  LLVMDebugVersion = (5 << 16),         // Current version of debug information.
+  LLVMDebugVersion = (6 << 16),         // Current version of debug information.
+  LLVMDebugVersion5 = (5 << 16),        // Constant for version 5.
   LLVMDebugVersion4 = (4 << 16),        // Constant for version 4.
   LLVMDebugVersionMask = 0xffff0000     // Mask for version number.
 };
@@ -582,7 +583,8 @@ class GlobalDesc : public AnchoredDesc {
 private:
   DebugInfoDesc *Context;               // Context debug descriptor.
   std::string Name;                     // Global name.
-  std::string DisplayName;              // C++ unmangled name.
+  std::string FullName;                 // Fully qualified name.
+  std::string LinkageName;              // Name for binding to MIPS linkage.
   DebugInfoDesc *File;                  // Defined compile unit (may be NULL.)
   unsigned Line;                        // Defined line# (may be zero.)
   DebugInfoDesc *TyDesc;                // Type debug descriptor.
@@ -596,7 +598,8 @@ public:
   // Accessors
   DebugInfoDesc *getContext()                const { return Context; }
   const std::string &getName()               const { return Name; }
-  const std::string &getDisplayName()        const { return DisplayName; }
+  const std::string &getFullName()           const { return FullName; }
+  const std::string &getLinkageName()        const { return LinkageName; }
   CompileUnitDesc *getFile() const {
     return static_cast<CompileUnitDesc *>(File);
   }
@@ -608,7 +611,8 @@ public:
   bool isDefinition()                        const { return IsDefinition; }
   void setContext(DebugInfoDesc *C)                { Context = C; }
   void setName(const std::string &N)               { Name = N; }
-  void setDisplayName(const std::string &N)        { DisplayName = N; }
+  void setFullName(const std::string &N)           { FullName = N; }
+  void setLinkageName(const std::string &N)        { LinkageName = N; }
   void setFile(CompileUnitDesc *U) {
     File = static_cast<DebugInfoDesc *>(U);
   }
@@ -618,9 +622,6 @@ public:
   }
   void setIsStatic(bool IS)                        { IsStatic = IS; }
   void setIsDefinition(bool ID)                    { IsDefinition = ID; }
-  bool hasMangledName()                      const {
-    return !DisplayName.empty();
-  }
 
   /// ApplyToFields - Target the visitor to the fields of the GlobalDesc.
   ///
index f76316937d8f29acc590be5d0ce5411d5c45276a..5058ccaa2cb814efffc6b7f4ea9063d01f4d59dc 100644 (file)
@@ -1587,11 +1587,13 @@ private:
             DIE *Static = new DIE(DW_TAG_variable);
             
             // Add name and mangled name.
-            const std::string &Name = StaticDesc->getDisplayName();
-            const std::string &MangledName = StaticDesc->getName();
+            const std::string &Name = StaticDesc->getName();
+            const std::string &LinkageName = StaticDesc->getLinkageName();
             AddString(Static, DW_AT_name, DW_FORM_string, Name);
-            AddString(Static, DW_AT_MIPS_linkage_name, DW_FORM_string,
-                              MangledName);
+            if (!LinkageName.empty()) {
+              AddString(Static, DW_AT_MIPS_linkage_name, DW_FORM_string,
+                                LinkageName);
+            }
             
             // Add location.
             AddSourceLine(Static, StaticDesc->getFile(), StaticDesc->getLine());
@@ -1613,17 +1615,15 @@ private:
             DIE *Method = new DIE(DW_TAG_subprogram);
            
             // Add name and mangled name.
-            const std::string &Name = MethodDesc->getDisplayName();
-            const std::string &MangledName = MethodDesc->getName();
-            bool IsCTor = false;
+            const std::string &Name = MethodDesc->getName();
+            const std::string &LinkageName = MethodDesc->getLinkageName();
+            
+            AddString(Method, DW_AT_name, DW_FORM_string, Name);            
+            bool IsCTor = TyDesc->getName() == Name;
             
-            if (Name.empty()) {
-              AddString(Method, DW_AT_name, DW_FORM_string, MangledName);            
-              IsCTor = TyDesc->getName() == MangledName;
-            } else {
-              AddString(Method, DW_AT_name, DW_FORM_string, Name);            
+            if (!LinkageName.empty()) {
               AddString(Method, DW_AT_MIPS_linkage_name, DW_FORM_string,
-                                MangledName);
+                                LinkageName);
             }
             
             // Add location.
@@ -1752,16 +1752,15 @@ private:
     // Get the global variable itself.
     GlobalVariable *GV = GVD->getGlobalVariable();
 
-    const std::string &Name = GVD->hasMangledName() ? GVD->getDisplayName()
-                                                    : GVD->getName();
-    const std::string &MangledName = GVD->hasMangledName() ? GVD->getName()
-                                                           : "";
+    const std::string &Name = GVD->getName();
+    const std::string &FullName = GVD->getFullName();
+    const std::string &LinkageName = GVD->getLinkageName();
     // Create the global's variable DIE.
     DIE *VariableDie = new DIE(DW_TAG_variable);
     AddString(VariableDie, DW_AT_name, DW_FORM_string, Name);
-    if (!MangledName.empty()) {
+    if (!LinkageName.empty()) {
       AddString(VariableDie, DW_AT_MIPS_linkage_name, DW_FORM_string,
-                             MangledName);
+                             LinkageName);
     }
     AddType(VariableDie, GVD->getType(), Unit); 
     AddUInt(VariableDie, DW_AT_external, DW_FORM_flag, 1);
@@ -1769,14 +1768,11 @@ private:
     // Add source line info if available.
     AddSourceLine(VariableDie, UnitDesc, GVD->getLine());
     
-    // Work up linkage name.
-    const std::string LinkageName = Asm->getGlobalLinkName(GV);
-
     // Add address.
     DIEBlock *Block = new DIEBlock();
     AddUInt(Block, 0, DW_FORM_data1, DW_OP_addr);
-    AddObjectLabel(Block, 0, DW_FORM_udata, LinkageName);
-    AddBlock(VariableDie, DW_AT_location,  0, Block);
+    AddObjectLabel(Block, 0, DW_FORM_udata, Asm->getGlobalLinkName(GV));
+    AddBlock(VariableDie, DW_AT_location, 0, Block);
     
     // Add to map.
     Slot = VariableDie;
@@ -1786,7 +1782,7 @@ private:
     
     // Expose as global.
     // FIXME - need to check external flag.
-    Unit->AddGlobal(Name, VariableDie);
+    Unit->AddGlobal(FullName, VariableDie);
     
     return VariableDie;
   }
@@ -1804,17 +1800,16 @@ private:
     if (Slot) return Slot;
     
     // Gather the details (simplify add attribute code.)
-    const std::string &Name = SPD->hasMangledName() ? SPD->getDisplayName()
-                                                    : SPD->getName();
-    const std::string &MangledName = SPD->hasMangledName() ? SPD->getName()
-                                                           : "";
+    const std::string &Name = SPD->getName();
+    const std::string &FullName = SPD->getFullName();
+    const std::string &LinkageName = SPD->getLinkageName();
     unsigned IsExternal = SPD->isStatic() ? 0 : 1;
                                       
     DIE *SubprogramDie = new DIE(DW_TAG_subprogram);
     AddString(SubprogramDie, DW_AT_name, DW_FORM_string, Name);
-    if (!MangledName.empty()) {
+    if (!LinkageName.empty()) {
       AddString(SubprogramDie, DW_AT_MIPS_linkage_name, DW_FORM_string,
-                               MangledName);
+                               LinkageName);
     }
     if (SPD->getType()) AddType(SubprogramDie, SPD->getType(), Unit);
     AddUInt(SubprogramDie, DW_AT_external, DW_FORM_flag, IsExternal);
@@ -1830,7 +1825,7 @@ private:
     Unit->getDie()->AddChild(SubprogramDie);
     
     // Expose as global.
-    Unit->AddGlobal(Name, SubprogramDie);
+    Unit->AddGlobal(FullName, SubprogramDie);
     
     return SubprogramDie;
   }
index 16f8dc8e20aeedfa91b42e25868ddab040c4a6ad..f6de1046fae6dddf528c2223aa99815a818a0745 100644 (file)
@@ -1048,7 +1048,8 @@ GlobalDesc::GlobalDesc(unsigned T)
 : AnchoredDesc(T)
 , Context(0)
 , Name("")
-, DisplayName("")
+, FullName("")
+, LinkageName("")
 , File(NULL)
 , Line(0)
 , TyDesc(NULL)
@@ -1063,7 +1064,8 @@ void GlobalDesc::ApplyToFields(DIVisitor *Visitor) {
 
   Visitor->Apply(Context);
   Visitor->Apply(Name);
-  if (getVersion() > LLVMDebugVersion4) Visitor->Apply(DisplayName);
+  Visitor->Apply(FullName);
+  Visitor->Apply(LinkageName);
   Visitor->Apply(File);
   Visitor->Apply(Line);
   Visitor->Apply(TyDesc);
@@ -1117,7 +1119,8 @@ void GlobalVariableDesc::dump() {
             << "Tag(" << getTag() << "), "
             << "Anchor(" << getAnchor() << "), "
             << "Name(\"" << getName() << "\"), "
-            << "DisplayName(\"" << getDisplayName() << "\"), "
+            << "FullName(\"" << getFullName() << "\"), "
+            << "LinkageName(\"" << getLinkageName() << "\"), "
             << "File(" << getFile() << "),"
             << "Line(" << getLine() << "),"
             << "Type(" << getType() << "), "
@@ -1170,7 +1173,8 @@ void SubprogramDesc::dump() {
             << "Tag(" << getTag() << "), "
             << "Anchor(" << getAnchor() << "), "
             << "Name(\"" << getName() << "\"), "
-            << "DisplayName(\"" << getDisplayName() << "\"), "
+            << "FullName(\"" << getFullName() << "\"), "
+            << "LinkageName(\"" << getLinkageName() << "\"), "
             << "File(" << getFile() << "),"
             << "Line(" << getLine() << "),"
             << "Type(" << getType() << "), "