mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 17:25:21 +00:00
Sort out mangled names for globals
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30460 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -622,6 +622,9 @@ public:
|
|||||||
}
|
}
|
||||||
void setIsStatic(bool IS) { IsStatic = IS; }
|
void setIsStatic(bool IS) { IsStatic = IS; }
|
||||||
void setIsDefinition(bool ID) { IsDefinition = ID; }
|
void setIsDefinition(bool ID) { IsDefinition = ID; }
|
||||||
|
bool hasMangledName() const {
|
||||||
|
return !DisplayName.empty();
|
||||||
|
}
|
||||||
|
|
||||||
/// ApplyToFields - Target the visitor to the fields of the GlobalDesc.
|
/// ApplyToFields - Target the visitor to the fields of the GlobalDesc.
|
||||||
///
|
///
|
||||||
|
@@ -1592,20 +1592,23 @@ DIE *DwarfWriter::NewGlobalVariable(GlobalVariableDesc *GVD) {
|
|||||||
|
|
||||||
// Get the global variable itself.
|
// Get the global variable itself.
|
||||||
GlobalVariable *GV = GVD->getGlobalVariable();
|
GlobalVariable *GV = GVD->getGlobalVariable();
|
||||||
// Generate the mangled name.
|
|
||||||
std::string MangledName = Asm->Mang->getValueName(GV);
|
|
||||||
|
|
||||||
// Gather the details (simplify add attribute code.)
|
const std::string &Name = GVD->hasMangledName() ? GVD->getDisplayName()
|
||||||
const std::string &Name = GVD->getName();
|
: GVD->getName();
|
||||||
|
const std::string &MangledName = GVD->hasMangledName() ? GVD->getName()
|
||||||
|
: "";
|
||||||
// Get the global's type.
|
// Get the global's type.
|
||||||
DIE *Type = NewType(Unit->getDie(), GVD->getType(), Unit);
|
DIE *Type = NewType(Unit->getDie(), GVD->getType(), Unit);
|
||||||
|
|
||||||
// Create the globale variable DIE.
|
// Create the globale variable DIE.
|
||||||
DIE *VariableDie = new DIE(DW_TAG_variable);
|
DIE *VariableDie = new DIE(DW_TAG_variable);
|
||||||
VariableDie->AddString (DW_AT_name, DW_FORM_string, Name);
|
VariableDie->AddString(DW_AT_name, DW_FORM_string, Name);
|
||||||
VariableDie->AddDIEntry (DW_AT_type, DW_FORM_ref4, Type);
|
if (!MangledName.empty()) {
|
||||||
VariableDie->AddUInt (DW_AT_external, DW_FORM_flag, 1);
|
VariableDie->AddString(DW_AT_MIPS_linkage_name, DW_FORM_string,
|
||||||
|
MangledName);
|
||||||
|
}
|
||||||
|
VariableDie->AddDIEntry(DW_AT_type, DW_FORM_ref4, Type);
|
||||||
|
VariableDie->AddUInt(DW_AT_external, DW_FORM_flag, 1);
|
||||||
|
|
||||||
// Add source line info if available.
|
// Add source line info if available.
|
||||||
AddSourceLine(VariableDie, UnitDesc, GVD->getLine());
|
AddSourceLine(VariableDie, UnitDesc, GVD->getLine());
|
||||||
@@ -1642,17 +1645,24 @@ DIE *DwarfWriter::NewSubprogram(SubprogramDesc *SPD) {
|
|||||||
if (Slot) return Slot;
|
if (Slot) return Slot;
|
||||||
|
|
||||||
// Gather the details (simplify add attribute code.)
|
// Gather the details (simplify add attribute code.)
|
||||||
const std::string &Name = SPD->getName();
|
const std::string &Name = SPD->hasMangledName() ? SPD->getDisplayName()
|
||||||
|
: SPD->getName();
|
||||||
|
const std::string &MangledName = SPD->hasMangledName() ? SPD->getName()
|
||||||
|
: "";
|
||||||
DIE *Type = NewType(Unit->getDie(), SPD->getType(), Unit);
|
DIE *Type = NewType(Unit->getDie(), SPD->getType(), Unit);
|
||||||
unsigned IsExternal = SPD->isStatic() ? 0 : 1;
|
unsigned IsExternal = SPD->isStatic() ? 0 : 1;
|
||||||
|
|
||||||
DIE *SubprogramDie = new DIE(DW_TAG_subprogram);
|
DIE *SubprogramDie = new DIE(DW_TAG_subprogram);
|
||||||
SubprogramDie->AddString (DW_AT_name, DW_FORM_string, Name);
|
SubprogramDie->AddString(DW_AT_name, DW_FORM_string, Name);
|
||||||
if (Type) {
|
if (!MangledName.empty()) {
|
||||||
SubprogramDie->AddDIEntry (DW_AT_type, DW_FORM_ref4, Type);
|
SubprogramDie->AddString(DW_AT_MIPS_linkage_name, DW_FORM_string,
|
||||||
|
MangledName);
|
||||||
}
|
}
|
||||||
SubprogramDie->AddUInt (DW_AT_external, DW_FORM_flag, IsExternal);
|
if (Type) {
|
||||||
SubprogramDie->AddUInt (DW_AT_prototyped, DW_FORM_flag, 1);
|
SubprogramDie->AddDIEntry(DW_AT_type, DW_FORM_ref4, Type);
|
||||||
|
}
|
||||||
|
SubprogramDie->AddUInt(DW_AT_external, DW_FORM_flag, IsExternal);
|
||||||
|
SubprogramDie->AddUInt(DW_AT_prototyped, DW_FORM_flag, 1);
|
||||||
|
|
||||||
// Add source line info if available.
|
// Add source line info if available.
|
||||||
AddSourceLine(SubprogramDie, UnitDesc, SPD->getLine());
|
AddSourceLine(SubprogramDie, UnitDesc, SPD->getLine());
|
||||||
|
Reference in New Issue
Block a user