1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
Commit Graph

74 Commits

Author SHA1 Message Date
Stepan Dyatkovskiy
72fdcabd4d llvm::SwitchInst
Renamed methods caseBegin, caseEnd and caseDefault with case_begin, case_end, and case_default.
Added some notes relative to case iterators.

llvm-svn: 152532
2012-03-11 06:09:17 +00:00
Stepan Dyatkovskiy
79f3dd93b7 Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:
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-03-08 07:06:20 +00:00
Benjamin Kramer
2a3719125f LVI: Recognize the form instcombine canonicalizes range checks into when forming constant ranges.
This could probably be made a lot smarter, but this is a common case and doesn't require LVI to scan a lot
of code. With this change CVP can optimize away the "shift == 0" case in Hashing.h that only gets hit when
"shift" is in a range not containing 0.

llvm-svn: 151919
2012-03-02 15:34:43 +00:00
Stepan Dyatkovskiy
856ca370cc SwitchInst refactoring.
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
2012-02-01 07:49:51 +00:00
Bill Wendling
3820625bc1 Remove dead code.
llvm-svn: 148384
2012-01-18 10:10:28 +00:00
Bill Wendling
771a417c3f A DenseMap of a std::map isn't a very good idea because the "grow()" method will
need to make a deep copy of each of the std::maps. Use a std::map of the
std::map instead. This improves the compile time of sqlite3 by ~2%.

llvm-svn: 148003
2012-01-12 01:41:03 +00:00
Bill Wendling
9974bf8911 Revert r147978. A DenseMap's iterators may become invalidated here.
llvm-svn: 147980
2012-01-11 23:43:34 +00:00
Bill Wendling
e0f4bb054e Use a DenseMap.
This appears to improve sqlite3's compile time by ~2%.

llvm-svn: 147978
2012-01-11 22:57:32 +00:00
Benjamin Kramer
4ff0db784c Clear the new cache.
llvm-svn: 145771
2011-12-03 15:19:55 +00:00
Benjamin Kramer
ed1cd704e0 Add a "seen blocks" cache to LVI to avoid a linear scan over the whole cache just to remove no blocks from the maps.
-15% on ARMDisassembler.cpp (Release build).  It's not that great to add another
layer of caching to the caching-heavy LVI but I don't see a better way.

llvm-svn: 145770
2011-12-03 15:16:45 +00:00
Chad Rosier
fdca220a9e Fix a few more places where TargetData/TargetLibraryInfo is not being passed.
Add FIXMEs to places that are non-trivial to fix.

llvm-svn: 145661
2011-12-02 01:26:24 +00:00
Chris Lattner
e1fe7061ce land David Blaikie's patch to de-constify Type, with a few tweaks.
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Eli Friedman
05fea3b4a2 llvm.memcpy.* has two distinct associated address spaces; the source address space, and the destination address space. Fix up the interface on MemIntrinsic and MemTransferInst to make this clear, and fix InstructionDereferencesPointer in LazyValueInfo.cpp to use the interface properly.
llvm-svn: 132356
2011-05-31 20:40:16 +00:00
Jay Foad
c146569beb Remove unused STL header includes.
llvm-svn: 130068
2011-04-23 19:53:52 +00:00
Chandler Carruth
af6432924d Mark some functions as used which are used within debug-only code. This
silences Clang's -Wunused-function when building in release mode.

llvm-svn: 129709
2011-04-18 18:49:44 +00:00
Nick Lewycky
708df45c84 Teach LazyValueInfo that allocas aren't NULL. Over all of llvm-test, this saves
half a million non-local queries, each of which would otherwise have triggered a
linear scan over a basic block.

Also fix a fixme for memory intrinsics which dereference pointers. With this,
we prove that a pointer is non-null because it was dereferenced by an intrinsic
112 times in llvm-test.

llvm-svn: 123533
2011-01-15 09:16:12 +00:00
Owen Anderson
ba8ae674d7 Reorder, rename, and document some members to make this easier to follow.
llvm-svn: 122929
2011-01-05 23:26:22 +00:00
Owen Anderson
97bd86a5e7 When computing the value on an edge, in certain cases LVI would fail to compute the value range
in the predecessor block, leading to an incorrect conclusion for the edge value.  Found by inspection.

llvm-svn: 122908
2011-01-05 21:37:18 +00:00
Owen Anderson
3d7ba422df Re-convert several of LazyValueInfo's internal maps to Dense{Map|Set}, and fix the issue in
hasBlockValue() that was causing iterator invalidations.  Many thanks to Dimitry Andric for
tracking down those invalidations!

llvm-svn: 122906
2011-01-05 21:15:29 +00:00
Owen Anderson
308ca4e488 Speculatively revert the use of DenseMap in LazyValueInfo, which may be causing Linux self-host failures.
llvm-svn: 122291
2010-12-20 23:53:19 +00:00
Owen Anderson
b481f13b97 Attempt to appease the DragonEgg buildbots.
llvm-svn: 122288
2010-12-20 23:23:18 +00:00
Owen Anderson
006186c519 Convert one of LVI's primary maps to a DenseMap, now that we know are more assured of iterator stability.
llvm-svn: 122273
2010-12-20 21:30:54 +00:00
Owen Anderson
7a69be36e5 More LVI cleanups, including trying to simplify the process of maintaining the OverDefinedCache.
llvm-svn: 122256
2010-12-20 19:33:41 +00:00
Owen Anderson
2ebd7e9192 Reuse the reference into the LVI cache throughout the solver subsystem. This is much easier to
verify as being safe thanks its recent de-recursivization.

