[PATCH] D51443: [dsymutil] Remove non-determinism.
Jonas Devlieghere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 29 10:35:30 PDT 2018
JDevlieghere created this revision.
JDevlieghere added reviewers: friss, aprantl.
Herald added a subscriber: mgrang.
Before this patch, analyzeContext called `getCanonicalDIEOffset()`, for which the result depends on the timings of the `setCanonicalDIEOffset()` calls in the `cloneLambda`. This can lead to slightly different output between runs.
This patch fixes this by moving the call to `getCanonicalDIEOffset()` into the `cloneLambda`.
Repository:
rL LLVM
https://reviews.llvm.org/D51443
Files:
llvm/tools/dsymutil/DwarfLinker.cpp
Index: llvm/tools/dsymutil/DwarfLinker.cpp
===================================================================
--- llvm/tools/dsymutil/DwarfLinker.cpp
+++ llvm/tools/dsymutil/DwarfLinker.cpp
@@ -271,6 +271,19 @@
Info.Prune &= (DIE.getTag() == dwarf::DW_TAG_module) ||
dwarf::toUnsigned(DIE.find(dwarf::DW_AT_declaration), 0);
+ return Info.Prune;
+}
+
+/// The canonical DIE offset is calculated when cloning a DIE. Therefore we
+/// cannot do it during analysis, but rather have to fix it up at the beginning
+/// of the clone step.
+static bool updatePruning(const DWARFDie &DIE, CompileUnit &CU) {
+ unsigned MyIdx = CU.getOrigUnit().getDIEIndex(DIE);
+ CompileUnit::DIEInfo &Info = CU.getInfo(MyIdx);
+
+ for (auto Child : DIE.children())
+ Info.Prune &= updatePruning(Child, CU);
+
// Don't prune it if there is no definition for the DIE.
Info.Prune &= Info.Ctxt && Info.Ctxt->getCanonicalDIEOffset();
@@ -2512,14 +2525,13 @@
*CU, UnitID++, !Options.NoODR && !Options.Update, ""));
}
}
-
+
// Now build the DIE parent links that we will use during the next phase.
for (auto &CurrentUnit : LinkContext.CompileUnits) {
auto CUDie = CurrentUnit->getOrigUnit().getUnitDIE();
if (!CUDie)
continue;
- analyzeContextInfo(CurrentUnit->getOrigUnit().getUnitDIE(), 0,
- *CurrentUnit, &ODRContexts.getRoot(),
+ analyzeContextInfo(CUDie, 0, *CurrentUnit, &ODRContexts.getRoot(),
UniquingStringPool, ODRContexts);
}
@@ -2547,6 +2559,15 @@
if (!LinkContext.ObjectFile)
continue;
+ // We need to update all compile units before doing lookForDIEsToKeep as
+ // the latter can follow cross-CU links through its attributes.
+ for (auto &CurrentUnit : LinkContext.CompileUnits) {
+ auto CUDie = CurrentUnit->getOrigUnit().getUnitDIE();
+ if (!CUDie)
+ continue;
+ updatePruning(CUDie, *CurrentUnit);
+ }
+
// Then mark all the DIEs that need to be present in the linked output
// and collect some information about them.
// Note that this loop can not be merged with the previous one because
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51443.163137.patch
Type: text/x-patch
Size: 2261 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180829/656b32c3/attachment.bin>
More information about the llvm-commits
mailing list