aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/SparsePropagation.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-06-26Apply clang-tidy's modernize-loop-convert to lib/Analysis.Benjamin Kramer1-2/+2
Only minor manual fixes. No functionality change intended. llvm-svn: 273816
2015-10-10Analysis: Remove implicit ilist iterator conversionsDuncan P. N. Exon Smith1-7/+7
Remove implicit ilist iterator conversions from LLVMAnalysis. I came across something really scary in `llvm::isKnownNotFullPoison()` which relied on `Instruction::getNextNode()` being completely broken (not surprising, but scary nevertheless). This function is documented (and coded to) return `nullptr` when it gets to the sentinel, but with an `ilist_half_node` as a sentinel, the sentinel check looks into some other memory and we don't recognize we've hit the end. Rooting out these scary cases is the reason I'm removing the implicit conversions before doing anything else with `ilist`; I'm not at all surprised that clients rely on badness. I found another scary case -- this time, not relying on badness, just bad (but I guess getting lucky so far) -- in `ObjectSizeOffsetEvaluator::compute_()`. Here, we save out the insertion point, do some things, and then restore it. Previously, we let the iterator auto-convert to `Instruction*`, and then set it back using the `Instruction*` version: Instruction *PrevInsertPoint = Builder.GetInsertPoint(); /* Logic that may change insert point */ if (PrevInsertPoint) Builder.SetInsertPoint(PrevInsertPoint); The check for `PrevInsertPoint` doesn't protect correctly against bad accesses. If the insertion point has been set to the end of a basic block (i.e., `SetInsertPoint(SomeBB)`), then `GetInsertPoint()` returns an iterator pointing at the list sentinel. The version of `SetInsertPoint()` that's getting called will then call `PrevInsertPoint->getParent()`, which explodes horribly. The only reason this hasn't blown up is that it's fairly unlikely the builder is adding to the end of the block; usually, we're adding instructions somewhere before the terminator. llvm-svn: 249925
2014-04-22[Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth1-1/+2
definition below all the header #include lines, lib/Analysis/... edition. This one has a bit extra as there were *other* #define's before #include lines in addition to DEBUG_TYPE. I've sunk all of them as a block. llvm-svn: 206843
2014-04-15[C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper1-2/+2
instead of comparing to nullptr. llvm-svn: 206243
2014-03-09[C++11] Add range based accessors for the Use-Def chain of a Value.Chandler Carruth1-5/+4
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
2013-01-02Move all of the header files which are involved in modelling the LLVM IRChandler Carruth1-3/+3
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
2012-03-08Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:Stepan Dyatkovskiy1-3/+2
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
2012-02-01SwitchInst refactoring.Stepan Dyatkovskiy1-1/+2
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
2011-11-15Remove all remaining uses of Value::getNameStr().Benjamin Kramer1-2/+2
llvm-svn: 144648
2009-12-23Convert debug messages to use dbgs(). Generally this meansDavid Greene1-4/+4
s/errs/dbgs/g except for certain special cases. llvm-svn: 92068
2009-12-18Eliminate unnecessary LLVMContexts.Dan Gohman1-2/+1
llvm-svn: 91729
2009-10-28rename indbr -> indirectbr to appease the residents of #llvm.Chris Lattner1-1/+1
llvm-svn: 85351
2009-10-27make the build build.Chris Lattner1-1/+1
llvm-svn: 85319
2009-10-27Random updates to passes for indbr, I need blockaddress before I can do much ↵Chris Lattner1-0/+5
more. llvm-svn: 85316
2009-09-19Add a comment explaining why you would ever want to do this.Nick Lewycky1-0/+3
llvm-svn: 82319
2009-09-19Lett users of sparse propagation do their own thing with phi nodes if they wantNick Lewycky1-0/+7
to. This can be combined with LCSSA or SSI form to store more information on a PHINode than can be computed by looking at its incoming values. llvm-svn: 82317
2009-09-18Add newlines.Nick Lewycky1-2/+2
llvm-svn: 82206
2009-08-23eliminate the "Value" printing methods that print to a std::ostream.Chris Lattner1-2/+2
This required converting a bunch of stuff off DOUT and other cleanups. llvm-svn: 79819
2009-07-31Move getTrue() and getFalse() to 2.5-like APIs.Owen Anderson1-1/+1
llvm-svn: 77685
2009-07-26Remove Value::getName{Start,End}, the last of the old Name APIs.Daniel Dunbar1-5/+6
llvm-svn: 77152
2009-07-21Rename getConstantInt{True|False} to get{True|False} at Chris' behest.Owen Anderson1-1/+1
llvm-svn: 76598
2009-07-06Finish LLVMContext-ing lib/Analysis. This required pushing LLVMContext's ↵Owen Anderson1-1/+2
through the ValueTracking API. llvm-svn: 74873
2009-03-11Make Print callable from a pass's print method: add const qualifier. NoTorok Edwin1-1/+1
functionality change. llvm-svn: 66700
2008-08-09"This patch adds a virtual call to AbstractLatticeFunction to derive a Chris Lattner1-1/+3
type lattice value for an Argument*, giving clients the opportunity to use something other than Top for it if they choose to." Patch by John McCall! llvm-svn: 54589
2008-05-27Use Function::getEntryBlock instead of Function::begin, for clarity.Dan Gohman1-1/+1
llvm-svn: 51613
2008-05-27Print debug output when any edge becomes executable, includingDan Gohman1-3/+3
the first visited edge. llvm-svn: 51612
2008-05-20Add a bool to isEdgeFeasible that tells it whether to treat unknownChris Lattner1-7/+19
value as undef or untracked. llvm-svn: 51295
2008-05-12prune #includes.Chris Lattner1-3/+0
llvm-svn: 50962
2008-05-12Add a new SparsePropagation analysis utility, which allows you to doChris Lattner1-0/+320
SCCP like sparse lattice analysis with relative ease. Just pick your lattice function and implement the transfer function and you're good. Just make sure you don't break monotonicity ;-) llvm-svn: 50961