aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LoopPass.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-08-09Consistently use LoopAnalysisManagerSean Silva1-1/+1
One exception here is LoopInfo which must forward-declare it (because the typedef is in LoopPassManager.h which depends on LoopInfo). Also, some includes for LoopPassManager.h were needed since that file provides the typedef. Besides a general consistently benefit, the extra layer of indirection allows the mechanical part of https://reviews.llvm.org/D23256 that requires touching every transformation and analysis to be factored out cleanly. Thanks to David for the suggestion. llvm-svn: 278079
2016-07-19[LoopPass] Some minor cleanupsDavid Majnemer1-7/+5
No functional change is intended. llvm-svn: 275999
2016-06-26Apply clang-tidy's modernize-loop-convert to lib/Analysis.Benjamin Kramer1-3/+1
Only minor manual fixes. No functionality change intended. llvm-svn: 273816
2016-06-20Fix dynamically linked debug builds.Eli Friedman1-0/+1
On the surface, this might not look like it does anything... but actually it brings in the declaration "extern template class AnalysisManager<Loop>;", which suppresses the instantiation of the constructor, which avoids the funny interaction between "extern template" and -fvisibility-inlines-hidden. llvm-svn: 273133
2016-06-17[PM] Remove support for omitting the AnalysisManager argument to newChandler Carruth1-2/+4
pass manager passes' `run` methods. This removes a bunch of SFINAE goop from the pass manager and just requires pass authors to accept `AnalysisManager<IRUnitT> &` as a dead argument. This is a small price to pay for the simplicity of the system as a whole, despite the noise that changing it causes at this stage. This will also helpfull allow us to make the signature of the run methods much more flexible for different kinds af passes to support things like intelligently updating the pass's progression over IR units. While this touches many, many, files, the changes are really boring. Mostly made with the help of my trusty perl one liners. Thanks to Sean and Hal for bouncing ideas for this with me in IRC. llvm-svn: 272978
2016-04-22Re-commit optimization bisect support (r267022) without new pass manager ↵Andrew Kaylor1-4/+10
support. The original commit was reverted because of a buildbot problem with LazyCallGraph::SCC handling (not related to the OptBisect handling). Differential Revision: http://reviews.llvm.org/D19172 llvm-svn: 267231
2016-04-22Revert "Initial implementation of optimization bisect support."Vedant Kumar1-10/+4
This reverts commit r267022, due to an ASan failure: http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/1549 llvm-svn: 267115
2016-04-21Initial implementation of optimization bisect support.Andrew Kaylor1-4/+10
This patch implements a optimization bisect feature, which will allow optimizations to be selectively disabled at compile time in order to track down test failures that are caused by incorrect optimizations. The bisection is enabled using a new command line option (-opt-bisect-limit). Individual passes that may be skipped call the OptBisect object (via an LLVMContext) to see if they should be skipped based on the bisect limit. A finer level of control (disabling individual transformations) can be managed through an addition OptBisect method, but this is not yet used. The skip checking in this implementation is based on (and replaces) the skipOptnoneFunction check. Where that check was being called, a new call has been inserted in its place which checks the bisect limit and the optnone attribute. A new function call has been added for module and SCC passes that behaves in a similar way. Differential Revision: http://reviews.llvm.org/D19172 llvm-svn: 267022
2016-01-08LoopInfo: Simplify ownership of Loop objectsJustin Bogner1-11/+10
It's strange that LoopInfo mostly owns the Loop objects, but that it defers deleting them to the loop pass manager. Instead, change the oddly named "updateUnloop" to "markAsRemoved" and have it queue the Loop object for deletion. We can't delete the Loop immediately when we remove it, since we need its pointer identity still, so we'll mark the object as "invalid" so that clients can see what's going on. llvm-svn: 257191
2016-01-06Recommit r256952 "Filtering IR printing for print-after-all/print-before-all"Weiming Zhao1-1/+5
Fix lit test fail due to outputting an extra line. Differential Revision: http://reviews.llvm.org/D15776 llvm-svn: 256987
2016-01-06Revert r256952 due to lit test fails.Weiming Zhao1-5/+1
llvm-svn: 256954
2016-01-06Filtering IR printing for print-after-all/print-before-allWeiming Zhao1-1/+5
Summary: This patch implements "-print-funcs" option to support function filtering for IR printing like -print-after-all, -print-before etc. Examples: -print-after-all -print-funcs=foo,bar Reviewers: mcrosier, joker.eph Subscribers: tejohnson, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D15776 llvm-svn: 256952
2015-12-16LPM: Make callers of LPM.deleteLoopFromQueue update LoopInfo directly. NFCJustin Bogner1-6/+0
As of r255720, the loop pass manager will DTRT when passes update the loop info for removed loops, so they no longer need to reach into LPPassManager APIs to do this kind of transformation. This change very nearly removes the need for the LPPassManager to even be passed into loop passes - the only remaining pass that uses the LPM argument is LoopUnswitch. llvm-svn: 255797
2015-12-16LPM: Simplify how passes mark loops for deletion. NFCJustin Bogner1-35/+16
When a pass removes a loop it currently has to reach up into the LPPassManager's internals to update the state of the iteration over loops. This reverse dependency results in a pretty awkward interplay of the LPPassManager and its Passes. Here, we change this to instead keep track of when a loop has become "unlooped" in the Loop objects themselves, then the LPPassManager can check this and manipulate its own state directly. This opens the door to allow most of the loop passes to work without a backreference to the LPPassManager. I've kept passes calling the LPPassManager::deleteLoopFromQueue API now so I could put an assert in to prove that this is NFC, but a later pass will update passes just to preserve the LoopInfo directly and stop referencing the LPPassManager completely. llvm-svn: 255720
2015-11-04PM: Rephrase PrintLoopPass as a wrapper around a new-style pass. NFCJustin Bogner1-17/+9
Splits PrintLoopPass into a new-style pass and a PrintLoopPassWrapper, much like we already do for PrintFunctionPass and PrintModulePass. llvm-svn: 252085
2015-10-22LoopPass: Remove redoLoop, it isn't used. NFCJustin Bogner1-13/+0
In r251064 I removed a logically unreachable call to `redoLoop`, and now there aren't any callers of this API at all. Remove the needless complexity. llvm-svn: 251067
2015-10-22LoopPass: Simplify the API for adding a new loop. NFCJustin Bogner1-27/+18
The insertLoop() API is only used to add new loops, and has confusing ownership semantics. Simplify it by replacing it with addLoop(). llvm-svn: 251064
2015-06-23Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko1-1/+1
Apparently, the style needs to be agreed upon first. llvm-svn: 240390
2015-06-19Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-1/+1
The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
2015-03-23Purge unused includes throughout libSupport.Benjamin Kramer1-0/+1
NFC. llvm-svn: 232976
2015-01-17[PM] Split the LoopInfo object apart from the legacy pass, creatingChandler Carruth1-3/+4
a LoopInfoWrapperPass to wire the object up to the legacy pass manager. This switches all the clients of LoopInfo over and paves the way to port LoopInfo to the new pass manager. No functionality change is intended with this iteration. llvm-svn: 226373
2014-09-24Fix assertion in LICM doFinalization()David Peixotto1-0/+11
The doFinalization method checks that the LoopToAliasSetMap is empty. LICM populates that map as it runs through the loop nest, deleting the entries for child loops as it goes. However, if a child loop is deleted by another pass (e.g. unrolling) then the loop will never be deleted from the map because LICM walks the loop nest to find entries it can delete. The fix is to delete the loop from the map and free the alias set when the loop is deleted from the loop nest. Differential Revision: http://reviews.llvm.org/D5305 llvm-svn: 218387
2014-06-21Add back functionality removed in r210497.Richard Trieu1-2/+4
Instead of asserting, output a message stating that a null pointer was found. llvm-svn: 211430
2014-06-09Removing an "if (!this)" check from two print methods. The condition willRichard Trieu1-0/+1
never be true in a well-defined context. The checking for null pointers has been moved into the caller logic so it does not rely on undefined behavior. llvm-svn: 210497
2014-05-16Add C API for thread yielding callback.Juergen Ributzka1-0/+3
Sometimes a LLVM compilation may take more time then a client would like to wait for. The problem is that it is not possible to safely suspend the LLVM thread from the outside. When the timing is bad it might be possible that the LLVM thread holds a global mutex and this would block any progress in any other thread. This commit adds a new yield callback function that can be registered with a context. LLVM will try to yield by calling this callback function, but there is no guaranteed frequency. LLVM will only do so if it can guarantee that suspending the thread won't block any forward progress in other LLVM contexts in the same process. Once the client receives the call back it can suspend the thread safely and resume it at another time. Related to <rdar://problem/16728690> llvm-svn: 208945
2014-04-21[Modules] Make Support/Debug.h modular. This requires it to not changeChandler Carruth1-0/+2
behavior based on other files defining DEBUG_TYPE, which means it cannot define DEBUG_TYPE at all. This is actually better IMO as it forces folks to define relevant DEBUG_TYPEs for their files. However, it requires all files that currently use DEBUG(...) to define a DEBUG_TYPE if they don't already. I've updated all such files in LLVM and will do the same for other upstream projects. This still leaves one important change in how LLVM uses the DEBUG_TYPE macro going forward: we need to only define the macro *after* header files have been #include-ed. Previously, this wasn't possible because Debug.h required the macro to be pre-defined. This commit removes that. By defining DEBUG_TYPE after the includes two things are fixed: - Header files that need to provide a DEBUG_TYPE for some inline code can do so by defining the macro before their inline code and undef-ing it afterward so the macro does not escape. - We no longer have rampant ODR violations due to including headers with different DEBUG_TYPE definitions. This may be mostly an academic violation today, but with modules these types of violations are easy to check for and potentially very relevant. Where necessary to suppor headers with DEBUG_TYPE, I have moved the definitions below the includes in this commit. I plan to move the rest of the DEBUG_TYPE macros in LLVM in subsequent commits; this one is big enough. The comments in Debug.h, which were hilariously out of date already, have been updated to reflect the recommended practice going forward. llvm-svn: 206822
2014-04-15[C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper1-2/+2
instead of comparing to nullptr. llvm-svn: 206243
2014-03-05[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-2/+2
class. llvm-svn: 202945
2014-02-26Constify the Optnone checks in IR passes.Paul Robinson1-2/+2
llvm-svn: 202213
2014-02-06Disable most IR-level transform passes on functions marked 'optnone'.Paul Robinson1-0/+14
Ideally only those transform passes that run at -O0 remain enabled, in reality we get as close as we reasonably can. Passes are responsible for disabling themselves, it's not the job of the pass manager to do it for them. llvm-svn: 200892
2014-01-12[PM] Rename the IR printing pass header to a more generic and correctChandler Carruth1-1/+1
name to match the source file which I got earlier. Update the include sites. Also modernize the comments in the header to use the more recommended doxygen style. llvm-svn: 199041
2014-01-07Move the LLVM IR asm writer header files into the IR directory, as theyChandler Carruth1-1/+1
are part of the core IR library in order to support dumping and other basic functionality. Rename the 'Assembly' include directory to 'AsmParser' to match the library name and the only functionality left their -- printing has been in the core IR library for quite some time. Update all of the #includes to match. All of this started because I wanted to have the layering in good shape before I started adding support for printing LLVM IR using the new pass infrastructure, and commandline support for the new pass infrastructure. llvm-svn: 198688
2013-07-20Comment: try to clarify loop iteration order.Andrew Trick1-0/+4
llvm-svn: 186774
2012-06-26Enable the new LoopInfo algorithm by default.Andrew Trick1-3/+7
The primary advantage is that loop optimizations will be applied in a stable order. This helps debugging and unit test creation. It is also a better overall implementation without pathologically bad performance on deep functions. On large functions (llvm-stress --size=200000 | opt -loops) Before: 0.1263s After: 0.0225s On deep functions (after tweaking llvm-stress, thanks Nadav): Before: 0.2281s After: 0.0227s See r158790 for more comments. The loop tree is now consistently generated in forward order, but loop passes are applied in reverse order over the program. If we have a loop optimization that prefers forward order, that can easily be achieved by adding a different type of LoopPassManager. llvm-svn: 159183
2012-03-23Take out the debug info probe stuff. It's making some changes toEric Christopher1-21/+2
the PassManager annoying and should be reimplemented as a decorator on top of existing passes (as should the timing data). llvm-svn: 153305
2011-08-29Reapply r138695. Fix PassManager stack depths.Andrew Trick1-4/+4
Patch by Xiaoyi Guo! llvm-svn: 138737
2011-08-27Reverting r138695 to see if it fixes clang self host.Andrew Trick1-4/+4
llvm-svn: 138701
2011-08-27Fix PassManager stack depths.Andrew Trick1-4/+4
Patch by Xiaoyi Guo! llvm-svn: 138695
2011-08-10Reapplying r136844.Andrew Trick1-50/+6
An algorithm for incrementally updating LoopInfo within a LoopPassManager. The incremental update should be extremely cheap in most cases and can be used in places where it's not feasible to regenerate the entire loop forest. - "Unloop" is a node in the loop tree whose last backedge has been removed. - Perform reverse dataflow on the block inside Unloop to propagate the nearest loop from the block's successors. - For reducible CFG, each block in unloop is visited exactly once. This is because unloop no longer has a backedge and blocks within subloops don't change parents. - Immediate subloops are summarized by the nearest loop reachable from their exits or exits within nested subloops. - At completion the unloop blocks each have a new parent loop, and each immediate subloop has a new parent. llvm-svn: 137276
2011-08-04Reverting r136884 updateUnloop, which crashed a linux builder.Andrew Trick1-6/+50
llvm-svn: 136857
2011-08-03An algorithm for incrementally updating LoopInfo within aAndrew Trick1-50/+6
LoopPassManager. The incremental update should be extremely cheap in most cases and can be used in places where it's not feasible to regenerate the entire loop forest. - "Unloop" is a node in the loop tree whose last backedge has been removed. - Perform reverse dataflow on the block inside Unloop to propagate the nearest loop from the block's successors. - For reducible CFG, each block in unloop is visited exactly once. This is because unloop no longer has a backedge and blocks within subloops don't change parents. - Immediate subloops are summarized by the nearest loop reachable from their exits or exits within nested subloops. - At completion the unloop blocks each have a new parent loop, and each immediate subloop has a new parent. llvm-svn: 136844
2011-08-03whitespaceAndrew Trick1-28/+28
llvm-svn: 136843
2011-03-10Introduce DebugInfoProbe. This is used to monitor how llvm optimizer is ↵Devang Patel1-2/+21
treating debugging information. It generates output that lools like 8 times line number info lost by Scalar Replacement of Aggregates (SSAUp) 1 times line number info lost by Simplify well-known library calls 12 times variable info lost by Jump Threading llvm-svn: 127381
2010-09-04zap dead code.Chris Lattner1-1/+0
llvm-svn: 113073
2010-08-19Revert r111199; it breaks -debug-pass=Structure output.Dan Gohman1-1/+1
llvm-svn: 111500
2010-08-16Make dumpPassStructure be a PMDataManager abstraction, rather thanDan Gohman1-1/+1
a Pass abstraction, since that's the level it's actually used at. Rename Pass' dumpPassStructure to dumpPass. This eliminates an awkward use of getAsPass() to convert a PMDataManager* into a Pass* just to permit a dumpPassStructure call. llvm-svn: 111199
2010-08-11Make LoopPass::getContainedPass return a LoopPass* instead of a Pass*Dan Gohman1-5/+5
and remove casts from all its callers. llvm-svn: 110848
2010-08-06Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson1-3/+3
llvm-svn: 110460
2010-08-06Revert r110396 to fix buildbots.Owen Anderson1-3/+3
llvm-svn: 110410
2010-08-05Don't use PassInfo* as a type identifier for passes. Instead, use the ↵Owen Anderson1-3/+3
address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. llvm-svn: 110396