summaryrefslogtreecommitdiff
path: root/test/Analysis/RegionInfo
AgeCommit message (Collapse)Author
2017-08-15[Dominators] Include infinite loops in PostDominatorTreeJakub Kuderski
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310940 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29[tests] Do not emity binary bitcode to stdout in RegionInfo testsTobias Grosser
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309485 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-06Fix minor typo introduce in r297014Tobias Grosser
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297020 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-06New Test-Case for Region AnalysisTobias Grosser
While working on improvements to region info analysis, this test case caused an incorrect region bb2 => bb3 to be detected. Reviewers: grosser Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in> Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30652 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297014 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-05New Test-Case for Region AnalysisTobias Grosser
While working on improvements to the region info analysis, this test case caused an incorrect region 1 => 2 to be detected. It is incorrect because entry has an outgoing edge to 3. This is interesting because 1 dom 2 and 2 pdom 1, which should have been enough to prevent incoming forward edges into the region and outgoing forward edges from the region. Reviewers: grosser Subscribers: llvm-commits Contributed-by: Nandini Singhal <cs15mtech01004@iith.ac.in> Differential Revision: https://reviews.llvm.org/D30603 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296988 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-02Revert "Fix PR 24415 (at least), by making our post-dominator tree behavior ↵Tobias Grosser
sane." and also "clang-format GenericDomTreeConstruction.h, since the current formatting makes it look like their is a bug in the loop indentation, and there is not" This reverts commit r296535. There are still some open design questions which I would like to discuss. I revert this for Daniel (who gave the OK), as he is on vacation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296812 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-28Fix PR 24415 (at least), by making our post-dominator tree behavior sane.Daniel Berlin
Summary: Currently, our post-dom tree tries to ignore and remove the effects of infinite loops. It fails miserably at this, because it tries to do it ahead of time, and thus can only detect self-loops, and any other type of infinite loop, it pretends doesn't exist at all. This can, in a bunch of cases, lead to wrong answers and a completely empty post-dom tree. Wrong answer: ``` declare void foo() define internal void @f() { entry: br i1 undef, label %bb35, label %bb3.i bb3.i: call void @foo() br label %bb3.i bb35.loopexit3: br label %bb35 bb35: ret void } ``` We get: ``` Inorder PostDominator Tree: [1] <<exit node>> {0,7} [2] %bb35 {1,6} [3] %bb35.loopexit3 {2,3} [3] %entry {4,5} ``` This is a trivial modification of the testcase for PR 6047 Note that we pretend bb3.i doesn't exist. We also pretend that bb35 post-dominates entry. While it's true that it does not exit in a theoretical sense, it's not really helpful to try to ignore the effect and pretend that bb35 post-dominates entry. Worse, we pretend the infinite loop does nothing (it's usually considered a side-effect), and doesn't even exist, even when it calls a function. Sadly, this makes it impossible to use when you are trying to move code safely. All compilers also create virtual or real single exit nodes (including us), and connect infinite loops there (which this patch does). In fact, others have worked around our behavior here, to the point of building their own post-dom trees: https://zneak.github.io/fcd/2016/02/17/structuring.html and pointing out the region infrastructure is near-useless for them with postdom in this state :( Completely empty post-dom tree: ``` define void @spam() #0 { bb: br label %bb1 bb1: ; preds = %bb1, %bb br label %bb1 bb2: ; No predecessors! ret void } ``` Printing analysis 'Post-Dominator Tree Construction' for function 'foo': =============================-------------------------------- Inorder PostDominator Tree: [1] <<exit node>> {0,1} :( (note that even if you ignore the effects of infinite loops, bb2 should be present as an exit node that post-dominates nothing). This patch changes post-dom to properly handle infinite loops and does root finding during calculation to prevent empty tress in such cases. We match gcc's (and the canonical theoretical) behavior for infinite loops (find the backedge, connect it to the exit block). Testcases coming as soon as i finish running this on a ton of random graphs :) Reviewers: chandlerc, davide Subscribers: bryant, llvm-commits Differential Revision: https://reviews.llvm.org/D29705 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296535 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-04Add missing CHECK: line to test case added in 29097Tobias Grosser
Without this CHECK line, we may not detect incorrectly detected additional regions at the end of the region tree. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290994 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-04RegionInfo: add new test caseTobias Grosser
This test case has been reduced from test/Analysis/RegionInfo/mix_1.ll and provides us with a minimal example of a test case which caused problems while working on an improved version of the RegionInfo analysis. We upstream this test case, as it certainly can be helpful in future debugging and optimization tests. Test case reduced by Pratik Bhatu <cs12b1010@iith.ac.in> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290974 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-10[RegionInfo] Add three tests that include infinite loopsTobias Grosser
These examples are variations that were inspired from a small subgraph taken from paper.ll which are interesting as they show certain issues with infinite loops. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286450 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-25Introduce RegionInfoAnalysis, which compute Region Tree in the new ↵Hongbin Zheng
PassManager. NFC Differential Revision: http://reviews.llvm.org/D17571 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261904 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-25Revert "Introduce RegionInfoAnalysis, which compute Region Tree in the new ↵Hongbin Zheng
PassManager. NFC" This reverts commit 8228b4d374edeb4cc0c5fddf6e1ab876918ee126. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261889 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-25Introduce RegionInfoAnalysis, which compute Region Tree in the new ↵Hongbin Zheng
PassManager. NFC Differential Revision: http://reviews.llvm.org/D17571 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261884 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-16[tests] Cleanup initialization of test suffixes.Daniel Dunbar
- Instead of setting the suffixes in a bunch of places, just set one master list in the top-level config. We now only modify the suffix list in a few suites that have one particular unique suffix (.ml, .mc, .yaml, .td, .py). - Aside from removing the need for a bunch of lit.local.cfg files, this enables 4 tests that were inadvertently being skipped (one in Transforms/BranchFolding, a .s file each in DebugInfo/AArch64 and CodeGen/PowerPC, and one in CodeGen/SI which is now failing and has been XFAILED). - This commit also fixes a bunch of config files to use config.root instead of older copy-pasted code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188513 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-03RegionInfo: Do not crash if unreachable block is foundTobias Grosser
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181025 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-12Revert the test moves from 176733. Use "REQUIRES: asserts" instead.Jan Wen Voung
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176873 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-08Disable statistics on Release builds and move tests that depend on -stats.Jan Wen Voung
Summary: Statistics are still available in Release+Asserts (any +Asserts builds), and stats can also be turned on with LLVM_ENABLE_STATS. Move some of the FastISel stats that were moved under DEBUG() back out of DEBUG(), since stats are disabled across the board now. Many tests depend on grepping "-stats" output. Move those into a orig_dir/Stats/. so that they can be marked as unsupported when building without statistics. Differential Revision: http://llvm-reviews.chandlerc.com/D486 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176733 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-30Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ↵Dmitri Gribenko
ModuleID This is done to avoid odd test failures, like the one fixed in r171243. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171250 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-02Convert the uses of '|&' to use '2>&1 |' instead, which works on oldChandler Carruth
versions of Bash. In addition, I can back out the change to the lit built-in shell test runner to support this. This should fix the majority of fallout on Darwin, but I suspect there will be a few straggling issues. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159544 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-16Replace all instances of dg.exp file with lit.local.cfg, since all tests are ↵Eli Bendersky
run with LIT now and now Dejagnu. dg.exp is no longer needed. Patch reviewed by Daniel Dunbar. It will be followed by additional cleanup patches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150664 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-25Make tests more useful.Benjamin Kramer
lit needs a linter ... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130126 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-10RegionInfo: Do not assert if a BB is not part of the dominance tree.Tobias Grosser
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110665 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-22Add new RegionInfo pass.Tobias Grosser
The RegionInfo pass detects single entry single exit regions in a function, where a region is defined as any subgraph that is connected to the remaining graph at only two spots. Furthermore an hierarchical region tree is built. Use it by calling "opt -regions analyze" or "opt -view-regions". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109089 91177308-0d34-0410-b5e6-96231b3b80d8