llvm.org GIT mirror llvm / b8b321a
[Dominators] Simplify child lists and make them deterministic This fixes an extremely subtle non-determinism that can only be triggered by an unfortunate alignment of passes. In my case: - JumpThreading does large dominator tree updates - CorrelatedValuePropagation preserves domtree now - LICM codegen depends on the order of children on domtree nodes The last part is non-deterministic if the update was stored in a set. But it turns out that the set is completely unnecessary, updates are deduplicated at an earlier stage so we can just use a vector, which is both more efficient and doesn't destroy the input ordering. I didn't manage to get the 240 MB IR file reduced enough, triggering this bug requires a lot of jump threading, so landing this without a test case. Differential Revision: https://reviews.llvm.org/D48392 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335176 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 2 years ago
1 changed file(s) with 12 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
8181 // Note that these children are from the future relative to what the
8282 // DominatorTree knows about -- using them to gets us some snapshot of the
8383 // CFG from the past (relative to the state of the CFG).
84 DenseMap> FutureSuccessors;
85 DenseMapDenseSet> FuturePredecessors;
84 DenseMapVector> FutureSuccessors;
85 DenseMap> FuturePredecessors;
8686 // Remembers if the whole tree was recalculated at some point during the
8787 // current batch update.
8888 bool IsRecalculated = false;
11751175 // predecessors. Note that these sets will only decrease size over time, as
11761176 // the next CFG snapshots slowly approach the actual (current) CFG.
11771177 for (UpdateT &U : BUI.Updates) {
1178 BUI.FutureSuccessors[U.getFrom()].insert({U.getTo(), U.getKind()});
1179 BUI.FuturePredecessors[U.getTo()].insert({U.getFrom(), U.getKind()});
1178 BUI.FutureSuccessors[U.getFrom()].push_back({U.getTo(), U.getKind()});
1179 BUI.FuturePredecessors[U.getTo()].push_back({U.getFrom(), U.getKind()});
11801180 }
11811181
11821182 LLVM_DEBUG(dbgs() << "About to apply " << NumLegalized << " updates\n");
12641264 LLVM_DEBUG(dbgs() << "Applying update: " << CurrentUpdate << "\n");
12651265
12661266 // Move to the next snapshot of the CFG by removing the reverse-applied
1267 // current update.
1267 // current update. Since updates are performed in the same order they are
1268 // legalized it's sufficient to pop the last item here.
12681269 auto &FS = BUI.FutureSuccessors[CurrentUpdate.getFrom()];
1269 FS.erase({CurrentUpdate.getTo(), CurrentUpdate.getKind()});
1270 assert(FS.back().getPointer() == CurrentUpdate.getTo() &&
1271 FS.back().getInt() == CurrentUpdate.getKind());
1272 FS.pop_back();
12701273 if (FS.empty()) BUI.FutureSuccessors.erase(CurrentUpdate.getFrom());
12711274
12721275 auto &FP = BUI.FuturePredecessors[CurrentUpdate.getTo()];
1273 FP.erase({CurrentUpdate.getFrom(), CurrentUpdate.getKind()});
1276 assert(FP.back().getPointer() == CurrentUpdate.getFrom() &&
1277 FP.back().getInt() == CurrentUpdate.getKind());
1278 FP.pop_back();
12741279 if (FP.empty()) BUI.FuturePredecessors.erase(CurrentUpdate.getTo());
12751280
12761281 if (CurrentUpdate.getKind() == UpdateKind::Insert)