summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SCCP.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix 80-column violation.Chad Rosier2012-03-281-2/+2
| | | | llvm-svn: 153556
* llvm::SwitchInstStepan Dyatkovskiy2012-03-111-3/+3
| | | | | | | Renamed methods caseBegin, caseEnd and caseDefault with case_begin, case_end, and case_default. Added some notes relative to case iterators. llvm-svn: 152532
* Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:Stepan Dyatkovskiy2012-03-081-12/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/136146.html Implemented CaseIterator and it solves almost all described issues: we don't need to mix operand/case/successor indexing anymore. Base iterator class is implemented as a template since it may be initialized either from "const SwitchInst*" or from "SwitchInst*". ConstCaseIt is just a read-only iterator. CaseIt is read-write iterator; it allows to change case successor and case value. Usage of iterator allows totally remove resolveXXXX methods. All indexing convertions done automatically inside the iterator's getters. Main way of iterator usage looks like this: SwitchInst *SI = ... // intialize it somehow for (SwitchInst::CaseIt i = SI->caseBegin(), e = SI->caseEnd(); i != e; ++i) { BasicBlock *BB = i.getCaseSuccessor(); ConstantInt *V = i.getCaseValue(); // Do something. } If you want to convert case number to TerminatorInst successor index, just use getSuccessorIndex iterator's method. If you want initialize iterator from TerminatorInst successor index, use CaseIt::fromSuccessorIndex(...) method. There are also related changes in llvm-clients: klee and clang. llvm-svn: 152297
* SwitchInst refactoring.Stepan Dyatkovskiy2012-02-011-10/+10
| | | | | | | | | | | | | | | | | 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
* Continue improving support for ConstantDataAggregate, and use theChris Lattner2012-01-261-8/+7
| | | | | | new methods recently added to (sometimes greatly!) simplify code. llvm-svn: 149024
* Remove trailing spaces and unneeded includes.Jakub Staszak2012-01-181-134/+131
| | | | llvm-svn: 148415
* Last bit of TargetLibraryInfo propagation. Also fixed a case for TargetDataChad Rosier2011-12-011-5/+22
| | | | | | | where it appeared beneficial to pass. More of rdar://10500969 llvm-svn: 145630
* Get rid of an optimization in SCCP which appears to have many issues. ↵Eli Friedman2011-11-111-167/+1
| | | | | | | | | | Specifically, it doesn't handle many cases involving undef correctly, and it is missing other checks which lead to it trying to re-mark a value marked as a constant with a different value. It also appears to trigger very rarely. Fixes PR11357. llvm-svn: 144352
* Make sure IPSCCP never marks a tracked call as overdefined in ↵Eli Friedman2011-09-201-9/+35
| | | | | | | | SCCPSolver::ResolvedUndefsIn. If we do, we can end up in a situation where a function is resolved to return a constant, but the caller is marked overdefined, which confuses the code later. <rdar://problem/9956541> (again). llvm-svn: 140210
* Use Duncan's patch to delete the instructions in reverse order (minus the ↵Bill Wendling2011-09-041-6/+10
| | | | | | landingpad and terminator). llvm-svn: 139090
* Update comments to reflect reality.Bill Wendling2011-09-021-2/+1
| | | | llvm-svn: 139023
* Change worklist driven deletion to be an iterative process.Bill Wendling2011-09-011-16/+7
| | | | | | Duncan noticed this! llvm-svn: 138967
* Make sure we aren't deleting the landingpad instruction.Bill Wendling2011-08-311-5/+21
| | | | | | | | | The landingpad instruction is required in the landing pad block. Because we're not deleting terminating instructions, the invoke may still jump to here (see Transforms/SCCP/2004-11-16-DeadInvoke.ll). Remove all uses of the landingpad instruction, but keep it around until code-gen can remove the basic block. llvm-svn: 138890
* Silly mistake from r137777; restore significant isStructTy() checks. While ↵Eli Friedman2011-08-171-4/+19
| | | | | | | | | | here, be a bit more defensive with unknown instructions. Fixes PR10687. llvm-svn: 137836
* A bunch of misc fixes to SCCPSolver::ResolvedUndefsIn, including a fix to stopEli Friedman2011-08-161-40/+72
| | | | | | | | | making random bad assumptions about instructions which are not explicitly listed. Includes fix for rdar://9956541, a version of "undef ^ undef should return 0 because it's easier than arguing with users". llvm-svn: 137777
* Minor bug in SCCP found by inspection. (I don't think it's possible to hit ↵Eli Friedman2011-08-161-0/+7
| | | | | | this with a normal pass pipeline, but fixing for completeness.) llvm-svn: 137755
* Initial commit of the 'landingpad' instruction.Bill Wendling2011-08-121-0/+1
| | | | | | | | | | | | This implements the 'landingpad' instruction. It's used to indicate that a basic block is a landing pad. There are several restrictions on its use (see LangRef.html for more detail). These restrictions allow the exception handling code to gather the information it needs in a much more sane way. This patch has the definition, implementation, C interface, parsing, and bitcode support in it. llvm-svn: 137501
* Add new atomic instructions to SCCP. No functional change, but stops debug ↵Eli Friedman2011-08-021-0/+2
| | | | | | spam. llvm-svn: 136723
* Add the 'resume' instruction for the new EH rewrite.Bill Wendling2011-07-311-0/+1
| | | | | | | | | This adds the 'resume' instruction class, IR parsing, and bitcode reading and writing. The 'resume' instruction resumes propagation of an existing (in-flight) exception whose unwinding was interrupted with a 'landingpad' instruction (to be added later). llvm-svn: 136589
* Revert r136253, r136263, r136269, r136313, r136325, r136326, r136329, r136338,Bill Wendling2011-07-301-2/+0
| | | | | | | r136339, r136341, r136369, r136387, r136392, r136396, r136429, r136430, r136444, r136445, r136446, r136253 pending review. llvm-svn: 136556
* Merge the contents from exception-handling-rewrite to the mainline.Bill Wendling2011-07-271-0/+2
| | | | | | This adds the new instructions 'landingpad' and 'resume'. llvm-svn: 136253
* Misc mid-level changes for new 'fence' instruction.Eli Friedman2011-07-271-0/+1
| | | | llvm-svn: 136205
* Add missing space (this line is no longer pushing the 80-column limit).Nick Lewycky2011-07-251-1/+1
| | | | llvm-svn: 135973
* Convert ConstantExpr::getGetElementPtr andJay Foad2011-07-211-2/+2
| | | | | | ConstantExpr::getInBoundsGetElementPtr to use ArrayRef. llvm-svn: 135673
* move tier out of an anonymous namespace, it doesn't make senseChris Lattner2011-07-211-10/+11
| | | | | | | | to for it to be an an anon namespace and be in a header. Eliminate some extraenous uses of tie. llvm-svn: 135669
* Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.Jay Foad2011-07-191-1/+1
| | | | llvm-svn: 135477
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-10/+10
| | | | llvm-svn: 135375
* PR7952: Make isa<> use the same logic as cast<>, so that they both workEli Friedman2011-05-211-1/+1
| | | | | | consistently. llvm-svn: 131803
* Fix a ton of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129558
* SCCP doesn't actually preserve the CFG. It will delete and insert terminatorNick Lewycky2011-01-211-4/+0
| | | | | | instructions. llvm-svn: 123973
* simplify a littleChris Lattner2011-01-161-7/+3
| | | | llvm-svn: 123573
* Avoid exponential growth of a table. It feels likeDale Johannesen2010-11-301-5/+22
| | | | | | there should be a better way to do this. PR 8679. llvm-svn: 120457
* Get rid of static constructors for pass registration. Instead, every pass ↵Owen Anderson2010-10-191-2/+6
| | | | | | | | | | | | | | | | | 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
* Now with fewer extraneous semicolons!Owen Anderson2010-10-071-2/+2
| | | | llvm-svn: 115996
* remove some dead code.Chris Lattner2010-08-181-3/+2
| | | | llvm-svn: 111344
* fix PR7876: If ipsccp decides that a function's address is takenChris Lattner2010-08-121-4/+15
| | | | | | before it rewrites the code, we need to use that in the post-rewrite pass. llvm-svn: 110962
* Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson2010-08-061-2/+2
| | | | llvm-svn: 110460
* Revert r110396 to fix buildbots.Owen Anderson2010-08-061-2/+2
| | | | llvm-svn: 110410
* Don't use PassInfo* as a type identifier for passes. Instead, use the ↵Owen Anderson2010-08-051-2/+2
| | | | | | | | address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. llvm-svn: 110396
* simplify by using CallSite constructors; virtually eliminates CallSite::get ↵Gabor Greif2010-07-281-2/+2
| | | | | | from the tree llvm-svn: 109687
* Fix batch of converting RegisterPass<> to INTIALIZE_PASS().Owen Anderson2010-07-211-4/+5
| | | | llvm-svn: 109045
* fix PR6940: sitofp(undef) folds to 0.0, not undef.Chris Lattner2010-04-261-0/+2
| | | | llvm-svn: 102358
* fix a SCCP miscompilation that could happen when aChris Lattner2010-04-091-3/+10
| | | | | | | | | forced constant is changed to a constant, we would end up adding the instruction to the wrong worklist, preventing it from being properly revisited. This fixes rdar://7832370 llvm-svn: 100837
* fix a really nasty bug that Evan was tracking in SCCP. When resolvingChris Lattner2010-04-051-29/+32
| | | | | | | | | | | | | | | | | | undefs in branches/switches, we have two cases: a branch on a literal undef or a branch on a symbolic value which is undef. If we have a literal undef, the code was correct: forcing it to a constant is the right thing to do. If we have a branch on a symbolic value that is undef, we should force the symbolic value to a constant, which then makes the successor block live. Forcing the condition of the branch to being a constant isn't safe if later paths become live and the value becomes overdefined. This is the case that 'forcedconstant' is designed to handle, so just use it. This fixes rdar://7765019 but there is no good testcase for this, the one I have is too insane to be useful in the future. llvm-svn: 100478
* Introduce ImmutableCallSite, useful for contexts where no mutationGabor Greif2010-04-011-1/+1
| | | | | | | | | is necessary. Inherits from new templated baseclass CallSiteBase<> which is highly customizable. Base CallSite on it too, in a configuration that allows full mutation. Adapt some call sites in analyses to employ ImmutableCallSite. llvm-svn: 100100
* rename use_const_iterator to const_use_iterator for consistency's sakeGabor Greif2010-03-251-1/+1
| | | | llvm-svn: 99564
* Finally land the InvokeInst operand reordering.Gabor Greif2010-03-241-1/+2
| | | | | | | | | | | | I have audited all getOperandNo calls now, fixing hidden assumptions. CallSite related uglyness will be eliminated successively. Note this patch has a long and griveous history, for all the back-and-forths have a look at CallSite.h's log. llvm-svn: 99399
* increase const goodness and remove pointless getUser() callsGabor Greif2010-03-241-7/+9
| | | | llvm-svn: 99395
* fix grammaro's pointed out by danielChris Lattner2010-02-271-2/+2
| | | | llvm-svn: 97313
* fix PR6414, a nondeterminism issue in IPSCCP which was becauseChris Lattner2010-02-271-1/+15
| | | | | | of a subtle interation in a loop operating in densemap order. llvm-svn: 97288
OpenPOWER on IntegriCloud