[PATCH] D140930: [dsymutil] Avoid invalid keep chains due to pruning
Jonas Devlieghere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 3 16:50:10 PST 2023
JDevlieghere created this revision.
JDevlieghere added reviewers: avl, aprantl.
Herald added a subscriber: hiraditya.
Herald added a project: All.
JDevlieghere requested review of this revision.
Herald added a project: LLVM.
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 1b79bed8f532 <https://reviews.llvm.org/rG1b79bed8f53231144ad6e14f8cc3e8673c7fb469>.
This patch fixes this issue by updating the pruning properties of the parent DIE during the parent walk.
Similar to c9cbe6937b1f <https://reviews.llvm.org/rGc9cbe6937b1fe797f805648216257ae88bde4ad7>, this issue was caught in a big internal project that doesn't lend itself to reduction and so far I haven't been able to create an artificial test case where (1) a pruned DIE doesn't have a decl context and (2) is marked as kept.
https://reviews.llvm.org/D140930
Files:
llvm/lib/DWARFLinker/DWARFLinker.cpp
Index: llvm/lib/DWARFLinker/DWARFLinker.cpp
===================================================================
--- llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -788,8 +788,12 @@
unsigned Idx = Current.CU.getOrigUnit().getDIEIndex(Current.Die);
CompileUnit::DIEInfo &MyInfo = Current.CU.getInfo(Idx);
- if (MyInfo.Prune)
- continue;
+ if (MyInfo.Prune) {
+ 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140930.486068.patch
Type: text/x-patch
Size: 674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230104/c33a2cf6/attachment.bin>
More information about the llvm-commits
mailing list