This is an archive of the discontinued LLVM Phabricator instance.

[Dominators] Implement incremental insertions
ClosedPublic

Authored by kuhar on Jul 12 2017, 5:41 PM.

Details

Summary

This patch introduces incremental edge insertions based on the Depth Based Search algorithm.

Insertions should work for both dominators and postdominators.

Diff Detail

Repository
rL LLVM

Event Timeline

kuhar created this revision.Jul 12 2017, 5:41 PM
kuhar added inline comments.Jul 12 2017, 9:03 PM
include/llvm/Support/GenericDomTreeConstruction.h
171 ↗(On Diff #106359)

Extra semicolon.

dberlin accepted this revision.Jul 13 2017, 10:31 AM
dberlin added inline comments.
include/llvm/Support/GenericDomTree.h
451 ↗(On Diff #106359)

s/edge insertion/CFG edge insertion/

455 ↗(On Diff #106359)

Will it really work if you do it before the actual cfg change exists?
(IE without that edge, will you still be able to find the right successors, predecessors?)
If so, great!

This revision is now accepted and ready to land.Jul 13 2017, 10:31 AM
kuhar marked 2 inline comments as done.Jul 13 2017, 6:10 PM
kuhar added inline comments.
include/llvm/Support/GenericDomTree.h
455 ↗(On Diff #106359)

Yes, but only for insertions, not for deletions.

The proof goes like this:
There are 2 cases - insertion from (x -> y) with incoming edges to reachable (a) nodes and unreachable (b) nodes.
a) To notice that the about-to-be inserted edge (x -> y) is missing, the path P mentioned in lemma 2.5 would have to go to back to x. So when we visit x we iterate it's successors to find affected nodes. y is not there, since there is no edge (yet) from x to y, but it doesn't matter, as we only visit each node once and the algorithm starts by visiting y.
b) In the case when y is unreachable, the algorithm reruns SemiNCA on a subtree starting at y. SemiNCA only processed unreachable nodes and y will be processed first. Then, it performs reachable insertions on the connecting edges it found during the DFS walk. (x -> y) cannot be a connecting edge, as y was unreachable.

So there's no way for the algorithm to notice that there's no edge from x to y.

When it comes to deletions, there are cases when the algorithm needs to rebuild the whole tree -- so the deletion has to happen before, or it'll reconstruct the exact same tree.

kuhar updated this revision to Diff 106572.Jul 13 2017, 6:14 PM
This revision was automatically updated to reflect the committed changes.