mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 23:32:27 +00:00
Move getRealLinkageName to a common place and remove all the duplicates of it.
Also simplify code a bit while there. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183076 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6dd56e60b0
commit
7c2b4be2a7
@ -239,6 +239,15 @@ public:
|
||||
/// create a GlobalValue) from the GlobalValue Src to this one.
|
||||
virtual void copyAttributesFrom(const GlobalValue *Src);
|
||||
|
||||
/// getRealLinkageName - If special LLVM prefix that is used to inform the asm
|
||||
/// printer to not emit usual symbol prefix before the symbol name is used
|
||||
/// then return linkage name after skipping this special LLVM prefix.
|
||||
static StringRef getRealLinkageName(StringRef Name) {
|
||||
if (!Name.empty() && Name[0] == '\1')
|
||||
return Name.substr(1);
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// @name Materialization
|
||||
/// Materialization is used to construct functions only as they're needed. This
|
||||
/// is useful to reduce memory usage in LLVM or parsing work done by the
|
||||
|
@ -1133,16 +1133,6 @@ DIE *CompileUnit::getOrCreateNameSpace(DINameSpace NS) {
|
||||
return NDie;
|
||||
}
|
||||
|
||||
/// getRealLinkageName - If special LLVM prefix that is used to inform the asm
|
||||
/// printer to not emit usual symbol prefix before the symbol name is used then
|
||||
/// return linkage name after skipping this special LLVM prefix.
|
||||
static StringRef getRealLinkageName(StringRef LinkageName) {
|
||||
char One = '\1';
|
||||
if (LinkageName.startswith(StringRef(&One, 1)))
|
||||
return LinkageName.substr(1);
|
||||
return LinkageName;
|
||||
}
|
||||
|
||||
/// getOrCreateSubprogramDIE - Create new DIE using SP.
|
||||
DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
|
||||
DIE *SPDie = getDIE(SP);
|
||||
@ -1175,7 +1165,7 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
|
||||
StringRef LinkageName = SP.getLinkageName();
|
||||
if (!LinkageName.empty() && DD->useDarwinGDBCompat())
|
||||
addString(SPDie, dwarf::DW_AT_MIPS_linkage_name,
|
||||
getRealLinkageName(LinkageName));
|
||||
GlobalValue::getRealLinkageName(LinkageName));
|
||||
|
||||
// If this DIE is going to refer declaration info using AT_specification
|
||||
// then there is no need to add other attributes.
|
||||
@ -1190,7 +1180,7 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
|
||||
// Add the linkage name if we have one.
|
||||
if (!LinkageName.empty() && !DD->useDarwinGDBCompat())
|
||||
addString(SPDie, dwarf::DW_AT_MIPS_linkage_name,
|
||||
getRealLinkageName(LinkageName));
|
||||
GlobalValue::getRealLinkageName(LinkageName));
|
||||
|
||||
// Constructors and operators for anonymous aggregates do not have names.
|
||||
if (!SP.getName().empty())
|
||||
@ -1367,12 +1357,12 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) {
|
||||
// TAG_variable.
|
||||
addString(IsStaticMember && VariableSpecDIE ?
|
||||
VariableSpecDIE : VariableDIE, dwarf::DW_AT_MIPS_linkage_name,
|
||||
getRealLinkageName(LinkageName));
|
||||
GlobalValue::getRealLinkageName(LinkageName));
|
||||
// In compatibility mode with older gdbs we put the linkage name on both
|
||||
// the TAG_variable DIE and on the TAG_member DIE.
|
||||
if (IsStaticMember && VariableSpecDIE && DD->useDarwinGDBCompat())
|
||||
addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name,
|
||||
getRealLinkageName(LinkageName));
|
||||
GlobalValue::getRealLinkageName(LinkageName));
|
||||
}
|
||||
} else if (const ConstantInt *CI =
|
||||
dyn_cast_or_null<ConstantInt>(GV.getConstant())) {
|
||||
|
@ -279,16 +279,6 @@ void DwarfUnits::assignAbbrevNumber(DIEAbbrev &Abbrev) {
|
||||
}
|
||||
}
|
||||
|
||||
// If special LLVM prefix that is used to inform the asm
|
||||
// printer to not emit usual symbol prefix before the symbol name is used then
|
||||
// return linkage name after skipping this special LLVM prefix.
|
||||
static StringRef getRealLinkageName(StringRef LinkageName) {
|
||||
char One = '\1';
|
||||
if (LinkageName.startswith(StringRef(&One, 1)))
|
||||
return LinkageName.substr(1);
|
||||
return LinkageName;
|
||||
}
|
||||
|
||||
static bool isObjCClass(StringRef Name) {
|
||||
return Name.startswith("+") || Name.startswith("-");
|
||||
}
|
||||
@ -2564,9 +2554,9 @@ void DwarfDebug::emitDebugInlineInfo() {
|
||||
Asm->EmitSectionOffset(InfoHolder.getStringPoolEntry(Name),
|
||||
DwarfStrSectionSym);
|
||||
else
|
||||
Asm->EmitSectionOffset(InfoHolder
|
||||
.getStringPoolEntry(getRealLinkageName(LName)),
|
||||
DwarfStrSectionSym);
|
||||
Asm->EmitSectionOffset(
|
||||
InfoHolder.getStringPoolEntry(Function::getRealLinkageName(LName)),
|
||||
DwarfStrSectionSym);
|
||||
|
||||
Asm->OutStreamer.AddComment("Function name");
|
||||
Asm->EmitSectionOffset(InfoHolder.getStringPoolEntry(Name),
|
||||
|
@ -764,12 +764,20 @@ DIArray DICompileUnit::getImportedEntities() const {
|
||||
return DIArray();
|
||||
}
|
||||
|
||||
/// fixupObjcLikeName - Replace contains special characters used
|
||||
/// fixupSubprogramName - Replace contains special characters used
|
||||
/// in a typical Objective-C names with '.' in a given string.
|
||||
static void fixupObjcLikeName(StringRef Str, SmallVectorImpl<char> &Out) {
|
||||
static void fixupSubprogramName(DISubprogram Fn, SmallVectorImpl<char> &Out) {
|
||||
StringRef FName =
|
||||
Fn.getFunction() ? Fn.getFunction()->getName() : Fn.getName();
|
||||
FName = Function::getRealLinkageName(FName);
|
||||
|
||||
StringRef Prefix("llvm.dbg.lv.");
|
||||
Out.reserve(FName.size() + Prefix.size());
|
||||
Out.append(Prefix.begin(), Prefix.end());
|
||||
|
||||
bool isObjCLike = false;
|
||||
for (size_t i = 0, e = Str.size(); i < e; ++i) {
|
||||
char C = Str[i];
|
||||
for (size_t i = 0, e = FName.size(); i < e; ++i) {
|
||||
char C = FName[i];
|
||||
if (C == '[')
|
||||
isObjCLike = true;
|
||||
|
||||
@ -784,33 +792,16 @@ static void fixupObjcLikeName(StringRef Str, SmallVectorImpl<char> &Out) {
|
||||
/// getFnSpecificMDNode - Return a NameMDNode, if available, that is
|
||||
/// suitable to hold function specific information.
|
||||
NamedMDNode *llvm::getFnSpecificMDNode(const Module &M, DISubprogram Fn) {
|
||||
SmallString<32> Name = StringRef("llvm.dbg.lv.");
|
||||
StringRef FName = "fn";
|
||||
if (Fn.getFunction())
|
||||
FName = Fn.getFunction()->getName();
|
||||
else
|
||||
FName = Fn.getName();
|
||||
char One = '\1';
|
||||
if (FName.startswith(StringRef(&One, 1)))
|
||||
FName = FName.substr(1);
|
||||
fixupObjcLikeName(FName, Name);
|
||||
SmallString<32> Name;
|
||||
fixupSubprogramName(Fn, Name);
|
||||
return M.getNamedMetadata(Name.str());
|
||||
}
|
||||
|
||||
/// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
|
||||
/// to hold function specific information.
|
||||
NamedMDNode *llvm::getOrInsertFnSpecificMDNode(Module &M, DISubprogram Fn) {
|
||||
SmallString<32> Name = StringRef("llvm.dbg.lv.");
|
||||
StringRef FName = "fn";
|
||||
if (Fn.getFunction())
|
||||
FName = Fn.getFunction()->getName();
|
||||
else
|
||||
FName = Fn.getName();
|
||||
char One = '\1';
|
||||
if (FName.startswith(StringRef(&One, 1)))
|
||||
FName = FName.substr(1);
|
||||
fixupObjcLikeName(FName, Name);
|
||||
|
||||
SmallString<32> Name;
|
||||
fixupSubprogramName(Fn, Name);
|
||||
return M.getOrInsertNamedMetadata(Name.str());
|
||||
}
|
||||
|
||||
|
@ -332,16 +332,6 @@ bool StripDebugDeclare::runOnModule(Module &M) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// getRealLinkageName - If special LLVM prefix that is used to inform the asm
|
||||
/// printer to not emit usual symbol prefix before the symbol name is used then
|
||||
/// return linkage name after skipping this special LLVM prefix.
|
||||
static StringRef getRealLinkageName(StringRef LinkageName) {
|
||||
char One = '\1';
|
||||
if (LinkageName.startswith(StringRef(&One, 1)))
|
||||
return LinkageName.substr(1);
|
||||
return LinkageName;
|
||||
}
|
||||
|
||||
bool StripDeadDebugInfo::runOnModule(Module &M) {
|
||||
bool Changed = false;
|
||||
|
||||
@ -401,9 +391,8 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
|
||||
StringRef FName = DISubprogram(*I).getLinkageName();
|
||||
if (FName.empty())
|
||||
FName = DISubprogram(*I).getName();
|
||||
if (NamedMDNode *LVNMD =
|
||||
M.getNamedMetadata(Twine("llvm.dbg.lv.",
|
||||
getRealLinkageName(FName))))
|
||||
if (NamedMDNode *LVNMD = M.getNamedMetadata(
|
||||
"llvm.dbg.lv." + Function::getRealLinkageName(FName)))
|
||||
LVNMD->eraseFromParent();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user