Skip to content

Commit

Permalink
[dsymutil] Avoid invalid keep chains due to pruning
Browse files Browse the repository at this point in the history
The pruning property that's part of the DIE info is fully computing
during the analyzeContextInfo phase, but can be updated during the
lookForDIEsToKeep phase.

  // Keep a module forward declaration if there is no definition.
  if (!(isODRAttribute(AttrSpec.Attr) && Info.Ctxt &&
        Info.Ctxt->hasCanonicalDIE()))
    Info.Prune = false;

When the pruning property is updated during the lookForDIEsToKeep phase,
it's not propagated to the parent, unlike during the analyzeContextInfo
phase. This can result in an invalid keep chain with the child DIE being
marked as kept while its parent is still marked as pruned and therefore
never kept, a situation that's now caught by 1b79bed.

This patch fixes this issue by updating the pruning properties of the
parent DIE during the parent walk.

Differential revision: https://reviews.llvm.org/D140930
  • Loading branch information
JDevlieghere committed Jan 4, 2023
1 parent f95108f commit 45f3472
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions llvm/lib/DWARFLinker/DWARFLinker.cpp
Expand Up @@ -788,8 +788,14 @@ void DWARFLinker::lookForDIEsToKeep(AddressesMap &AddressesMap,
unsigned Idx = Current.CU.getOrigUnit().getDIEIndex(Current.Die);
CompileUnit::DIEInfo &MyInfo = Current.CU.getInfo(Idx);

if (MyInfo.Prune)
continue;
if (MyInfo.Prune) {
// We're walking the dependencies of a module forward declaration that was
// kept because there is no definition.
if (Current.Flags & TF_DependencyWalk)
MyInfo.Prune = false;
else
continue;
}

// If the Keep flag is set, we are marking a required DIE's dependencies.
// If our target is already marked as kept, we're all set.
Expand Down

0 comments on commit 45f3472

Please sign in to comment.