llvm-svn: 122254
2010-12-20 18:18:16 +00:00
Nick Lewycky
44a08d5812 Make LazyValueInfo non-recursive.
llvm-svn: 122120
2010-12-18 01:00:40 +00:00
Dan Gohman
295ba3ab26 Move Value::getUnderlyingObject to be a standalone
function so that it can live in Analysis instead of
VMCore.

llvm-svn: 121885
2010-12-15 20:02:24 +00:00
Nick Lewycky
44b582fb69 Clean up some of LVI:
* mergeIn now uses constant folding for constants that are provably not-equal.
 * sink some sanity checks from the get*() methods into the mark*() methods, to ensure that we never have a constant/notconstant ConstantInt
 * some textual cleanups, whitespace changes, removing "else" after return, that sort of thing.

llvm-svn: 121877
2010-12-15 18:57:18 +00:00
Owen Anderson
a882a78d4b Take the first step towards making LVI non-recursive: get rid of the LVIQuery abstraction.
llvm-svn: 121357
2010-12-09 06:14:58 +00:00
Owen Anderson
69cbf2e8b7 Now with fewer extraneous semicolons!
llvm-svn: 115996
2010-10-07 22:25:06 +00:00
Owen Anderson
6f3516065f It is possible, under specific circumstances involving ptrtoint ConstantExpr's, for LVI to end up trying to merge
a Constant into a ConstantRange.  Handle this conservatively for now, rather than asserting.  The testcase is
more complex that I would like, but the manifestation of the problem is sensitive to iteration orders and the state of the
LVI cache, and I have not been able to reproduce it with manually constructed or simplified cases.

Fixes PR8162.

llvm-svn: 114103
2010-09-16 18:28:33 +00:00
Owen Anderson
e15120e561 Clean up some of the PassRegistry implementation, and pImpl-ize it to reduce #include clutter
and exposing internal details.

llvm-svn: 113252
2010-09-07 19:16:25 +00:00
Nick Lewycky
9698dae1df Add completely hokey binary-and and binary-or operations to ConstantRange and
teach LazyValueInfo to use them.

llvm-svn: 113196
2010-09-07 05:39:02 +00:00
Chris Lattner
8df3ffd7ac zap dead code.
llvm-svn: 113073
2010-09-04 18:12:00 +00:00
Owen Anderson
9161c79ffe Add support for simplifying a load from a computed value to a load from a global when it
is provable that they're equivalent.  This fixes PR4855.

llvm-svn: 112994
2010-09-03 19:08:37 +00:00
Owen Anderson
1abc937731 Remove incorrect and poorly tested code for trying to reason about values on default edges of
switches.  Just return the conservatively correct answer.

llvm-svn: 112876
2010-09-02 22:16:52 +00:00
Owen Anderson
3206920eb2 Fix a bug in LazyValueInfo that CorrelatedValuePropagation exposed: In the LVI lattice, undef and the full set ConstantRange should not
be treated as equivalent.

llvm-svn: 112843
2010-09-02 18:23:58 +00:00
Owen Anderson
d29fb4b991 It is possible to try to merge a not-constant with a constantrage, when dealing with ptrtoint ConstantExpr's.
Unfortunately, the only testcase I have for this is huge and doesn't reduce well because the error is
sensitive to iteration-order issues, since the problem only occurs when merging values in a particular order.

llvm-svn: 112489
2010-08-30 17:03:45 +00:00
Owen Anderson
f2255ee253 Improve the precision of getConstant().
llvm-svn: 112323
2010-08-27 23:29:38 +00:00
Owen Anderson
35ff7a208e Use LVI to eliminate conditional branches where we've tested a related condition previously. Update tests for this change.
This fixes PR5652.

llvm-svn: 112270
2010-08-27 17:12:29 +00:00
Owen Anderson
e0cdfa265a In the default address space, any GEP off of null results in a trap value if you try to load it. Thus,
any load in the default address space that completes implies that the base value that it GEP'd from
was not null.

llvm-svn: 112015
2010-08-25 01:16:47 +00:00
Owen Anderson
5362513cf2 NULL loads are only invalid in the default address space.
llvm-svn: 111972
2010-08-24 22:00:55 +00:00
Owen Anderson
5acb4e1218 Add support for inferring values for the default cases of switches.
llvm-svn: 111971
2010-08-24 21:59:42 +00:00
Owen Anderson
4db6284783 Add support for inferring that a load from a pointer implies that it is not null.
llvm-svn: 111959
2010-08-24 20:47:29 +00:00
Owen Anderson
cb599851f2 Don't assume that all constants with integer types are ConstantInts.
llvm-svn: 111906
2010-08-24 07:55:44 +00:00
Owen Anderson
a57dfdac61 Use ConstantRange to propagate information through value definitions.
llvm-svn: 111425
2010-08-18 21:11:37 +00:00
Owen Anderson
65795241db Inform LazyValueInfo whenever a block is deleted, to avoid dangling pointer issues.
llvm-svn: 111382
2010-08-18 18:39:01 +00:00
Owen Anderson
803f9320fa Fix another iterator invalidation that caused a *really* nasty miscompilation in 403.gcc.
llvm-svn: 111210
2010-08-16 23:42:33 +00:00
Owen Anderson
97ce6f3223 Fix a subtle use-after-free issue.
llvm-svn: 110863
2010-08-11 22:36:04 +00:00
Owen Anderson
0692635e68 Improve indentation.
llvm-svn: 110778
2010-08-11 04:24:25 +00:00
Owen Anderson
a095d3fe73 Now that we're using ConstantRange to represent potential values, make use of that represenation to
create constraints from comparisons other than eq/neq.

llvm-svn: 110742
2010-08-10 23:20:01 +00:00