This is an archive of the discontinued LLVM Phabricator instance.

[Debuginfo][NFC] Avoid double calling of DWARFDie::find(DW_AT_name).
ClosedPublic

Authored by avl on Apr 30 2020, 6:53 AM.

Details

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%).

Diff Detail

Event Timeline

avl created this revision.Apr 30 2020, 6:53 AM
dblaikie accepted this revision.Apr 30 2020, 8:38 AM
dblaikie added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
529–542

Are there any callers left relying on this fallback behavior? Could they be ported to an explicit function dedicated to this task ("getLinkageNameOrShortName") so it's clear?

This revision is now accepted and ready to land.Apr 30 2020, 8:38 AM
avl marked an inline comment as done.Apr 30 2020, 9:49 AM
avl added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
529–542

There are some callers relying on that fallback behavior which could use function with clearer name :

D.getName(DINameKind::LinkageName) -> D.getLinkageNameOrShortName()

But there are callers which receive name kind through parameters. In those cases it could not be replaced to getLinkageNameOrShortName:

const char *DWARFDie::getSubroutineName(DINameKind Kind) const {
  if (!isSubroutineDIE())
    return nullptr;
  return getName(Kind);
}
...
(Name = DIE.getSubroutineName(Kind)
...

I assume that this fallback behavior is important for all who currently specify DINameKind::LinkageName. Probably they could be evaluated and not all would finally require fallback behavior.

clayborg accepted this revision.Apr 30 2020, 11:45 AM
This revision was automatically updated to reflect the committed changes.