summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/JumpThreading.cpp
Commit message (Collapse)AuthorAgeFilesLines
* SwitchInst refactoring.Stepan Dyatkovskiy2012-02-011-3/+4
| | | | | | | | | | | | | | | | | The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want. What was done: 1. Changed semantics of index inside the getCaseValue method: getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous. 2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned. 3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment. 4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst. 4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor. 4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor. Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang. llvm-svn: 149481
* SplitBlockPredecessors uses ArrayRef instead of Data and Size.Jakub Staszak2011-12-091-6/+3
| | | | llvm-svn: 146277
* Fix a few more places where TargetData/TargetLibraryInfo is not being passed.Chad Rosier2011-12-021-1/+6
| | | | | | Add FIXMEs to places that are non-trivial to fix. llvm-svn: 145661
* Change a bunch of isVolatile() checks to check for atomic load/store as well.Eli Friedman2011-09-121-2/+2
| | | | | | | | No tests; these changes aren't really interesting in the sense that the logic is the same for volatile and atomic. I believe this completes all of the changes necessary for the optimizer to handle loads and stores correctly. I'm going to try and come up with some additional testing, though. llvm-svn: 139533
* Calculate GetBestDestForJumpOnUndef correctly.Jakub Staszak2011-06-271-1/+3
| | | | llvm-svn: 133946
* Add a parameter to ConstantFoldTerminator() that callers can use to ask it ↵Frits van Bommel2011-05-221-1/+1
| | | | | | | | to also clean up the condition of any conditional terminator it folds to be unconditional, if that turns the condition into dead code. This just means it calls RecursivelyDeleteTriviallyDeadInstructions() in strategic spots. It defaults to the old behavior. I also changed -simplifycfg, -jump-threading and -codegenprepare to use this to produce slightly better code without any extra cleanup passes (AFAICT this was the only place in -simplifycfg where now-dead conditions of replaced terminators weren't being cleaned up). The only other user of this function is -sccp, but I didn't read that thoroughly enough to figure out whether it might be holding pointers to instructions that could be deleted by this. llvm-svn: 131855
* Preserve line number information while threading jumps.Devang Patel2011-05-041-2/+5
| | | | llvm-svn: 130880
* 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
OpenPOWER on IntegriCloud