summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/PHITransAddr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [PHITransAddr] Don't assume that instruction operands are translatableDavid Majnemer2015-08-091-3/+4
| | | | | | | | | | | | | We can only PHI translate instructions. In our attempt to PHI translate a bitcast, we attempt to translate its operand; however, the operand might be an argument or a global instead of an instruction. Benignly bail out when this happens. This fixes PR24397. Differential Revision: http://reviews.llvm.org/D11879 llvm-svn: 244418
* [GVN] Set proper debug locations for some instructions created by GVN.Alexey Samsonov2015-06-101-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Determining proper debug locations for instructions created in PHITransAddr is tricky. We use a simple approach here and simply copy debug locations from instructions computing load address to "corresponding" instructions re-creating the address computation in predecessor basic blocks. This may not always be correct, given all the rearrangement and simplification going on, and debug locations may jump around a lot, as the basic blocks we copy locations between may be very far from each other. Still, this would work good in most simple cases (e.g. when chain of address computing instruction is short, or our mapping turns out to be 1-to-1), and we desire to have *some* reasonable debug locations associated with newly inserted instructions. See http://reviews.llvm.org/D10351 review thread for more details. Test Plan: regression test suite Reviewers: spatel, dblaikie Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10351 llvm-svn: 239479
* Replace loop with std::equal. NFC intended.Benjamin Kramer2015-06-091-7/+1
| | | | llvm-svn: 239430
* [PHITransAddr] Don't translate unreachable valuesDavid Majnemer2015-06-011-7/+12
| | | | | | | | | | | Unreachable values may use themselves in strange ways due to their dominance property. Attempting to translate through them can lead to infinite recursion, crashing LLVM. Instead, claim that we weren't able to translate the value. This fixes PR23096. llvm-svn: 238702
* [PHITransAddr] Use std::find instead of std::countDavid Majnemer2015-06-011-2/+4
| | | | | | | There is no need to visit all the elements if we are merely performing a membership check. NFCI. llvm-svn: 238701
* [opaque pointer type] more gep API migrationDavid Blaikie2015-03-141-4/+3
| | | | llvm-svn: 232274
* [PM] Split the AssumptionTracker immutable pass into two separate APIs:Chandler Carruth2015-01-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | a cache of assumptions for a single function, and an immutable pass that manages those caches. The motivation for this change is two fold. Immutable analyses are really hacks around the current pass manager design and don't exist in the new design. This is usually OK, but it requires that the core logic of an immutable pass be reasonably partitioned off from the pass logic. This change does precisely that. As a consequence it also paves the way for the *many* utility functions that deal in the assumptions to live in both pass manager worlds by creating an separate non-pass object with its own independent API that they all rely on. Now, the only bits of the system that deal with the actual pass mechanics are those that actually need to deal with the pass mechanics. Once this separation is made, several simplifications become pretty obvious in the assumption cache itself. Rather than using a set and callback value handles, it can just be a vector of weak value handles. The callers can easily skip the handles that are null, and eventually we can wrap all of this up behind a filter iterator. For now, this adds boiler plate to the various passes, but this kind of boiler plate will end up making it possible to port these passes to the new pass manager, and so it will end up factored away pretty reasonably. llvm-svn: 225131
* Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)Hal Finkel2014-09-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change, which allows @llvm.assume to be used from within computeKnownBits (and other associated functions in ValueTracking), adds some (optional) parameters to computeKnownBits and friends. These functions now (optionally) take a "context" instruction pointer, an AssumptionTracker pointer, and also a DomTree pointer, and most of the changes are just to pass this new information when it is easily available from InstSimplify, InstCombine, etc. As explained below, the significant conceptual change is that known properties of a value might depend on the control-flow location of the use (because we care that the @llvm.assume dominates the use because assumptions have control-flow dependencies). This means that, when we ask if bits are known in a value, we might get different answers for different uses. The significant changes are all in ValueTracking. Two main changes: First, as with the rest of the code, new parameters need to be passed around. To make this easier, I grouped them into a structure, and I made internal static versions of the relevant functions that take this structure as a parameter. The new code does as you might expect, it looks for @llvm.assume calls that make use of the value we're trying to learn something about (often indirectly), attempts to pattern match that expression, and uses the result if successful. By making use of the AssumptionTracker, the process of finding @llvm.assume calls is not expensive. Part of the structure being passed around inside ValueTracking is a set of already-considered @llvm.assume calls. This is to prevent a query using, for example, the assume(a == b), to recurse on itself. The context and DT params are used to find applicable assumptions. An assumption needs to dominate the context instruction, or come after it deterministically. In this latter case we only handle the specific case where both the assumption and the context instruction are in the same block, and we need to exclude assumptions from being used to simplify their own ephemeral values (those which contribute only to the assumption) because otherwise the assumption would prove its feeding comparison trivial and would be removed. This commit adds the plumbing and the logic for a simple masked-bit propagation (just enough to write a regression test). Future commits add more patterns (and, correspondingly, more regression tests). llvm-svn: 217342
* [C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper2014-04-151-22/+22
| | | | | | instead of comparing to nullptr. llvm-svn: 206243
* [C++11] Add range based accessors for the Use-Def chain of a Value.Chandler Carruth2014-03-091-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This requires a number of steps. 1) Move value_use_iterator into the Value class as an implementation detail 2) Change it to actually be a *Use* iterator rather than a *User* iterator. 3) Add an adaptor which is a User iterator that always looks through the Use to the User. 4) Wrap these in Value::use_iterator and Value::user_iterator typedefs. 5) Add the range adaptors as Value::uses() and Value::users(). 6) Update *all* of the callers to correctly distinguish between whether they wanted a use_iterator (and to explicitly dig out the User when needed), or a user_iterator which makes the Use itself totally opaque. Because #6 requires churning essentially everything that walked the Use-Def chains, I went ahead and added all of the range adaptors and switched them to range-based loops where appropriate. Also because the renaming requires at least churning every line of code, it didn't make any sense to split these up into multiple commits -- all of which would touch all of the same lies of code. The result is still not quite optimal. The Value::use_iterator is a nice regular iterator, but Value::user_iterator is an iterator over User*s rather than over the User objects themselves. As a consequence, it fits a bit awkwardly into the range-based world and it has the weird extra-dereferencing 'operator->' that so many of our iterators have. I think this could be fixed by providing something which transforms a range of T&s into a range of T*s, but that *can* be separated into another patch, and it isn't yet 100% clear whether this is the right move. However, this change gets us most of the benefit and cleans up a substantial amount of code around Use and User. =] llvm-svn: 203364
* Rename some member variables from TD to DL.Rafael Espindola2014-02-181-3/+3
| | | | | | TargetData was renamed DataLayout back in r165242. llvm-svn: 201581
* [cleanup] Move the Dominators.h and Verifier.h headers into the IRChandler Carruth2014-01-131-1/+1
| | | | | | | | | | | | | | | | | | directory. These passes are already defined in the IR library, and it doesn't make any sense to have the headers in Analysis. Long term, I think there is going to be a much better way to divide these matters. The dominators code should be fully separated into the abstract graph algorithm and have that put in Support where it becomes obvious that evn Clang's CFGBlock's can use it. Then the verifier can manually construct dominance information from the Support-driven interface while the Analysis library can provide a pass which both caches, reconstructs, and supports a nice update API. But those are very long term, and so I don't want to leave the really confusing structure until that day arrives. llvm-svn: 199082
* Correct word hyphenationsAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities and contractions in nearby lines. llvm-svn: 196471
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-021-2/+2
| | | | | | | | | | | | | | | | | | | | | into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. llvm-svn: 171366
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-2/+2
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
* Release build: guard dump functions withManman Ren2012-09-121-1/+1
| | | | | | | | "#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)" No functional change. Update r163344. llvm-svn: 163679
* Release build: guard dump functions with "ifndef NDEBUG"Manman Ren2012-09-061-0/+2
| | | | | | No functional change. llvm-svn: 163344
* Uniformize the InstructionSimplify interface by ensuring that all routinesDuncan Sands2012-03-131-1/+1
| | | | | | | | take a TargetLibraryInfo parameter. Internally, rather than passing TD, TLI and DT parameters around all over the place, introduce a struct for holding them. llvm-svn: 152623
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-2/+0
| | | | llvm-svn: 148578
* Move Instruction::isSafeToSpeculativelyExecute out of VMCore andDan Gohman2011-12-141-3/+4
| | | | | | | | | into Analysis as a standalone function, since there's no need for it to be in VMCore. Also, update it to use isKnownNonZero and other goodies available in Analysis, making it more precise, enabling more aggressive optimization. llvm-svn: 146610
* Propagate TargetLibraryInfo throughout ConstantFolding.cpp and Chad Rosier2011-12-011-1/+1
| | | | | | | InstructionSimplify.cpp. Other fixups as needed. Part of rdar://10500969 llvm-svn: 145559
* Shorten some expressions by using ArrayRef::slice().Frits van Bommel2011-07-251-2/+1
| | | | llvm-svn: 135910
* Convert GetElementPtrInst to use ArrayRef.Jay Foad2011-07-251-3/+4
| | | | llvm-svn: 135904
* Convert SimplifyGEPInst to use ArrayRef.Jay Foad2011-07-191-1/+1
| | | | llvm-svn: 135482
* Don't include Operator.h from InstrTypes.h.Jay Foad2011-04-111-0/+1
| | | | llvm-svn: 129271
* split dom frontier handling stuff out to its own DominanceFrontier header,Chris Lattner2011-01-021-0/+1
| | | | | | so that Dominators.h is *just* domtree. Also prune #includes a bit. llvm-svn: 122714
* Strip trailing whitespace.Dan Gohman2010-11-181-48/+48
| | | | llvm-svn: 119706
* Use llvm_unreachable for "impossible" situations.Dan Gohman2010-11-181-3/+6
| | | | llvm-svn: 119705
* Add support for PHI-translating sext, zext, and trunc instructions,Dan Gohman2010-11-181-18/+26
| | | | | | enabling more PRE. PR8586. llvm-svn: 119704
* In which I discover the existence of loops. Threading an operationDuncan Sands2010-11-161-2/+2
| | | | | | | | | | | over a phi node by applying it to each operand may be wrong if the operation and the phi node are mutually interdependent (the testcase has a simple example of this). So only do this transform if it would be correct to perform the operation in each predecessor of the block containing the phi, i.e. if the other operands all dominate the phi. This should fix the FFMPEG snow.c regression reported by İsmail Dönmez. llvm-svn: 119347
* Reapply r97010, the speculative revert failed.Daniel Dunbar2010-02-241-32/+28
| | | | llvm-svn: 97036
* Speculatively revert r97010, "Add an argument to PHITranslateValue to specifyDaniel Dunbar2010-02-241-28/+32
| | | | | | the DominatorTree. ...", in hopes of restoring poor old PPC bootstrap. llvm-svn: 97027
* Add an argument to PHITranslateValue to specify the DominatorTree. If thisBob Wilson2010-02-241-32/+28
| | | | | | | | | | | | | | | | | | | | argument is non-null, pass it along to PHITranslateSubExpr so that it can prefer using existing values that dominate the PredBB, instead of just blindly picking the first equivalent value that it finds on a uselist. Also when the DominatorTree is specified, have PHITranslateValue filter out any result that does not dominate the PredBB. This is basically just refactoring the check that used to be in GetAvailablePHITranslatedSubExpr and also in GVN. Despite my initial expectations, this change does not affect the results of GVN for any testcases that I could find, but it should help compile time. Before this change, if PHITranslateSubExpr picked a value that does not dominate, PHITranslateWithInsertion would then insert a new value, which GVN would later determine to be redundant and would replace. By picking a good value to begin with, we save GVN the extra work of inserting and then replacing a new value. llvm-svn: 97010
* Change dbgs() back to errs() as Chris requested.David Greene2009-12-231-4/+4
| | | | llvm-svn: 92085
* Convert debug messages to use dbgs(). Generally this meansDavid Greene2009-12-231-7/+8
| | | | | | s/errs/dbgs/g except for certain special cases. llvm-svn: 92046
* Add a minor optimization: if we haven't changed the operands of anChris Lattner2009-12-091-0/+4
| | | | | | | | | | add, there is no need to scan the world to find the same add again. This invalidates the previous testcase, which wasn't wonderful anyway, because it needed a run of instcombine to permute the use-lists in just the right way to before GVN was run (so it was really fragile). Not a big loss. llvm-svn: 90973
* fix PR5733, a case where we'd replace an add with a lexically identical Chris Lattner2009-12-091-1/+2
| | | | | | binary operator that wasn't an add. In this case, a xor. Whoops. llvm-svn: 90971
* fix a nasty variable that was shadowing the real CurBB but with the wrong value.Chris Lattner2009-12-091-1/+0
| | | | llvm-svn: 90920
* fix many input tracking bugs.Chris Lattner2009-12-091-33/+30
| | | | llvm-svn: 90915
* fix PHI translation to take the PHI out of the instinputs set and addChris Lattner2009-12-091-9/+7
| | | | | | the translated value back to it if an instruction. llvm-svn: 90909
* instructions defined in CurBB may be intermediate nodes of the computation.Chris Lattner2009-12-091-14/+14
| | | | llvm-svn: 90908
* add dumping and sanity checking support.Chris Lattner2009-12-091-0/+69
| | | | llvm-svn: 90906
* make sure that PHITransAddr keeps its 'InstInputs' list up toChris Lattner2009-12-081-3/+42
| | | | | | date when instsimplify kicks in. llvm-svn: 90901
* fix a typo (and -> add) and fix GetAvailablePHITranslatedSubExpr to not Chris Lattner2009-12-081-3/+6
| | | | | | side-effect the current object. llvm-svn: 90837
* fix typoChris Lattner2009-12-071-1/+1
| | | | llvm-svn: 90793
* add accessor, improve comment.Chris Lattner2009-12-071-1/+1
| | | | llvm-svn: 90792
* add support for phi translation and incorpation of new expression.Chris Lattner2009-12-071-121/+144
| | | | llvm-svn: 90782
* checkpoint of the new PHITransAddr code, still not done and not used byChris Lattner2009-12-071-29/+257
| | | | | | anything. llvm-svn: 90779
* add the start of a class used to handle phi translation in memdep andChris Lattner2009-12-041-0/+71
gvn (this is just a skeleton so far). This will ultimately be used to fix a nasty miscompilation with GVN. llvm-svn: 90518
OpenPOWER on IntegriCloud