summaryrefslogtreecommitdiff
path: root/include/llvm/Transforms/Scalar.h
Commit message (Collapse)AuthorAge
* revert r166264 because the LTO build is still failingNadav Rotem2012-10-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166340 91177308-0d34-0410-b5e6-96231b3b80d8
* recommit the patch that makes LSR and LowerInvoke use the TargetTransform ↵Nadav Rotem2012-10-19
| | | | | | interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166264 91177308-0d34-0410-b5e6-96231b3b80d8
* Temporarily revert the TargetTransform changes.Bob Wilson2012-10-18
| | | | | | | | | | | The TargetTransform changes are breaking LTO bootstraps of clang. I am working with Nadav to figure out the problem, but I am reverting it for now to get our buildbots working. This reverts svn commits: 165665 165669 165670 165786 165787 165997 and I have also reverted clang svn 165741 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166168 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new interface to allow IR-level passes to access codegen-specific ↵Nadav Rotem2012-10-10
| | | | | | information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165665 91177308-0d34-0410-b5e6-96231b3b80d8
* Port the SSAUpdater-based promotion logic from the old SROA pass to theChandler Carruth2012-09-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | new one, and add support for running the new pass in that mode and in that slot of the pass manager. With this the new pass can completely replace the old one within the pipeline. The strategy for enabling or disabling the SSAUpdater logic is to do it by making the requirement of the domtree analysis optional. By default, it is required and we get the standard mem2reg approach. This is usually the desired strategy when run in stand-alone situations. Within the CGSCC pass manager, we disable requiring of the domtree analysis and consequentially trigger fallback to the SSAUpdater promotion. In theory this would allow the pass to re-use a domtree if one happened to be available even when run in a mode that doesn't require it. In practice, it lets us have a single pass rather than two which was simpler for me to wrap my head around. There is a hidden flag to force the use of the SSAUpdater code path for the purpose of testing. The primary testing strategy is just to run the existing tests through that path. One notable difference is that it has custom code to handle lifetime markers, and one of the tests has been enhanced to exercise that code. This has survived a bootstrap and the test suite without serious correctness issues, however my run of the test suite produced *very* alarming performance numbers. I don't entirely understand or trust them though, so more investigation is on-going. To aid my understanding of the performance impact of the new SROA now that it runs throughout the optimization pipeline, I'm enabling it by default in this commit, and will disable it again once the LNT bots have picked up one iteration with it. I want to get those bots (which are much more stable) to evaluate the impact of the change before I jump to any conclusions. NOTE: Several Clang tests will fail because they run -O3 and check the result's order of output. They'll go back to passing once I disable it again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163965 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a new SROA implementation.Chandler Carruth2012-09-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is essentially a ground up re-think of the SROA pass in LLVM. It was initially inspired by a few problems with the existing pass: - It is subject to the bane of my existence in optimizations: arbitrary thresholds. - It is overly conservative about which constructs can be split and promoted. - The vector value replacement aspect is separated from the splitting logic, missing many opportunities where splitting and vector value formation can work together. - The splitting is entirely based around the underlying type of the alloca, despite this type often having little to do with the reality of how that memory is used. This is especially prevelant with unions and base classes where we tail-pack derived members. - When splitting fails (often due to the thresholds), the vector value replacement (again because it is separate) can kick in for preposterous cases where we simply should have split the value. This results in forming i1024 and i2048 integer "bit vectors" that tremendously slow down subsequnet IR optimizations (due to large APInts) and impede the backend's lowering. The new design takes an approach that fundamentally is not susceptible to many of these problems. It is the result of a discusison between myself and Duncan Sands over IRC about how to premptively avoid these types of problems and how to do SROA in a more principled way. Since then, it has evolved and grown, but this remains an important aspect: it fixes real world problems with the SROA process today. First, the transform of SROA actually has little to do with replacement. It has more to do with splitting. The goal is to take an aggregate alloca and form a composition of scalar allocas which can replace it and will be most suitable to the eventual replacement by scalar SSA values. The actual replacement is performed by mem2reg (and in the future SSAUpdater). The splitting is divided into four phases. The first phase is an analysis of the uses of the alloca. This phase recursively walks uses, building up a dense datastructure representing the ranges of the alloca's memory actually used and checking for uses which inhibit any aspects of the transform such as the escape of a pointer. Once we have a mapping of the ranges of the alloca used by individual operations, we compute a partitioning of the used ranges. Some uses are inherently splittable (such as memcpy and memset), while scalar uses are not splittable. The goal is to build a partitioning that has the minimum number of splits while placing each unsplittable use in its own partition. Overlapping unsplittable uses belong to the same partition. This is the target split of the aggregate alloca, and it maximizes the number of scalar accesses which become accesses to their own alloca and candidates for promotion. Third, we re-walk the uses of the alloca and assign each specific memory access to all the partitions touched so that we have dense use-lists for each partition. Finally, we build a new, smaller alloca for each partition and rewrite each use of that partition to use the new alloca. During this phase the pass will also work very hard to transform uses of an alloca into a form suitable for promotion, including forming vector operations, speculating loads throguh PHI nodes and selects, etc. After splitting is complete, each newly refined alloca that is a candidate for promotion to a scalar SSA value is run through mem2reg. There are lots of reasonably detailed comments in the source code about the design and algorithms, and I'm going to be trying to improve them in subsequent commits to ensure this is well documented, as the new pass is in many ways more complex than the old one. Some of this is still a WIP, but the current state is reasonbly stable. It has passed bootstrap, the nightly test suite, and Duncan has run it successfully through the ACATS and DragonEgg test suites. That said, it remains behind a default-off flag until the last few pieces are in place, and full testing can be done. Specific areas I'm looking at next: - Improved comments and some code cleanup from reviews. - SSAUpdater and enabling this pass inside the CGSCC pass manager. - Some datastructure tuning and compile-time measurements. - More aggressive FCA splitting and vector formation. Many thanks to Duncan Sands for the thorough final review, as well as Benjamin Kramer for lots of review during the process of writing this pass, and Daniel Berlin for reviewing the data structures and algorithms and general theory of the pass. Also, several other people on IRC, over lunch tables, etc for lots of feedback and advice. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163883 91177308-0d34-0410-b5e6-96231b3b80d8
* move the bounds checking pass to the instrumentation folder, where it ↵Nuno Lopes2012-07-20
| | | | | | | | belongs. I dunno why in the world I dropped it in the Scalar folder in the first place. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160587 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a number of threshold arguments to the SRA pass.Nadav Rotem2012-06-21
| | | | | | | | A patch by Tom Stellard with minor changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158918 91177308-0d34-0410-b5e6-96231b3b80d8
* add a new pass to instrument loads and stores for run-time bounds checkingNuno Lopes2012-05-22
| | | | | | | | move EmitGEPOffset from InstCombine to Transforms/Utils/Local.h (a draft of this) patch reviewed by Andrew, thanks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157261 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new ObjC ARC optimization pass to eliminate unneededDan Gohman2012-01-17
| | | | | | | autorelease push+pop pairs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148330 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove reference to dead GEPSplitterPass. PR11506.Eli Friedman2011-12-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146195 91177308-0d34-0410-b5e6-96231b3b80d8
* svn mv Target/ARM/ARMGlobalMerge.cpp Transforms/Scalar/GlobalMerge.cppDevang Patel2011-10-17
| | | | | | | There is no reason to have simple IR level pass in lib/Target. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142200 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the old tail duplication pass. It is not used and is unable to updateRafael Espindola2011-08-30
| | | | | | | ssa, so it has to be run really early in the pipeline. Any replacement should probably use the SSAUpdater. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138841 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce "expect" intrinsic instructions.Jakub Staszak2011-07-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134516 91177308-0d34-0410-b5e6-96231b3b80d8
* The ARC language-specific optimizer. Credit to Dan Gohman.John McCall2011-06-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133108 91177308-0d34-0410-b5e6-96231b3b80d8
* Passing unroll parameters (unroll-count, threshold, and partial unroll) via ↵Junjie Gu2011-04-13
| | | | | | | | | | | LoopUnroll class's ctor. Doing so will allow multiple context with different loop unroll parameters to run. This is a minor change and no effect on existing application. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129449 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete the SimplifyHalfPowrLibCalls pass, which was unused, andDan Gohman2011-02-28
| | | | | | | only existed as the result of a misunderstanding. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126669 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove outdated references to dominance frontiers.Cameron Zwarich2011-01-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123724 91177308-0d34-0410-b5e6-96231b3b80d8
* split SROA into two passes: one that uses DomFrontiers (-scalarrepl) Chris Lattner2011-01-14
| | | | | | | and one that uses SSAUpdater (-scalarrepl-ssa) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123436 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new loop-instsimplify pass, with the intention of replacing the instanceCameron Zwarich2011-01-03
| | | | | | | | of instcombine that is currently in the middle of the loop pass pipeline. This commit only checks in the pass; it will hopefully be enabled by default later. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122719 91177308-0d34-0410-b5e6-96231b3b80d8
* sketch out a new early cse pass. No functionality yet.Chris Lattner2011-01-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122713 91177308-0d34-0410-b5e6-96231b3b80d8
* Start of a pass for recognizing memset and memcpy idioms.Chris Lattner2010-12-26
| | | | | | | No functionality yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122562 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new convenience pass for testing InstructionSimplify. PreviouslyDuncan Sands2010-12-20
| | | | | | | | | | it could only be tested indirectly, via instcombine, gvn or some other pass that makes use of InstructionSimplify, which means that testcases had to be carefully contrived to dance around any other transformations that that pass did. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122264 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove LoopIndexSplit pass. It is neither maintained nor used by anyone.Devang Patel2010-10-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116004 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename ValuePropagation to a more descriptive CorrelatedValuePropagation.Owen Anderson2010-08-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112591 91177308-0d34-0410-b5e6-96231b3b80d8
* remove the ABCD and SSI passes. They don't have any clients thatChris Lattner2010-08-28
| | | | | | | | I'm aware of, aren't maintained, and LVI will be replacing their value. nlewycky approved this on irc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112355 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a prototype of a new peephole optimizing pass that uses LazyValue info ↵Owen Anderson2010-08-27
| | | | | | | | | to simplify PHIs and select's. This pass addresses the missed optimizations from PR2581 and PR4420. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112325 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate PromoteMemoryToRegisterID; just use addPreserved("mem2reg")Dan Gohman2010-08-06
| | | | | | | instead, as an example of what this looks like. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110478 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson2010-08-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110460 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r110396 to fix buildbots.Owen Anderson2010-08-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110410 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use PassInfo* as a type identifier for passes. Instead, use the ↵Owen Anderson2010-08-05
| | | | | | | | | address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110396 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an atomic lowering passPeter Collingbourne2010-08-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110113 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an LLVM IR version of code sinking. This uses the same simple algorithmDan Gohman2010-05-07
| | | | | | | as MachineSink, but it isn't constrained by MachineInstr-level details. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103257 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a problem that lower invoke has with allocas (PR6694), and Chris Lattner2010-04-26
| | | | | | | | | | add a version of createLowerInvokePass that allows the client to specify whether it wants "expensive" or "cheap" lowering. Patch by Alex Mac! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102402 91177308-0d34-0410-b5e6-96231b3b80d8
* SCCVN, we hardly knew ye!Owen Anderson2010-04-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101117 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r97245 which seems to be causing performance problems.Bob Wilson2010-02-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97366 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the EnableFullLoadPRE flag from a separate command-line option to anBob Wilson2010-02-26
| | | | | | | argument of createGVNPass and set it automatically for -O3. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97245 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused "NoPRE" parameter in GVN and createGVNPass().Bob Wilson2010-02-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97235 91177308-0d34-0410-b5e6-96231b3b80d8
* Pull these back out, they're a little too aggressive and timeEric Christopher2010-02-09
| | | | | | | consuming for a simple optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95671 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new pass to do llvm.objsize lowering using SCEV.Eric Christopher2010-02-09
| | | | | | | | | | | | | Initial skeleton and SCEVUnknown lowering implemented, the rest should come relatively quickly. Move testcase to new directory. Move pass to right before SimplifyLibCalls - which is moved down a bit so we can take advantage of a few opts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95628 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an option for running GVN with redundant load processing disabled.Dan Gohman2009-11-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88742 91177308-0d34-0410-b5e6-96231b3b80d8
* remove the now dead condprop pass, PR3906.Chris Lattner2009-11-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86810 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove CodeGenLICM. It's largely obsoleted by MachineLICM's new abilityDan Gohman2009-10-31
| | | | | | | to unfold loop-invariant loads. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85657 91177308-0d34-0410-b5e6-96231b3b80d8
* Add option to createGVNPass to disable PRE.Evan Cheng2009-10-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85609 91177308-0d34-0410-b5e6-96231b3b80d8
* Add ABCD, a generalized implementation of the Elimination of Array BoundsNick Lewycky2009-10-28
| | | | | | | | | Checks on Demand algorithm which looks at arbitrary branches instead of loop iterations. This is GSoC work by Andre Tavares with only editorial changes applied! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85382 91177308-0d34-0410-b5e6-96231b3b80d8
* Forgot to commit these.Owen Anderson2009-10-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85180 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove FreeInst.Victor Hernandez2009-10-26
| | | | | | | | | Remove LowerAllocations pass. Update some more passes to treate free calls just like they were treating FreeInst. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85176 91177308-0d34-0410-b5e6-96231b3b80d8
* Check in the experimental GEP splitter pass. This pass splits complexDan Gohman2009-10-26
| | | | | | | | | | | GEPs (more than one non-zero index) into simple GEPs (at most one non-zero index). In some simple experiments using this it's not uncommon to see 3% overall code size wins, because it exposes redundancies that can be eliminated, however it's tricky to use because instcombine aggressively undoes the work that this pass does. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85144 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove MallocInst from LLVM Instructions.Victor Hernandez2009-10-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84299 91177308-0d34-0410-b5e6-96231b3b80d8
* remove predicate simplifier, it never got the last bugs beatenChris Lattner2009-10-06
| | | | | | | | | out of it, and jump threading, condprop and gvn are now getting most of the benefit. This was approved by Nicholas and Nicolas. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83390 91177308-0d34-0410-b5e6-96231b3b80d8