mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[Debuginfo][NFC] Avoid double calling of DWARFDie::find(DW_AT_name).
Summary: Current implementation of DWARFDie::getName(DINameKind Kind) could lead to double call to DWARFDie::find(DW_AT_name) in following scenario: getName(LinkageName); getName(ShortName); getName(LinkageName) calls find(DW_AT_name) if linkage name is not found. Then, it is called again in getName(ShortName). This patch alows to request LinkageName and ShortName separately to avoid extra call to find(DW_AT_name). It helps D74169 to parse clang debuginfo faster(~1%). Reviewers: clayborg, dblaikie Differential Revision: https://reviews.llvm.org/D79173
This commit is contained in:
parent
3ba9d60e1f
commit
511ea0ddf5
@ -241,10 +241,22 @@ public:
|
||||
/// Returns null if no name is found.
|
||||
const char *getSubroutineName(DINameKind Kind) const;
|
||||
|
||||
/// Return the DIE name resolving DW_AT_sepcification or DW_AT_abstract_origin
|
||||
/// references if necessary. Returns null if no name is found.
|
||||
/// Return the DIE name resolving DW_AT_specification or DW_AT_abstract_origin
|
||||
/// references if necessary. For the LinkageName case it additionaly searches
|
||||
/// for ShortName if LinkageName is not found.
|
||||
/// Returns null if no name is found.
|
||||
const char *getName(DINameKind Kind) const;
|
||||
|
||||
/// Return the DIE short name resolving DW_AT_specification or
|
||||
/// DW_AT_abstract_origin references if necessary. Returns null if no name
|
||||
/// is found.
|
||||
const char *getShortName() const;
|
||||
|
||||
/// Return the DIE linkage name resolving DW_AT_specification or
|
||||
/// DW_AT_abstract_origin references if necessary. Returns null if no name
|
||||
/// is found.
|
||||
const char *getLinkageName() const;
|
||||
|
||||
/// Returns the declaration line (start line) for a DIE, assuming it specifies
|
||||
/// a subprogram. This may be fetched from specification or abstract origin
|
||||
/// for this subprogram by resolving DW_AT_sepcification or
|
||||
|
@ -160,16 +160,17 @@ bool DWARFLinker::DIECloner::getDIENames(const DWARFDie &Die,
|
||||
if (Die.getTag() == dwarf::DW_TAG_lexical_block)
|
||||
return false;
|
||||
|
||||
// FIXME: a bit wasteful as the first getName might return the
|
||||
// short name.
|
||||
if (!Info.MangledName)
|
||||
if (const char *MangledName = Die.getName(DINameKind::LinkageName))
|
||||
if (const char *MangledName = Die.getLinkageName())
|
||||
Info.MangledName = StringPool.getEntry(MangledName);
|
||||
|
||||
if (!Info.Name)
|
||||
if (const char *Name = Die.getName(DINameKind::ShortName))
|
||||
if (const char *Name = Die.getShortName())
|
||||
Info.Name = StringPool.getEntry(Name);
|
||||
|
||||
if (!Info.MangledName)
|
||||
Info.MangledName = Info.Name;
|
||||
|
||||
if (StripTemplate && Info.Name && Info.MangledName != Info.Name) {
|
||||
StringRef Name = Info.Name.getString();
|
||||
if (Optional<StringRef> StrippedName = StripTemplateParameters(Name))
|
||||
|
@ -80,8 +80,12 @@ PointerIntPair<DeclContext *, 1> DeclContextTree::getChildDeclContext(
|
||||
break;
|
||||
}
|
||||
|
||||
const char *Name = DIE.getName(DINameKind::LinkageName);
|
||||
const char *ShortName = DIE.getName(DINameKind::ShortName);
|
||||
const char *Name = DIE.getLinkageName();
|
||||
const char *ShortName = DIE.getShortName();
|
||||
|
||||
if (!Name)
|
||||
Name = ShortName;
|
||||
|
||||
StringRef NameRef;
|
||||
StringRef ShortNameRef;
|
||||
StringRef FileRef;
|
||||
|
@ -531,14 +531,26 @@ const char *DWARFDie::getName(DINameKind Kind) const {
|
||||
return nullptr;
|
||||
// Try to get mangled name only if it was asked for.
|
||||
if (Kind == DINameKind::LinkageName) {
|
||||
if (auto Name = dwarf::toString(
|
||||
findRecursively({DW_AT_MIPS_linkage_name, DW_AT_linkage_name}),
|
||||
nullptr))
|
||||
if (auto Name = getLinkageName())
|
||||
return Name;
|
||||
}
|
||||
if (auto Name = dwarf::toString(findRecursively(DW_AT_name), nullptr))
|
||||
return Name;
|
||||
return nullptr;
|
||||
return getShortName();
|
||||
}
|
||||
|
||||
const char *DWARFDie::getShortName() const {
|
||||
if (!isValid())
|
||||
return nullptr;
|
||||
|
||||
return dwarf::toString(findRecursively(dwarf::DW_AT_name), nullptr);
|
||||
}
|
||||
|
||||
const char *DWARFDie::getLinkageName() const {
|
||||
if (!isValid())
|
||||
return nullptr;
|
||||
|
||||
return dwarf::toString(findRecursively({dwarf::DW_AT_MIPS_linkage_name,
|
||||
dwarf::DW_AT_linkage_name}),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
uint64_t DWARFDie::getDeclLine() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user