llvm-project/llvm/test/Analysis/RegionInfo
Jakub Kuderski 638c085d07 [Dominators] Include infinite loops in PostDominatorTree
Summary:
This patch teaches PostDominatorTree about infinite loops. It is built on top of D29705 by @dberlin which includes a very detailed motivation for this change.

What's new is that the patch also teaches the incremental updater how to deal with reverse-unreachable regions and how to properly maintain and verify tree roots. Before that, the incremental algorithm sometimes ended up preserving reverse-unreachable regions after updates that wouldn't appear in the tree if it was constructed from scratch on the same CFG.

This patch makes the following assumptions:
- A sequence of updates should produce the same tree as a recalculating it.
- Any sequence of the same updates should lead to the same tree.
- Siblings and roots are unordered.

The last two properties are essential to efficiently perform batch updates in the future.
When it comes to the first one, we can decide later that the consistency between freshly built tree and an updated one doesn't matter match, as there are many correct ways to pick roots in infinite loops, and to relax this assumption. That should enable us to recalculate postdominators less frequently.

This patch is pretty conservative when it comes to incremental updates on reverse-unreachable regions and ends up recalculating the whole tree in many cases. It should be possible to improve the performance in many cases, if we decide that it's important enough.
That being said, my experiments showed that reverse-unreachable are very rare in the IR emitted by clang when bootstrapping  clang. Here are the statistics I collected by analyzing IR between passes and after each removePredecessor call:

```
# functions:  52283
# samples:  337609
# reverse unreachable BBs:  216022
# BBs:  247840796
Percent reverse-unreachable:  0.08716159869015269 %
Max(PercRevUnreachable) in a function:  87.58620689655172 %
# > 25 % samples:  471 ( 0.1395104988314885 % samples )
... in 145 ( 0.27733680163724345 % functions )
```

Most of the reverse-unreachable regions come from invalid IR where it wouldn't be possible to construct a PostDomTree anyway.

I would like to commit this patch in the next week in order to be able to complete the work that depends on it before the end of my internship, so please don't wait long to voice your concerns :).

Reviewers: dberlin, sanjoy, grosser, brzycki, davide, chandlerc, hfinkel

Reviewed By: dberlin

Subscribers: nhaehnle, javed.absar, kparzysz, uabelho, jlebar, hiraditya, llvm-commits, dberlin, david2050

Differential Revision: https://reviews.llvm.org/D35851

llvm-svn: 310940
2017-08-15 18:14:57 +00:00
..
20100809_bb_not_in_domtree.ll
bad_node_traversal.ll
block_sort.ll
cond_loop.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
condition_complicated.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
condition_complicated_2.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
condition_forward_edge.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
condition_same_exit.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
condition_simple.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
exit_in_condition.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
infinite_loop.ll [Dominators] Include infinite loops in PostDominatorTree 2017-08-15 18:14:57 +00:00
infinite_loop_2.ll [Dominators] Include infinite loops in PostDominatorTree 2017-08-15 18:14:57 +00:00
infinite_loop_3.ll [Dominators] Include infinite loops in PostDominatorTree 2017-08-15 18:14:57 +00:00
infinite_loop_4.ll [Dominators] Include infinite loops in PostDominatorTree 2017-08-15 18:14:57 +00:00
infinite_loop_5_a.ll [Dominators] Include infinite loops in PostDominatorTree 2017-08-15 18:14:57 +00:00
infinite_loop_5_b.ll [Dominators] Include infinite loops in PostDominatorTree 2017-08-15 18:14:57 +00:00
infinite_loop_5_c.ll
loop_with_condition.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
loops_1.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
loops_2.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
mix_1.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
multiple_exiting_edge.ll
nested_loops.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
next.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
outgoing_edge.ll New Test-Case for Region Analysis 2017-03-05 14:08:28 +00:00
outgoing_edge_1.ll Fix minor typo introduce in r297014 2017-03-06 16:03:26 +00:00
paper.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
two_loops_same_header.ll [tests] Do not emity binary bitcode to stdout in RegionInfo tests 2017-07-29 09:58:43 +00:00
unreachable_bb.ll