You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[DwarfDebug] Move abstract entities tracking from DwarfCompileUnit to DwarfUnit
DwarfCompileUnit::constructVariableDIE() and constructLabelDIE() are
meant for constructing both abstract and concrete DIEs of a DbgEntity.
They use DwarfUnit::insertDIE() to store a freshly-created DIE. However,
insertDIE()/DwarfUnit::DITypeNodeToDieMap stores only single DIE per DINode.
If insertDIE() is called several times for the same instance of DINode,
only first DIE is saved in DwarfUnit::DITypeNodeToDieMap, as follows
from DenseMap::insert() specification.
It means, depending on what is called first,
DwarfCompileUnit::constructVariableDIE(LV, /* Abstract */ true) or
DwarfCompileUnit::constructVariableDIE(LV, /* Abstract */ false),
DwarfUnit::DITypeNodeToDieMap stores either abstract or concrete DIE of a node.
This behavior suggests an obscure API of DwarfCompileUnit, as it silently discards
one of the DIEs and makes it unclear what DwarfUnit::DITypeNodeToDieMap
is made for.
Also, DwarfFile and DwarfUnit have a tiny duplicate code piece.
To address that, DwarfInfoHolder class is introduced, which
stores DIEs for DILocalVariables and DILabels separately from
DIEs for other DINodes (as DILocalVariables and DILabels may have
concrete and abstract DIEs), and allows explicit access to
abstract/concrete DIEs of a debug info entity.
DwarfInfoHolder may later be used for tracking DIEs of abstract/concrete
lexical scopes.
Currently, concrete lexical block/subprogram DIEs are distinguished by
their DISubprogram/DILocalScope/DILocalScope+inlinedAt in DwarfCompileUnit.
As a result, the same DISubprogram can't be attached to two llvm::Functions
(https://lists.llvm.org/pipermail/llvm-dev/2020-September/145342.html).
Matching DISubprogram/DILocalScope DIEs with their LexicalScopes and
letting DwarfUnit members to access abstract scopes may enable linking
DISubprogram to several llvm::Functions, and allow the transition from
distinct to uniqued DISubprograms proposed here
llvm#142166 (comment).
0 commit comments