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] Track abstract entities in DwarfUnit separately
`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` store 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 depends on
function call order and makes it unclear what `DwarfUnit::DITypeNodeToDieMap` is
meant to store.
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.
Also, DwarfFile and DwarfUnit have a tiny duplicate code piece.
AbstractEntities, AbstractLocalScopeDIEs and FinalizedAbstractSubprograms
tracking were moved to DwarfInfoHolder, as the corresponding entities may be
shared across CUs.
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