Emit correct linkage-name attribute based on DWARF version.

There are still 4 tests that check for DW_AT_MIPS_linkage_name,
because they specify DWARF 2 or 3 in the module metadata. So, I didn't
create an explicit version-based test for the attribute.

Differential Revision: http://reviews.llvm.org/D8227


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231880 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Paul Robinson
2015-03-10 22:44:45 +00:00
parent 7c7b72a066
commit 107918efa2
16 changed files with 34 additions and 32 deletions

View File

@ -759,6 +759,15 @@ void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, bool Unsigned) {
addBlock(Die, dwarf::DW_AT_const_value, Block);
}
// Add a linkage name to the DIE.
void DwarfUnit::addLinkageName(DIE &Die, StringRef LinkageName) {
if (!LinkageName.empty())
addString(Die,
DD->getDwarfVersion() >= 4 ? dwarf::DW_AT_linkage_name
: dwarf::DW_AT_MIPS_linkage_name,
GlobalValue::getRealLinkageName(LinkageName));
}
/// addTemplateParams - Add template parameters into buffer.
void DwarfUnit::addTemplateParams(DIE &Buffer, DIArray TParams) {
// Add template parameters.
@ -1278,9 +1287,8 @@ bool DwarfUnit::applySubprogramDefinitionAttributes(DISubprogram SP,
assert(((LinkageName.empty() || DeclLinkageName.empty()) ||
LinkageName == DeclLinkageName) &&
"decl has a linkage name and it is different");
if (!LinkageName.empty() && DeclLinkageName.empty())
addString(SPDie, dwarf::DW_AT_MIPS_linkage_name,
GlobalValue::getRealLinkageName(LinkageName));
if (DeclLinkageName.empty())
addLinkageName(SPDie, LinkageName);
if (!DeclDie)
return false;