summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/JumpThreading.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix an infinite alternation in JumpThreading where two transforms would ↵Owen Anderson2011-04-141-3/+15
| | | | | | | | | | repeatedly undo each other. The solution is to perform more aggressive constant folding to make one of the edges just folded away rather than trying to thread it. Fixes <rdar://problem/9284786>. Discovered with CSmith. llvm-svn: 129538
* Remove PHINode::reserveOperandSpace(). Instead, add a parameter toJay Foad2011-03-301-2/+2
| | | | | | PHINode::Create() giving the (known or expected) number of operands. llvm-svn: 128537
* (Almost) always call reserveOperandSpace() on newly created PHINodes.Jay Foad2011-03-301-2/+3
| | | | llvm-svn: 128535
* prevent jump threading from merging blocks when their address isChris Lattner2011-02-181-1/+11
| | | | | | | | | | | | | | | | | taken (and used!). This prevents merging the blocks (invalidating the block addresses) in a case like this: #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) void foo() { printf("%p\n", _THIS_IP_); printf("%p\n", _THIS_IP_); printf("%p\n", _THIS_IP_); } which fixes PR4151. llvm-svn: 125829
* Fix a bug in the loop in JumpThreading::ProcessThreadableEdges() where it ↵Frits van Bommel2010-12-161-2/+2
| | | | | | | | could falsely produce a MultipleDestSentinel value if the first predecessor ended with an 'indirectbr'. If that happened, it caused an unnecessary FindMostPopularDest() call. This wasn't a correctness problem, but it broke the fast path for single-predecessor blocks. llvm-svn: 121966
* Teach jump threading to "look through" a select when the branch direction of ↵Frits van Bommel2010-12-151-0/+34
| | | | | | | | a terminator depends on it. When it sees a promising select it now tries to figure out whether the condition of the select is known in any of the predecessors and if so it maps the operands appropriately. llvm-svn: 121859
* simplify code and reduce indentationChris Lattner2010-12-131-32/+30
| | | | llvm-svn: 121670
* Remove some dead code from the jump threading pass.Frits van Bommel2010-12-071-141/+0
| | | | | | The last uses of these functions were removed in r113852 when LazyValueInfo was permanently enabled and removed the need for them. llvm-svn: 121133
* Implement jump threading of 'indirectbr' by keeping track of whether we're ↵Frits van Bommel2010-12-061-46/+80
| | | | | | looking for ConstantInt*s or BlockAddress*s. llvm-svn: 121066
* Refactor jump threading.Frits van Bommel2010-12-051-69/+73
| | | | | | | Should have no functional change other than the order of two transformations that are mutually-exclusive and the exact formatting of debug output. Internally, it now stores the ConstantInt*s as Constant*s, and actual undef values instead of nulls. llvm-svn: 120946
* Remove trailing whitespace.Frits van Bommel2010-12-051-208/+208
| | | | llvm-svn: 120945
* Get rid of static constructors for pass registration. Instead, every pass ↵Owen Anderson2010-10-191-1/+3
| | | | | | | | | | | | | | | | | exposes an initializeMyPassFunction(), which must be called in the pass's constructor. This function uses static dependency declarations to recursively initialize the pass's dependencies. Clients that only create passes through the createFooPass() APIs will require no changes. Clients that want to use the CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h before parsing commandline arguments. I have tested this with all standard configurations of clang and llvm-gcc on Darwin. It is possible that there are problems with the static dependencies that will only be visible with non-standard options. If you encounter any crash in pass registration/creation, please send the testcase to me directly. llvm-svn: 116820
* Begin adding static dependence information to passes, which will allow us toOwen Anderson2010-10-121-1/+4
| | | | | | | | | perform initialization without static constructors AND without explicit initialization by the client. For the moment, passes are required to initialize both their (potential) dependencies and any passes they preserve. I hope to be able to relax the latter requirement in the future. llvm-svn: 116334
* Now with fewer extraneous semicolons!Owen Anderson2010-10-071-1/+1
| | | | llvm-svn: 115996
* Fix PR8247: JumpThreading can cause a block to become unreachable while ↵Owen Anderson2010-09-291-4/+4
| | | | | | | | | | still having predecessor, if it is part of a self-loop. Because of this, we cannot use the Simplify* APIs, as they can assert-fail on unreachable code. Since it's not easy to determine if a given threading will cause a block to become unreachable, simply defer simplifying simplification to later InstCombine and/or DCE passes. llvm-svn: 115082
* Remove the option to disable LazyValueInfo in JumpThreading, as it is nowOwen Anderson2010-09-141-110/+37
| | | | | | on by default and has received significant testing. llvm-svn: 113852
* Change lower atomic pass to use IntrinsicInst to simplify it a bit.Chris Lattner2010-09-051-4/+3
| | | | llvm-svn: 113114
* eliminate some non-obvious casts. UndefValue isa Constant.Chris Lattner2010-09-051-4/+4
| | | | llvm-svn: 113113
* Reapply commit 112699, speculatively reverted by echristo, sinceDuncan Sands2010-09-021-2/+2
| | | | | | | | | I'm sure it is harmless. Original commit message: If PrototypeValue is erased in the middle of using the SSAUpdator then the SSAUpdator may access freed memory. Instead, simply pass in the type and name explicitly, which is all that was used anyway. llvm-svn: 112810
* JumpThreading keeps LazyValueInfo up to date, so we don't need to rerun itOwen Anderson2010-09-011-1/+3
| | | | | | if we schedule another LVI-using pass afterwards. llvm-svn: 112722
* Speculatively revert 112699 and 112702, they seem to be causingEric Christopher2010-09-011-2/+2
| | | | | | self host errors on clang-x86-64. llvm-svn: 112719
* If PrototypeValue is erased in the middle of using the SSAUpdatorDuncan Sands2010-09-011-2/+2
| | | | | | | then the SSAUpdator may access freed memory. Instead, simply pass in the type and name explicitly, which is all that was used anyway. llvm-svn: 112699
* More cleanups of my JumpThreading transforms, including extracting some ↵Owen Anderson2010-08-311-37/+26
| | | | | | duplicated code into a helper function. llvm-svn: 112634
* Add an RAII helper to make cleanup of the RecursionSet more fool-proof.Owen Anderson2010-08-311-18/+24
| | | | llvm-svn: 112628
* Refactor my fix for PR5652 to terminate the predecessor lookups after the ↵Owen Anderson2010-08-311-25/+24
| | | | | | first failure. llvm-svn: 112620
* More Chris-inspired JumpThreading fixes: use ConstantExpr to correctly ↵Owen Anderson2010-08-311-26/+64
| | | | | | | | | constant-fold undef, and be more careful with its return value. This actually exposed an infinite recursion bug in ComputeValueKnownInPredecessors which theoretically already existed (in JumpThreading's handling of and/or of i1's), but never manifested before. This patch adds a tracking set to prevent this case. llvm-svn: 112589
* Re-apply r112539, being more careful to respect the return values of the ↵Owen Anderson2010-08-301-22/+25
| | | | | | | | constant folding methods. Additionally, use the ConstantExpr::get*() methods to simplify some constant folding. llvm-svn: 112550
* Revert r112539. It accidentally introduced a miscompilation.Owen Anderson2010-08-301-20/+16
| | | | llvm-svn: 112543
* Fixes and cleanups pointed out by Chris. In general, be careful to handle 0 ↵Owen Anderson2010-08-301-16/+20
| | | | | | | | results from ComputeValueKnownInPredecessors (indicating undef), and re-use existing constant folding APIs. llvm-svn: 112539
* Fix typos in comments.Owen Anderson2010-08-271-2/+2
| | | | llvm-svn: 112286
* Use LVI to eliminate conditional branches where we've tested a related ↵Owen Anderson2010-08-271-0/+39
| | | | | | | | condition previously. Update tests for this change. This fixes PR5652. llvm-svn: 112270
* Make JumpThreading smart enough to properly thread StrSwitch when it's ↵Owen Anderson2010-08-261-17/+77
| | | | | | compiled with clang++. llvm-svn: 112198
* Turn LVI on, previously detected failures should be fixed now.Owen Anderson2010-08-241-1/+1
| | | | llvm-svn: 111923
* Turn LVI back off, I have a testcase now.Owen Anderson2010-08-231-1/+1
| | | | llvm-svn: 111834
* Re-enable LazyValueInfo. Monitoring for failures.Owen Anderson2010-08-231-1/+1
| | | | llvm-svn: 111816
* Disable LVI while I evaluate a failure.Owen Anderson2010-08-191-1/+1
| | | | llvm-svn: 111551
* Tentatively enabled LVI by default. I'll be monitoring for any failures.Owen Anderson2010-08-191-1/+1
| | | | llvm-svn: 111543
* Inform LazyValueInfo whenever a block is deleted, to avoid dangling pointer ↵Owen Anderson2010-08-181-0/+7
| | | | | | issues. llvm-svn: 111382
* Fix PR7755: knowing something about an inval for a predChris Lattner2010-08-181-8/+4
| | | | | | | | | from the LHS should disable reconsidering that pred on the RHS. However, knowing something about the pred on the RHS shouldn't disable subsequent additions on the RHS from happening. llvm-svn: 111349
* Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson2010-08-061-1/+1
| | | | llvm-svn: 110460
* Revert r110396 to fix buildbots.Owen Anderson2010-08-061-1/+1
| | | | llvm-svn: 110410
* Don't use PassInfo* as a type identifier for passes. Instead, use the ↵Owen Anderson2010-08-051-1/+1
| | | | | | | | address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. llvm-svn: 110396
* Give JumpThreading+LVI a long-form cl::opt so that it's easier to toggle the ↵Owen Anderson2010-08-051-1/+4
| | | | | | default. llvm-svn: 110384
* Add an initial implementation of LazyValueInfo updating for JumpThreading. ↵Owen Anderson2010-07-261-0/+3
| | | | | | Disabled for now. llvm-svn: 109424
* Fix batch of converting RegisterPass<> to INTIALIZE_PASS().Owen Anderson2010-07-211-2/+2
| | | | llvm-svn: 109045
* cache results of operator*Gabor Greif2010-07-121-21/+31
| | | | llvm-svn: 108142
* if jump threading is able to infer interesting values on bothChris Lattner2010-07-121-2/+13
| | | | | | | | the LHS and RHS of an and/or instruction, don't multiply add known predecessor values. This fixes the crash on testcase from PR7498 llvm-svn: 108114
* jump threading can't split a critical edge from an indirectbr. ThisChris Lattner2010-06-141-1/+6
| | | | | | fixes PR7356. llvm-svn: 105950
* Move FindAvailableLoadedValue isSafeToLoadUnconditionally out ofDan Gohman2010-05-281-0/+1
| | | | | | | lib/Transforms/Utils and into lib/Analysis so that Analysis passes can use them. llvm-svn: 104949
* fix PR6743, a case where we'd delete an instruction before using itChris Lattner2010-04-101-1/+3
| | | | | | in some cases. llvm-svn: 100937
OpenPOWER on IntegriCloud