Commit Graph

3872 Commits

Author SHA1 Message Date
Duncan Sands fced7620f5 See if this fixes llvm-gcc bootstrap.
llvm-svn: 124184
2011-01-25 12:15:09 +00:00
Duncan Sands d395108394 According to my auto-simplifier the most common missed simplifications in
optimized code are:
  (non-negative number)+(power-of-two) != 0 -> true
and
  (x | 1) != 0 -> true
Instcombine knows about the second one of course, but only does it if X|1
has only one use.  These fire thousands of times in the testsuite.

llvm-svn: 124183
2011-01-25 09:38:29 +00:00
Eric Christopher cd087f2512 Reorganize this so that the early exit and special cases come early
rather than interspersed. No functional change.

llvm-svn: 124168
2011-01-25 01:34:31 +00:00
Dan Gohman 0f124e1987 Give GetUnderlyingObject a TargetData, to keep it in sync
with BasicAA's DecomposeGEPExpression, which recently began
using a TargetData. This fixes PR8968, though the testcase
is awkward to reduce.

Also, update several off GetUnderlyingObject's users
which happen to have a TargetData handy to pass it in.

llvm-svn: 124134
2011-01-24 18:53:32 +00:00
Chris Lattner f277b5d434 fix PR8928 by clearing a stale map, patch by Jakub Staszak!
llvm-svn: 124132
2011-01-24 18:36:51 +00:00
Dan Gohman 3ac8cd614f Add a comment.
llvm-svn: 124126
2011-01-24 17:54:18 +00:00
Nick Lewycky d4192f71b5 Simplify some code with no functionality change. Make the test a lot more
robust against smarter optimizations, using the power of FileCheck.

llvm-svn: 124081
2011-01-23 20:06:05 +00:00
Ted Kremenek 3c4408ceb6 Null initialize a few variables flagged by
clang's -Wuninitialized-experimental warning.
While these don't look like real bugs, clang's
-Wuninitialized-experimental analysis is stricter
than GCC's, and these fixes have the benefit
of being general nice cleanups.

llvm-svn: 124073
2011-01-23 17:05:06 +00:00
Nick Lewycky bc98f5b78e Use value ranges to fold ext(trunc) in SCEV when possible.
llvm-svn: 124062
2011-01-23 06:20:19 +00:00
Nick Lewycky b32c8943e6 Have SCEV turn sext(x) into zext(x) when x is s>= 0. This applies many times in
"make check" alone.

llvm-svn: 124046
2011-01-22 22:06:21 +00:00
Eric Christopher c70e037b73 Add a FIXME explaining the move to a single indirect call bonus per function
that we can change from indirect to direct.

llvm-svn: 124045
2011-01-22 21:56:53 +00:00
Eric Christopher 08e8b3b629 Only apply the devirtualization bonus once instead of per-call site in the
target function.

Fixes part of rdar://8546196

llvm-svn: 124044
2011-01-22 21:17:33 +00:00
Duncan Sands 8fb2c3827c At -O123 the early-cse pass is run before instcombine has run. According to my
auto-simplier the transform most missed by early-cse is (zext X) != 0 -> X != 0.
This patch adds this transform and some related logic to InstructionSimplify
and removes some of the logic from instcombine (unfortunately not all because
there are several situations in which instcombine can improve things by making
new instructions, whereas instsimplify is not allowed to do this).  At -O2 this
often results in more than 15% more simplifications by early-cse, and results in
hundreds of lines of bitcode being eliminated from the testsuite.  I did see some
small negative effects in the testsuite, for example a few additional instructions
in three programs.  One program, 483.xalancbmk, got an additional 35 instructions,
which seems to be due to a function getting an additional instruction and then
being inlined all over the place.

llvm-svn: 123911
2011-01-20 13:21:55 +00:00
Nick Lewycky 5c901f3489 Similarly, analyze truncate through multiply.
llvm-svn: 123842
2011-01-19 18:56:00 +00:00
Nick Lewycky 5143f0f09b Add a missed SCEV fold that is required to continue analyzing the IR produced
by indvars through the scev expander.

trunc(add x, y) --> add(trunc x, y). Currently SCEV largely folds the other way
which is probably wrong, but preserved to minimize churn. Instcombine doesn't
do this fold either, demonstrating a missed optz'n opportunity on code doing
add+trunc+add.

llvm-svn: 123838
2011-01-19 16:59:46 +00:00
Nick Lewycky e9ea75e3fc Add a missing SCEV simplification sext(zext x) --> zext x.
llvm-svn: 123832
2011-01-19 15:56:12 +00:00
Dan Gohman 44da55b7be Teach BasicAA to return PartialAlias in cases where both pointers
are pointing to the same object, one pointer is accessing the entire
object, and the other is access has a non-zero size. This prevents
TBAA from kicking in and saying NoAlias in such cases.

llvm-svn: 123775
2011-01-18 21:16:06 +00:00
Duncan Sands 99589d07e9 For completeness, generalize the (X + Y) - Y -> X transform and add X - (X + 1) -> -1.
These were not recommended by my auto-simplifier since they don't fire often enough.
However they do fire from time to time, for example they remove one subtraction from
the final bitcode for 483.xalancbmk.

llvm-svn: 123755
2011-01-18 11:50:19 +00:00
Duncan Sands 9b8e2bd8ef Simplify (X<<1)-X into X. According to my auto-simplier this is the most common missed
simplification in fully optimized code.  It occurs sporadically in the testsuite, and
many times in 403.gcc: the final bitcode has 131 fewer subtractions after this change.
The reason that the multiplies are not eliminated is the same reason that instcombine
did not catch this: they are used by other instructions (instcombine catches this with
a more general transform which in general is only profitable if the operands have only
one use).

llvm-svn: 123754
2011-01-18 09:24:58 +00:00
Cameron Zwarich 6b0c4c9b6c Move DominanceFrontier from VMCore to Analysis.
llvm-svn: 123747
2011-01-18 06:06:27 +00:00
Chris Lattner 08f43456c9 fix PR8983, a broken assertion.
llvm-svn: 123562
2011-01-16 03:43:53 +00:00
Nick Lewycky 367f98f000 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
Duncan Sands d6f1a9584d Turn X-(X-Y) into Y. According to my auto-simplifier this is the most common
simplification present in fully optimized code (I think instcombine fails to
transform some of these when "X-Y" has more than one use).  Fires here and
there all over the test-suite, for example it eliminates 8 subtractions in
the final IR for 445.gobmk, 2 subs in 447.dealII, 2 in paq8p etc.

llvm-svn: 123442
2011-01-14 15:26:10 +00:00
Duncan Sands 571fd9a606 Factorize common code out of the InstructionSimplify shift logic. Add in
threading of shifts over selects and phis while there.  This fires here and
there in the testsuite, to not much effect.  For example when compiling spirit
it fires 5 times, during early-cse, resulting in 6 more cse simplifications,
and 3 more terminators being folded by jump threading, but the final bitcode
doesn't change in any interesting way: other optimizations would have caught
the opportunity anyway, only later.

llvm-svn: 123441
2011-01-14 14:44:12 +00:00
Duncan Sands 7f60dc1eb0 Move some shift transforms out of instcombine and into InstructionSimplify.
While there, I noticed that the transform "undef >>a X -> undef" was wrong.
For example if X is 2 then the top two bits must be equal, so the result can
not be anything.  I fixed this in the constant folder as well.  Also, I made
the transform for "X << undef" stronger: it now folds to undef always, even
though X might be zero.  This is in accordance with the LangRef, but I must
admit that it is fairly aggressive.  Also, I added "i32 X << 32 -> undef"
following the LangRef and the constant folder, likewise fairly aggressive.

llvm-svn: 123417
2011-01-14 00:37:45 +00:00
Tobias Grosser b1d11c19da Add single entry / single exit accessors.
Add methods for accessing the (single) entry / exit edge of a region. If no such
edge exists, null is returned.  Both accessors return the start block of the
corresponding edge. The edge can finally be formed by utilizing
Region::getEntry() or Region::getExit();

Contributed by: Andreas Simbuerger <simbuerg@fim.uni-passau.de>

llvm-svn: 123410
2011-01-13 23:18:04 +00:00
Duncan Sands ad000d8f16 Remove some wrong code which fortunately was never executed (as explained in
the comment I added): an extern weak global may have a null address.

llvm-svn: 123373
2011-01-13 10:43:08 +00:00
Duncan Sands 8d25a7c3a0 The most common simplification missed by instsimplify in unoptimized bitcode
is "X != 0 -> X" when X is a boolean.  This occurs a lot because of the way
llvm-gcc converts gcc's conditional expressions.  Add this, and a few other
similar transforms for completeness.

llvm-svn: 123372
2011-01-13 08:56:29 +00:00
Chris Lattner d30de95520 some comment improvements.
llvm-svn: 123243
2011-01-11 17:11:59 +00:00
Eric Christopher 23bf3bafb7 Temporarily revert 123133, it's causing some regressions and I'm trying
to get a testcase.

llvm-svn: 123225
2011-01-11 09:02:09 +00:00
Chris Lattner 23109cb319 the GEP faq says that only inbounds geps are guaranteed to not overflow.
llvm-svn: 123218
2011-01-11 06:44:41 +00:00
Jakob Stoklund Olesen 087f207009 Revert r123207: "Turn on memdep's verifyRemoved() in an attempt to smoke out the cause of our gcc bootstrap miscompare."
It didn't.

llvm-svn: 123215
2011-01-11 04:05:39 +00:00
Jakob Stoklund Olesen 9b6853efd6 Turn on memdep's verifyRemoved() in an attempt to smoke out the cause of our gcc bootstrap miscompare.
llvm-svn: 123207
2011-01-11 01:18:03 +00:00
Chandler Carruth b1e7f557b7 Teach constant folding to perform conversions from constant floating
point values to their integer representation through the SSE intrinsic
calls. This is the last part of a README.txt entry for which I have real
world examples.

llvm-svn: 123206
2011-01-11 01:07:24 +00:00
Chandler Carruth 352d9b14b3 Cleanup some of the constant folding code to consistently test intrinsic
IDs when available rather than using a mixture of IDs and textual name
comparisons.

llvm-svn: 123165
2011-01-10 09:02:58 +00:00
Chris Lattner 67f82314af add a fixme: ir isn't expressive enough.
llvm-svn: 123139
2011-01-09 23:02:10 +00:00
Chris Lattner 28f140a33e Step #4 in improving trip count analysis: HowFarToZero can analyze
NUW AddRec's much more aggressively.  We now get a trip count
for @test2 in nsw.ll

llvm-svn: 123138
2011-01-09 22:58:47 +00:00
Chris Lattner dff679f4b6 rearrange some code, no functionality change.
llvm-svn: 123136
2011-01-09 22:39:48 +00:00
Chris Lattner a44274cb4f Step #3 to improving trip count analysis: If we fold
a + {b,+,stride} into {a+b,+,stride}  (because a is LIV),
then the resultant AddRec is NUW/NSW if the client says it
is.

llvm-svn: 123133
2011-01-09 22:31:26 +00:00
Chris Lattner fc87752d55 Step #2 to improve trip count analysis for loops like this:
void f(int* begin, int* end) { std::fill(begin, end, 0); }

which turns into a != exit expression where one pointer is
strided and (thanks to step #1) known to not overflow, and 
the other is loop invariant.

The observation here is that, though the IV is strided by
4 in this case, that the IV *has* to become equal to the
end value.  It cannot "miss" the end value by stepping over
it, because if it did, the strided IV expression would
eventually wrap around.

Handle this by turning A != B into "A-B != 0" where the A-B
part is known to be NUW.

llvm-svn: 123131
2011-01-09 22:26:35 +00:00
Chris Lattner 10223a3fbf teach SCEV analysis of PHI nodes that PHI recurences formed
with GEP instructions are always NUW, because PHIs cannot wrap
the end of the address space.

llvm-svn: 123105
2011-01-09 02:28:48 +00:00
Chris Lattner a337f5ec5c reduce indentation. Print <nuw> and <nsw> when dumping SCEV AddRec's
that have the bit set.

llvm-svn: 123104
2011-01-09 02:16:18 +00:00
Chris Lattner 171608e738 use isNullValue() to simplify code, add an assert.
llvm-svn: 122977
2011-01-06 22:24:29 +00:00
Chris Lattner 5858e091a6 implement constant folding support for an exotic constant expr:
ret i64 ptrtoint (i8* getelementptr ([1000 x i8]* @X, i64 1, i64 sub (i64 0, i64 ptrtoint ([1000 x i8]* @X to i64))) to i64)

to "ret i64 1000".  This allows us to correctly compute the trip count
on a loop in PR8883, which occurs with std::fill on a char array.  This
allows us to transform it into a memset with a constant size.

llvm-svn: 122950
2011-01-06 06:19:46 +00:00
Owen Anderson 6f060afbbd 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 e86dacf449 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 118ac80c81 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
Chris Lattner c86e67e110 fix an off-by-one bug that caused a crash analyzing
ashr's with huge shift amounts, PR8896

llvm-svn: 122814
2011-01-04 18:19:15 +00:00
Owen Anderson d62d37225a Use the new addEscapingValue callback to update GlobalsModRef when GVN adds PHIs of GEPs. For the moment,
have GlobalsModRef handle this conservatively by simply removing the value from its maps.

llvm-svn: 122787
2011-01-03 23:51:43 +00:00
Owen Anderson b6e4ff0d85 Stub out a new updating interface to AliasAnalysis, allowing stateful analyses to be informed when
a pointer value has potentially become escaping.  Implementations can choose to either fall back to
conservative responses for that value, or may recompute their analysis to accomodate the change.

llvm-svn: 122777
2011-01-03 21:38:41 +00:00
Chris Lattner 16e42128c2 fix rdar://8813415 - a miscompilation of 164.gzip that loop-idiom
exposed.  It turns out to be a latent bug in basicaa, scary.

llvm-svn: 122772
2011-01-03 21:03:33 +00:00
Nick Lewycky 0f87ca7733 Add spliceFunction to the CallGraph interface. This allows users to efficiently
update a callGraph when performing the common operation of splicing the body to
a new function and updating all callers (such as via RAUW).

No users yet, though this is intended for DeadArgumentElimination as part of
PR8887.

llvm-svn: 122728
2011-01-03 03:19:35 +00:00
Chris Lattner bf0aa927cc split dom frontier handling stuff out to its own DominanceFrontier header,
so that Dominators.h is *just* domtree.  Also prune #includes a bit.

llvm-svn: 122714
2011-01-02 22:09:33 +00:00
Duncan Sands 772749aea1 Revert commit 122654 at the request of Chris, who reckons that instsimplify
is the wrong hammer for this nail, and is probably right.

llvm-svn: 122661
2011-01-01 20:08:02 +00:00
Duncan Sands e3c539581c Fix a README item by having InstructionSimplify do a mild form of value
numbering, in which it considers (for example) "%a = add i32 %x, %y" and
"%b = add i32 %x, %y" to be equal because the operands are equal and the
result of the instructions only depends on the values of the operands.
This has almost no effect (it removes 4 instructions from gcc-as-one-file),
and perhaps slows down compilation: I measured a 0.4% slowdown on the large
gcc-as-one-file testcase, but it wasn't statistically significant.

llvm-svn: 122654
2011-01-01 16:12:09 +00:00
Benjamin Kramer b6d52b8b64 Cast away "comparison between signed and unsigned integer" warnings.
llvm-svn: 122598
2010-12-28 13:52:52 +00:00
Chris Lattner 9cb1035f94 move isBytewiseValue out to ValueTracking.h/cpp
llvm-svn: 122565
2010-12-26 20:15:01 +00:00
Jeffrey Yasskin 9b43f33620 Change all self assignments X=X to (void)X, so that we can turn on a
new gcc warning that complains on self-assignments and
self-initializations.

llvm-svn: 122458
2010-12-23 00:58:24 +00:00
Duncan Sands a45cfbd405 When determining whether the new instruction was already present in
the original instruction, half the cases were missed (making it not
wrong but suboptimal).  Also correct a typo (A <-> B) in the second
chunk. 

llvm-svn: 122414
2010-12-22 17:15:25 +00:00
Duncan Sands 3547d2ebd8 Add some statistics, good for understanding how much more powerful
instcombine is compared to instsimplify.

llvm-svn: 122397
2010-12-22 09:40:51 +00:00
Duncan Sands fecc642224 While I don't think any later transforms can fire, it seems cleaner to
not assume this (for example in case more transforms get added below
it).  Suggested by Frits van Bommel.

llvm-svn: 122332
2010-12-21 15:03:43 +00:00
Duncan Sands 5def0d6791 Fix inverted condition noticed by Frits van Bommel.
llvm-svn: 122331
2010-12-21 14:48:48 +00:00
Duncan Sands d0eb6d39f8 Pull a few more simplifications out of instcombine (there are still
plenty left though!), in particular for multiplication.

llvm-svn: 122330
2010-12-21 14:00:22 +00:00
Duncan Sands ee3ec6eb94 Teach InstructionSimplify about distributive laws. These transforms fire
quite often, but don't make much difference in practice presumably because
instcombine also knows them and more.

llvm-svn: 122328
2010-12-21 13:32:22 +00:00
Duncan Sands f64e690c4f Move checking of the recursion limit into the various Thread methods.
No functionality change.

llvm-svn: 122327
2010-12-21 09:09:15 +00:00
Duncan Sands 6c7a52cf80 Add generic simplification of associative operations, generalizing
a couple of existing transforms.  This fires surprisingly often, for
example when compiling gcc "(X+(-1))+1->X" fires quite a lot as well
as various "and" simplifications (usually with a phi node operand).
Most of the time this doesn't make a real difference since the same
thing would have been done elsewhere anyway, eg: by instcombine, but
there are a few places where this results in simplifications that we
were not doing before.

llvm-svn: 122326
2010-12-21 08:49:00 +00:00
Owen Anderson c6beda80ff 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 9be3ec6264 Attempt to appease the DragonEgg buildbots.
llvm-svn: 122288
2010-12-20 23:23:18 +00:00
Owen Anderson 813a2c45a8 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 d83f98a51e 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 64c2c5798a 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
Duncan Sands ed6d6c33dd Have SimplifyBinOp dispatch Xor, Add and Sub to the corresponding methods
(they had just been forgotten before).  Adding Xor causes "main" in the
existing testcase 2010-11-01-lshr-mask.ll to be hugely more simplified.

llvm-svn: 122245
2010-12-20 14:47:04 +00:00
Nick Lewycky 55a700b0cf Make LazyValueInfo non-recursive.
llvm-svn: 122120
2010-12-18 01:00:40 +00:00
Nate Begeman 7aa18bf46a Add vector versions of some existing scalar transforms to aid codegen in matching psign & pblend operations to the IR produced by clang/gcc for their C idioms.
llvm-svn: 122105
2010-12-17 23:12:19 +00:00
Dan Gohman 91ab4ffd96 Update a comment.
llvm-svn: 121946
2010-12-16 02:55:10 +00:00
Dan Gohman e1a17a3473 Make memcpyopt TBAA-aware.
llvm-svn: 121944
2010-12-16 02:51:19 +00:00
Dan Gohman 2c9d342f04 Enable TBAA by default.
llvm-svn: 121923
2010-12-15 23:58:44 +00:00
Dan Gohman 05b18f143f Reapply r121886, and also update DecomposeGEPExpression to keep
it in sync.

llvm-svn: 121895
2010-12-15 20:49:55 +00:00
Dan Gohman d02b65982e Revert r121886. DecomposeGEPExpression needs to be kept
in sync.

llvm-svn: 121892
2010-12-15 20:39:25 +00:00
Dan Gohman 949ab7889c Strengthen GetUnderlyingObject using InstructionSimplify.
While LLVM's main design is that analysis code shouldn't
go out of its way to understand code which hasn't been
InstCombined, analysis utility routines like this can
find themselves being called in the middle of transform
passes when instcombine hasn't had a chance to run.

llvm-svn: 121886
2010-12-15 20:10:26 +00:00
Dan Gohman a4fcd2418d 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 11678bd299 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
Duncan Sands 0a2c416894 Move Sub simplifications and additional Add simplifications out of
instcombine and into InstructionSimplify.

llvm-svn: 121861
2010-12-15 14:07:39 +00:00
Duncan Sands 019a418808 If we detect that the instruction we are simplifying is unreachable, arrange for
it to be replaced by undef rather than not replaced at all, the idea being that
this may reduce the amount of work done by whoever called InstructionSimplify.

llvm-svn: 121860
2010-12-15 11:02:22 +00:00
Dan Gohman 3cb55a1d23 Update a comment.
llvm-svn: 121727
2010-12-13 22:53:18 +00:00
Dan Gohman c4bf5cac9f Reapply r121520, PartialAlias implementation for BasicAA, now that
memdep is updated to handle it.

llvm-svn: 121725
2010-12-13 22:50:24 +00:00
Dan Gohman ba5d0abe39 Update memdep to handle PartialAlias as MayAlias.
llvm-svn: 121723
2010-12-13 22:47:57 +00:00
Tobias Grosser f3e1ada522 Remove useless dynamic_cast<>().
Thanks Peter for pointing me to something that should have never been
committed to the llvm code base.

llvm-svn: 121648
2010-12-12 21:58:28 +00:00
Dan Gohman 39de62348f Revert r121520, which may have introduced miscompilations.
llvm-svn: 121573
2010-12-10 21:48:28 +00:00
Dan Gohman 041f74e762 Implement PartialAlias checking in BasicAA.
llvm-svn: 121520
2010-12-10 20:47:03 +00:00
Dan Gohman 704e7c2332 Minimally update this code to handle PartialAlias.
llvm-svn: 121518
2010-12-10 20:14:49 +00:00
Dan Gohman 201acdb6db Use PartialAlias to do better noalias lint checking.
llvm-svn: 121514
2010-12-10 20:04:06 +00:00
Dan Gohman 4431e31df0 Teach AliasAnalysisCounter about PartialAlias.
llvm-svn: 121513
2010-12-10 19:53:05 +00:00
Dan Gohman 105d60a5ef Teach AliasAnalysisEvaluator about PartialAlias.
llvm-svn: 121512
2010-12-10 19:52:40 +00:00
Dan Gohman fb0a3754f5 Update this code to handle PartialAlias as MayAlias.
llvm-svn: 121508
2010-12-10 19:40:47 +00:00
Owen Anderson c7ed4dc932 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
Devang Patel 8817135cb9 Use type's file info while describing inheritance relationship.
llvm-svn: 121289
2010-12-08 21:46:37 +00:00
Devang Patel b68c6231e9 Add support to create debug info for functions and methods.
llvm-svn: 121281
2010-12-08 20:42:44 +00:00
Devang Patel 81c3c87717 Add support to create class type.
llvm-svn: 121279
2010-12-08 20:18:20 +00:00
Devang Patel 89ea4f27a8 Add support to create vector, array, enums etc...
llvm-svn: 121224
2010-12-08 01:50:15 +00:00
Devang Patel dd261afdd9 Global variable does not need linkage name.
llvm-svn: 121212
2010-12-08 00:06:22 +00:00
Devang Patel 63f83cd861 Add support to create local variable's debug info.
llvm-svn: 121211
2010-12-07 23:58:00 +00:00
Devang Patel 746660fc7b Add support to create variables, structs etc.. using DIBuilder.
This is still work in progress.

llvm-svn: 121205
2010-12-07 23:25:47 +00:00
Jay Foad 583abbc4df PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

llvm-svn: 121120
2010-12-07 08:25:19 +00:00
Jakob Stoklund Olesen 8bdfb0c166 Also inore '()' while creating mdnode name from ObjC symbol name.
llvm-svn: 120856
2010-12-03 23:40:45 +00:00
Devang Patel f0227ccf3f Ignore '+' while creating mdnode name from ObjC symbol name.
llvm-svn: 120853
2010-12-03 23:29:30 +00:00
Jay Foad 25a5e4ca1f PR5207: Rename overloaded APInt methods set(), clear(), flip() to
setAllBits(), setBit(unsigned), etc.

llvm-svn: 120564
2010-12-01 08:53:58 +00:00
Chris Lattner e28618de59 move GetPointerBaseWithConstantOffset out of GVN into ValueTracking.h
llvm-svn: 120476
2010-11-30 22:25:26 +00:00
Jay Foad 15084f085d PR5207: Make APInt::set(), APInt::clear() and APInt::flip() return void.
llvm-svn: 120413
2010-11-30 09:02:01 +00:00
Chris Lattner d540a5d842 strength reduce this.
llvm-svn: 120381
2010-11-30 01:56:13 +00:00
Chris Lattner afbc0c2b8c getLocationForDest should work for memset as well.
llvm-svn: 120380
2010-11-30 01:48:20 +00:00
Chris Lattner 90c4947df7 enhance basicaa to return "Mod" for a memcpy call when the
queried location doesn't overlap the source, and add a testcase.

llvm-svn: 120370
2010-11-30 00:43:16 +00:00
Chris Lattner 9a146372b5 Teach basicaa that memset's modref set is at worst "mod" and never
contains "ref".

Enhance DSE to use a modref query instead of a store-specific hack
to generalize the "ignore may-alias stores" optimization to handle
memset and memcpy.

llvm-svn: 120368
2010-11-30 00:28:45 +00:00
Frits van Bommel a98214de10 Teach ConstantFoldInstruction() how to fold insertvalue and extractvalue.
llvm-svn: 120316
2010-11-29 20:36:52 +00:00
Michael J. Spencer 447762da85 Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Chandler Carruth abcab28f9b Add some dead stores to pacify my least favorite GCC warning: may be
uninitialized. The warning is terrible, has incorrect source locations, and has
a huge false positive rate such as *all* of these.

If anyone has a better solution, please let me know. Alternatively, I'll
happily add -Wno-uninitialized to the -Werror build mode. Maybe I can even do
it *only* when building with GCC instead of Clang.

llvm-svn: 120281
2010-11-29 01:41:13 +00:00
Duncan Sands a021988d64 Expand a little on the description of what InstructionSimplify does.
llvm-svn: 120016
2010-11-23 10:50:08 +00:00
Duncan Sands 763dec0ab8 Clarify that constant folding of instructions applies when all operands
are constant.  There was in fact one exception to this (phi nodes) - so
remove that exception (InstructionSimplify handles this so there should
be no loss).

llvm-svn: 120015
2010-11-23 10:16:18 +00:00
Duncan Sands c133c54426 If a GEP index simply advances by multiples of a type of zero size,
then replace the index with zero.

llvm-svn: 119974
2010-11-22 16:32:50 +00:00
Duncan Sands 8a0f486e36 Move the "gep undef" -> "undef" transform from instcombine to
InstructionSimplify.

llvm-svn: 119970
2010-11-22 13:42:49 +00:00
Benjamin Kramer 585dfa2b3d Initialize MemDep's TD member so buildbots don't trip over an uninitialized pointer (TD is passed to PHITransAddr).
I wonder why this didn't explode earlier.

llvm-svn: 119944
2010-11-21 15:21:46 +00:00
Duncan Sands cf4bceba49 Add a rather pointless InstructionSimplify transform, inspired by recent constant
folding improvements: if P points to a type of size zero, turn "gep P, N" into "P".
More generally, if a gep index type has size zero, instcombine could replace the
index with zero, but that is not done here.

llvm-svn: 119942
2010-11-21 13:53:09 +00:00
Duncan Sands 1f86be9164 Fix spelling.
llvm-svn: 119941
2010-11-21 12:43:13 +00:00
Chris Lattner 6ce038082b apply Dan's fix for PR8268 which allows constant folding to handle indexes over
zero sized elements.  This allows us to compile:

  #include <string>
  void foo() { std::string s; }

into an empty function.

llvm-svn: 119933
2010-11-21 08:39:01 +00:00
Chris Lattner 663ba91cc6 add "getLocation" method to AliasAnalysis for getting the source and
destination location of a memcpy/memmove.  I'm not clear about whether
TBAA works on these, so I'm leaving it out for now.  Dan, please revisit
this when convenient.

llvm-svn: 119928
2010-11-21 07:51:27 +00:00
Chris Lattner e48c31ce33 implement PR8576, deleting dead stores with intervening may-alias stores.
llvm-svn: 119927
2010-11-21 07:34:32 +00:00
Benjamin Kramer ddd1b7b801 Simplify code. No change in functionality.
llvm-svn: 119908
2010-11-20 18:43:35 +00:00
Benjamin Kramer c77ebcc9a5 Silence warning about an uninitialized variable.
llvm-svn: 119800
2010-11-19 11:37:26 +00:00
Duncan Sands b238de0415 Remove threading of Xor over selects and phis, with an explanation
of why such threading is pointless.

llvm-svn: 119798
2010-11-19 09:20:39 +00:00
Duncan Sands aef146b890 Factor code for testing whether replacing one value with another
preserves LCSSA form out of ScalarEvolution and into the LoopInfo
class.  Use it to check that SimplifyInstruction simplifications
are not breaking LCSSA form.  Fixes PR8622.

llvm-svn: 119727
2010-11-18 19:59:41 +00:00
Dan Gohman f1ebfc1544 Strip trailing whitespace.
llvm-svn: 119706
2010-11-18 17:06:31 +00:00
Dan Gohman 0ab28b62b1 Use llvm_unreachable for "impossible" situations.
llvm-svn: 119705
2010-11-18 17:05:57 +00:00
Dan Gohman 2e1fc849b2 Add support for PHI-translating sext, zext, and trunc instructions,
enabling more PRE. PR8586.

llvm-svn: 119704
2010-11-18 17:05:13 +00:00
Dan Gohman 8ea83d81e0 Introduce memoization for ScalarEvolution dominates and properlyDominates
queries, and SCEVExpander getRelevantLoop queries.

llvm-svn: 119595
2010-11-18 00:34:22 +00:00
Dan Gohman 7e6b393e66 Factor out the code for purging a SCEV from all the various memoization maps.
Some of these maps may merge in the future, but for now it's convenient to have
a utility function for them.

llvm-svn: 119587
2010-11-17 23:28:48 +00:00
Dan Gohman 7ee1bbb76c Merge the implementations of isLoopInvariant and hasComputableLoopEvolution, and
memoize the results. This improves compile time in code which highly complex
expressions which get queried many times.

llvm-svn: 119584
2010-11-17 23:21:44 +00:00
Dan Gohman 534749bf70 Make SCEV::getType() and SCEV::print non-virtual. Move SCEV::hasOperand
to ScalarEvolution. Delete SCEV::~SCEV. SCEV is no longer virtual.

llvm-svn: 119578
2010-11-17 22:27:42 +00:00
Dan Gohman 20d9ce21ef Move SCEV::dominates and properlyDominates to ScalarEvolution.
llvm-svn: 119570
2010-11-17 21:41:58 +00:00
Dan Gohman afd6db9932 Move SCEV::isLoopInvariant and hasComputableLoopEvolution to be member
functions of ScalarEvolution, in preparation for memoization and
other optimizations.

llvm-svn: 119562
2010-11-17 21:23:15 +00:00
Duncan Sands 39d77131a1 Before replacing a phi node with a different value, it
needs to be checked that this won't break LCSSA form.
Change the existing checking method to a more direct one:
rather than seeing if all predecessors belong to the loop,
check that the replacing value is either not in any loop or
is in a loop that contains the phi node.

llvm-svn: 119556
2010-11-17 20:49:12 +00:00
Dan Gohman d3a32ae4c8 Verify SCEVAddRecExpr's invariant in ScalarEvolution::getAddRecExpr
instead of in SCEVAddRecExpr's constructor, in preparation for an
upcoming change.

llvm-svn: 119554
2010-11-17 20:48:38 +00:00
Dan Gohman ed75631743 Fix ScalarEvolution's range memoization to avoid using a
default ctor with ConstantRange.

llvm-svn: 119550
2010-11-17 20:23:08 +00:00
Duncan Sands c89ac07e7a Move some those Xor simplifications which don't require creating new
instructions out of InstCombine and into InstructionSimplify.  While
there, introduce an m_AllOnes pattern to simplify matching with integers
and vectors with all bits equal to one.

llvm-svn: 119536
2010-11-17 18:52:15 +00:00
Duncan Sands ec7a6ecb92 Now that hasConstantValue has been made simpler, it may return the
phi node itself if it occurs in an unreachable basic block.  Protect
against this.  Hopefully this will fix some more buildbots.

llvm-svn: 119493
2010-11-17 10:23:23 +00:00
Duncan Sands 64e41cf865 Previously SimplifyInstruction could report that an instruction
simplified to itself (this can only happen in unreachable blocks).
Change it to return null instead.  Hopefully this will fix some
buildbot failures.

llvm-svn: 119490
2010-11-17 08:35:29 +00:00
Duncan Sands 7412f6e53d Fix a layering violation: hasConstantValue, which is part of the PHINode
class, uses DominatorTree which is an analysis.  This change moves all of
the tricky hasConstantValue logic to SimplifyInstruction, and replaces it
with a very simple literal implementation.  I already taught users of
hasConstantValue that need tricky stuff to use SimplifyInstruction instead.
I didn't update InlineFunction because the IR looks like it might be in a
funky state at the point it calls hasConstantValue, which makes calling
SimplifyInstruction dangerous since it can in theory do a lot of tricky
reasoning.  This may be a pessimization, for example in the case where
all phi node operands are either undef or a fixed constant.

llvm-svn: 119459
2010-11-17 04:30:22 +00:00
Duncan Sands d06f50e2db Have ScalarEvolution use SimplifyInstruction rather than hasConstantValue.
While there, add a note about an inefficiency I noticed.

llvm-svn: 119458
2010-11-17 04:18:45 +00:00
Dan Gohman 761065e3b7 Memoize results from ScalarEvolution's getUnsignedRange and getSignedRange.
This fixes some extreme compile times on unrolled sha512 code.

llvm-svn: 119455
2010-11-17 02:44:44 +00:00
Duncan Sands 5ffc298bc7 In which I discover the existence of loops. Threading an operation
over a phi node by applying it to each operand may be wrong if the
operation and the phi node are mutually interdependent (the testcase
has a simple example of this).  So only do this transform if it would
be correct to perform the operation in each predecessor of the block
containing the phi, i.e. if the other operands all dominate the phi.
This should fix the FFMPEG snow.c regression reported by İsmail Dönmez.

llvm-svn: 119347
2010-11-16 12:16:38 +00:00
Duncan Sands f12ba1dfe1 Teach InstructionSimplify the trick of skipping incoming phi
values that are equal to the phi itself.

llvm-svn: 119161
2010-11-15 17:52:45 +00:00
Duncan Sands b99f39b9f6 If dom tree information is available, make it possible to pass
it to get better phi node simplification.

llvm-svn: 119055
2010-11-14 18:36:10 +00:00
Duncan Sands 4581ddc123 Teach InstructionSimplify about phi nodes. I chose to have it simply
offload the work to hasConstantValue rather than do something more
complicated (such handling mutually recursive phis) because (1) it is
not clear it is worth it; and (2) if it is worth it, maybe such logic
would be better placed in hasConstantValue.  Adjust some GVN tests
which are now cleaned up much further (eg: all phi nodes are removed).

llvm-svn: 119043
2010-11-14 13:30:18 +00:00
Duncan Sands 1d27f01210 Boost the power of phi node constant folding slightly: if all
operands are the phi node itself or undef, then return undef.
This logic already existed at a higher level so in practice it
shouldn't make the slightest difference.  Note that this code
could be replaced by a call to PN->hasConstantValue().  However
since we bail out the moment we see a non-constant operand, it
is more efficient to have a specialized version of that logic.

llvm-svn: 119041
2010-11-14 12:53:18 +00:00
Duncan Sands 7e800d6f9c Strip trailing whitespace.
llvm-svn: 119038
2010-11-14 11:23:23 +00:00
Duncan Sands e5ac78e16e Fix typo pointed out by Trevor Harmon.
llvm-svn: 119001
2010-11-13 12:16:27 +00:00
Dan Gohman 970afd926f Re-disable TBAA for now; it broke MultiSource/Applications/JM/lencod,
at least.

llvm-svn: 118890
2010-11-12 11:21:08 +00:00
Dan Gohman ea18d8ec2d Enable TBAA.
llvm-svn: 118884
2010-11-12 06:20:01 +00:00
Dan Gohman 65316d6749 Add helper functions for computing the Location of load, store,
and vaarg instructions.

llvm-svn: 118845
2010-11-11 21:50:19 +00:00
Dan Gohman 468638826e Don't forget the TBAA info, if available.
llvm-svn: 118842
2010-11-11 21:27:26 +00:00
Dan Gohman 7dacf8f3f3 Avoid calling alias on non-pointer values.
llvm-svn: 118822
2010-11-11 19:23:51 +00:00
Dan Gohman c87c843db7 It's not necessary to clear out the Size and TBAATag at each of
these points.

llvm-svn: 118752
2010-11-11 00:42:22 +00:00
Dan Gohman 8bf3d832e5 Set NonLocalDepInfo's Size field to UnknownSize when invalidating
it, so that it doesn't appear to be a known size.

llvm-svn: 118748
2010-11-11 00:20:27 +00:00
Dan Gohman 6791936848 When clearing a non-local pointer dependency cache entry, clear
the reverse map too. This fixes seflhost build errors.

llvm-svn: 118729
2010-11-10 22:35:02 +00:00
Devang Patel 364bf04267 Take care of special characters while creating named MDNode name to hold function specific local variable's info.
This fixes radar 8653152. I am checking in testcase as a separate check-in.

llvm-svn: 118726
2010-11-10 22:19:21 +00:00
Dan Gohman 1d760ce8b3 Factor out the code for computing an AliasAnalysis::Location
for a given instruction into a helper function.

llvm-svn: 118723
2010-11-10 21:51:35 +00:00
Dan Gohman 2e8ca44b81 Fully invalidate cached results when a prior query's size or
type is insufficient for, or incompatible with, the current query.

llvm-svn: 118721
2010-11-10 21:45:11 +00:00
Duncan Sands 8f7220e9fd Reduce the maximum recursion depth, 5 seems pointlessly too much.
Probably it should just be 1, but compromise with 3.

llvm-svn: 118718
2010-11-10 20:53:24 +00:00
Dan Gohman 0a6021a54d Enhance GVN to do more precise alias queries for non-local memory
references. For example, this allows gvn to eliminate the load in
this example:

  void foo(int n, int* p, int *q) {
    p[0] = 0;
    p[1] = 1;
    if (n) {
      *q = p[0];
    }
  }

llvm-svn: 118714
2010-11-10 20:37:15 +00:00
Duncan Sands f3b1bf1606 Teach InstructionSimplify how to look through PHI nodes. Since PHI
nodes can be used in loops, this could result in infinite looping
if there is no recursion limit, so add such a limit.  It is also
used for the SelectInst case because in theory there could be an
infinite loop there too if the basic block is unreachable.

llvm-svn: 118694
2010-11-10 18:23:01 +00:00
Dan Gohman 066c1bb1e9 Add a doesAccessArgPointees helper function, and update code to use
it, and to be consistent.

llvm-svn: 118692
2010-11-10 18:17:28 +00:00
Duncan Sands b0579e9d3f Simplify binary operations where one operand is a select instruction.
The simplifications performed here never create new instructions, they
only return existing instructions (or a constant), and so are always a
win.  In theory they should transform (for example)
  %z = and i32 %x, %y
  %s = select i1 %cond, i32 %y, i32 %z
  %r = and i32 %x, %s
into
  %r = and i32 %x, y
but in practice they get into a fight with instcombine, and lose.
Unfortunately instcombine does a poor job in this case.  Nonetheless
I'm committing this transform to make it easier to discuss what to
do to make peace with instcombine.

llvm-svn: 118679
2010-11-10 13:00:08 +00:00
Dan Gohman 2694e14087 Make ModRefBehavior a lattice. Use this to clean up AliasAnalysis
chaining and simplify FunctionAttrs' GetModRefBehavior logic.

llvm-svn: 118660
2010-11-10 01:02:18 +00:00
Dan Gohman 88ff1ece63 VAArg doesn't capture its operand.
llvm-svn: 118623
2010-11-09 20:09:35 +00:00
Dan Gohman 5d06f892ef Teach AliasAnalysis about AccessesArgumentsReadonly.
llvm-svn: 118621
2010-11-09 20:06:55 +00:00
Dan Gohman 0f17507478 Teach LICM and AliasSetTracker about AccessesArgumentsReadonly.
llvm-svn: 118618
2010-11-09 19:58:21 +00:00
Duncan Sands fc5ad3f0f9 Factorize code, no functionality change.
llvm-svn: 118516
2010-11-09 17:25:51 +00:00
Dan Gohman 142ff82a18 Re-introduce the MaxLookup limit to BasicAliasAnalysis'
pointsToConstantMemory code to guard against possible
compile time slowdowns.

llvm-svn: 118440
2010-11-08 20:26:19 +00:00
Dan Gohman 601c94b309 Implement getModRefBehavior for TypeBasedAliasAnalysis.
llvm-svn: 118416
2010-11-08 17:10:22 +00:00
Dan Gohman 9130bad71f Extend the AliasAnalysis::pointsToConstantMemory interface to allow it
to optionally look for constant or local (alloca) memory.

Teach BasicAliasAnalysis::pointsToConstantMemory to look through Select
and Phi nodes, and to support looking for local memory.

Remove FunctionAttrs' PointsToLocalOrConstantMemory function, now that
AliasAnalysis knows all the tricks that it knew.

llvm-svn: 118412
2010-11-08 16:45:26 +00:00
Dan Gohman 0b56778d65 Delete getIntrinsicModRefBehavior. Clients can just use the normal
getModRefBehavior now, since it now understands intrinsics as well
as normal functions.

llvm-svn: 118411
2010-11-08 16:11:19 +00:00
Dan Gohman e461d7d135 Teach BasicAliasAnalysis::getModRefBehavior(const Function *F)
to analyze intrinsic functions.

llvm-svn: 118409
2010-11-08 16:08:43 +00:00
Duncan Sands a620bd1fa3 Add simplification of floating point comparisons with the result
of a select instruction, the same as already exists for integer
comparisons.

llvm-svn: 118379
2010-11-07 16:46:25 +00:00
Duncan Sands f532d31198 Fix a README item: when doing a comparison with the result
of a select instruction, see if doing the compare with the
true and false values of the select gives the same result.
If so, that can be used as the value of the comparison.

llvm-svn: 118378
2010-11-07 16:12:23 +00:00
Benjamin Kramer ed8b7bf9ed Use arrays instead of constant-sized SmallVectors.
llvm-svn: 118257
2010-11-04 18:45:27 +00:00
Devang Patel 57c5a20364 Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
	DBuilder.CreatePointerType(Ty, Size);
instead of
	DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
                                       TheCU, "", getOrCreateMainFile(),
                                       0, Size, 0, 0, 0, OCTy);

llvm-svn: 118248
2010-11-04 15:01:38 +00:00
Devang Patel 415c551459 Fix DIType verifier. The element 3 is DIFile now.
llvm-svn: 118054
2010-11-02 20:41:13 +00:00
Dan Gohman dcb354b234 Make ScalarEvolution::forgetLoop forget all contained loops too, because
they may have ValuesAtScopes map entries referencing their outer loops.
This fixes a user-after-free reported in PR8471.

llvm-svn: 117698
2010-10-29 20:16:10 +00:00
Dan Gohman 15a43965ac Teach memdep to use pointsToConstantMemory to determine that loads
from constant memory don't alias any stores.

llvm-svn: 117636
2010-10-29 01:14:04 +00:00
Dan Gohman c6096263e2 Support TBAA attachments on calls. This is somewhat experimental.
llvm-svn: 117317
2010-10-25 21:38:20 +00:00
Dan Gohman 82b2e0da9c Fix chaining in TBAA's pointsToConstantMemory.
llvm-svn: 117314
2010-10-25 21:24:55 +00:00
Dan Gohman e6715d0755 Only read one bit for testing for a readonly type, leaving the other
bits open for future uses.

llvm-svn: 117301
2010-10-25 20:22:29 +00:00
Dan Gohman fd864a1d31 Add a comment.
llvm-svn: 117288
2010-10-25 19:47:25 +00:00
Dan Gohman abaf2d8d3b Update comments; BasicAA is no longer necessarily the end of the chain.
llvm-svn: 117268
2010-10-25 16:29:52 +00:00
Dan Gohman 1033ce669b Reintroduce these asserts, now that BasicAA is a normal AliasAnalysis pass.
llvm-svn: 117266
2010-10-25 16:28:57 +00:00
Benjamin Kramer 9192e7ab12 Make some symbols static, move classes into anonymous namespaces.
llvm-svn: 117111
2010-10-22 17:35:07 +00:00
Dan Gohman 8512270dbc Add some more documentation.
llvm-svn: 117070
2010-10-21 21:55:35 +00:00
Dan Gohman 12c9e0cf1c Explain what "constant" means here.
llvm-svn: 117053
2010-10-21 19:45:09 +00:00
Dan Gohman 104f1812ce Update comments.
llvm-svn: 117048
2010-10-21 19:01:22 +00:00
Dan Gohman 1b85604130 Memdep says that an instruction clobbers itself
when it means there is no specific clobber instruction.

llvm-svn: 116960
2010-10-20 22:37:41 +00:00
Dan Gohman a2ab75bc8d Factor out the main aliasing check into a separate function.
llvm-svn: 116958
2010-10-20 22:11:14 +00:00
Dan Gohman 2549d0cf64 Fix comments; the type graph is currently a tree, not a DAG.
llvm-svn: 116954
2010-10-20 22:02:58 +00:00
Tobias Grosser 23c8341c3d Add RegionPass support.
A RegionPass is executed like a LoopPass but on the regions detected by the
RegionInfo pass instead of the loops detected by the LoopInfo pass.

llvm-svn: 116905
2010-10-20 01:54:44 +00:00
Douglas Gregor 48b4568718 Fix CMake build
llvm-svn: 116903
2010-10-20 01:36:56 +00:00
Dan Gohman da85ed8541 Move NoAA out of BasicAliasAnalysis.cpp into its own file, now that
it doesn't have a special relationship with BasicAliasAnalysis
anymore.

llvm-svn: 116876
2010-10-19 23:09:08 +00:00
Dan Gohman f372cf869b Reapply r116831 and r116839, converting AliasAnalysis to use
uint64_t, plus fixes for places I missed before.

llvm-svn: 116875
2010-10-19 22:54:46 +00:00
Dan Gohman b4aa503501 Revert r116831 and r116839, which are breaking selfhost builds.
llvm-svn: 116858
2010-10-19 21:06:16 +00:00
Dan Gohman f4c5fe73be Change AliasAnalysis and its clients to use uint64_t instead of unsigned
for representing object sizes, for consistency with other parts of LLVM.

llvm-svn: 116831
2010-10-19 18:00:02 +00:00
Owen Anderson 6c18d1aac0 Get rid of static constructors for pass registration. Instead, every pass 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
2010-10-19 17:21:58 +00:00
Dan Gohman 14fe8cf238 Consistently use AliasAnalysis::UnknownSize instead of hardcoding ~0u.
llvm-svn: 116815
2010-10-19 17:06:23 +00:00
Dan Gohman e4a82e2f21 Make the representation of AliasSets explicitly differentiate
between "not known yet" and "known no tbaa info" so that it
can merge them properly.

llvm-svn: 116767
2010-10-18 23:31:47 +00:00
Dan Gohman 408beac597 Don't pass the raw invalid pointer used to represent conflicting
TBAA information to AliasAnalysis.

llvm-svn: 116751
2010-10-18 21:28:00 +00:00
Dan Gohman 71af9db0e8 Make AliasSetTracker TBAA-aware, enabling TBAA-enabled LICM.
llvm-svn: 116743
2010-10-18 20:44:50 +00:00
Dan Gohman f3702452c8 Fix BasicAA to pass TBAAInfo through to the chained analysis.
llvm-svn: 116730
2010-10-18 18:45:11 +00:00
Dan Gohman 33fcde9b9c Make TypeBasedAliasAnalysis default to doing nothing, with a command-line
option to enable it.

llvm-svn: 116722
2010-10-18 18:17:47 +00:00
Dan Gohman f0a3bed6d6 Use chaining in TypeBasedAliasAnalysis::pointsToConstantMemory.
llvm-svn: 116721
2010-10-18 18:10:31 +00:00
Dan Gohman 02538ac4d3 Make BasicAliasAnalysis a normal AliasAnalysis implementation which
does normal initialization and normal chaining. Change the default
AliasAnalysis implementation to NoAlias.

Update StandardCompileOpts.h and friends to explicitly request
BasicAliasAnalysis.

Update tests to explicitly request -basicaa.

llvm-svn: 116720
2010-10-18 18:04:47 +00:00
Benjamin Kramer 1dc34b48dd Eliminate some calls to Value::getNameStr.
llvm-svn: 116670
2010-10-16 11:28:23 +00:00
Dan Gohman 31a01ee3cb Tolerate a null parent pointer.
llvm-svn: 116533
2010-10-14 22:55:57 +00:00
Chris Lattner 698661c741 add uadd_ov/usub_ov to apint, consolidate constant folding
logic to use the new APInt methods.  Among other things this
implements rdar://8501501 - llvm.smul.with.overflow.i32 should constant fold

which comes from "clang -ftrapv", originally brought to my attention from PR8221.

llvm-svn: 116457
2010-10-14 00:05:07 +00:00
Owen Anderson c266a36625 Analysis groups need to initialize their default implementations.
llvm-svn: 116441
2010-10-13 21:49:58 +00:00
Tobias Grosser 4b0986b6c1 Add Region::isTopLevelRegion().
llvm-svn: 116402
2010-10-13 11:02:44 +00:00
Tobias Grosser 4c71c117d1 RegionInfo: Fix trivial error that slipped in last minute.
llvm-svn: 116400
2010-10-13 08:00:53 +00:00
Tobias Grosser fe92a9384e RegionInfo: Update RegionInfo after a BB was split.
llvm-svn: 116398
2010-10-13 05:54:13 +00:00
Tobias Grosser a8677226ab RegioInfo: Add getExpandedRegion().
getExpandedRegion() enables us to create non canonical regions. Those regions
can be used to define the largerst region, that fullfills a certain property.

llvm-svn: 116397
2010-10-13 05:54:11 +00:00
Tobias Grosser 648594c920 RegionInfo: Allow to update exit and entry of a region.
llvm-svn: 116396
2010-10-13 05:54:10 +00:00
Tobias Grosser bf984fd78e RegionInfo: Enhance addSubregion.
llvm-svn: 116395
2010-10-13 05:54:09 +00:00
Tobias Grosser 8352ce5f8d RegionInfo: Allow to set the parent region of a basic block.
llvm-svn: 116394
2010-10-13 05:54:07 +00:00
Tobias Grosser e910b9d9cd RegionInfo: Free the RegionNodes in cache.
Contributed by: ether

llvm-svn: 116380
2010-10-13 00:07:59 +00:00
Owen Anderson 8ac477ffb5 Begin adding static dependence information to passes, which will allow us to
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
2010-10-12 19:48:12 +00:00
Dan Gohman a8d3a7f93d Support AA chaining.
llvm-svn: 116264
2010-10-11 23:39:34 +00:00
Kenneth Uildriks b8d7efe785 Now using a variant of the existing inlining heuristics to decide whether to create a given specialization of a function in PartialSpecialization. If the total performance bonus across all callsites passing the same constant exceeds the specialization cost, we create the specialization.
llvm-svn: 116158
2010-10-09 22:06:36 +00:00
Kenneth Uildriks 99463ca8cf Start separating out code metrics into code size metrics and code performance metrics. Partial Specialization will apply the former to function specializations, and the latter to all callsites that can use a specialization, in order to decide whether to create a specialization
llvm-svn: 116057
2010-10-08 13:57:31 +00:00
Owen Anderson df7a4f2515 Now with fewer extraneous semicolons!
llvm-svn: 115996
2010-10-07 22:25:06 +00:00
Owen Anderson 98eb3ec6c5 Add an implementation of the initialization routine for IPA.
llvm-svn: 115947
2010-10-07 18:31:27 +00:00
Owen Anderson 6875c2ea26 Add initialization routines for Analysis and IPA.
llvm-svn: 115946
2010-10-07 18:31:00 +00:00
Owen Anderson 82d38df40c Fix a warning when building with clang++.
llvm-svn: 115924
2010-10-07 17:04:18 +00:00
Owen Anderson 5e19bfcde3 Move the pass initialization helper functions into the llvm namespace, and add
a header declaring them all.  This is also where we will declare per-library pass-set
initializer functions down the road.

llvm-svn: 115900
2010-10-07 04:13:08 +00:00
Owen Anderson af08ad4350 Appease the clang self-host buildbot by providing a correct instantiation.
llvm-svn: 115857
2010-10-06 22:23:20 +00:00
Owen Anderson ad8134f03b Hide analysis group registration behind a macro, just like pass registration.
llvm-svn: 115835
2010-10-06 21:02:27 +00:00
Devang Patel 9a33ec24eb Add support for DW_TAG_unspecified_parameters.
llvm-svn: 115833
2010-10-06 20:50:40 +00:00
Dan Gohman 8e4c19ac44 Don't add the operand count to SCEV uniquing data; FoldingSetNodeID
already knows its own length, so this is redundant.

llvm-svn: 115521
2010-10-04 17:24:08 +00:00
Devang Patel bea08d1c85 Let FE mark a variable as artificial variable.
llvm-svn: 115102
2010-09-29 23:07:21 +00:00
Devang Patel 95ae73c394 Generalize DISubprogram element to encode various flags instead of just one boolean for isArtificial.
This is a backword compatible change.

llvm-svn: 115084
2010-09-29 21:04:46 +00:00
Benjamin Kramer 923a8cf356 Remove PointerTracking from cmakelists …
llvm-svn: 115076
2010-09-29 19:39:50 +00:00
Chris Lattner af995f0ee5 remove PointerTracking from mainline, Edwin is going to move it out to ClamAV
for LLVM 2.9

llvm-svn: 115062
2010-09-29 18:43:27 +00:00
Oscar Fuentes b4b12535e8 Removed a bunch of unnecessary target_link_libraries.
llvm-svn: 114999
2010-09-28 22:39:14 +00:00
Devang Patel 7a55481fa4 Provide an interface to let FEs anchor debug info for types.
llvm-svn: 114969
2010-09-28 18:08:20 +00:00
Jakob Stoklund Olesen 1083573796 Don't try to constant fold libm functions with non-finite arguments.
Usually we wouldn't do this anyway because llvm_fenv_testexcept would return an
exception, but we have seen some cases where neither errno nor fenv detect an
exception on arm-linux.

llvm-svn: 114893
2010-09-27 21:29:20 +00:00
Dan Gohman 2348393cf5 Teach memdep about TBAA tags.
llvm-svn: 114588
2010-09-22 21:41:02 +00:00
Benjamin Kramer 4b57204e80 Simplify code.
llvm-svn: 114444
2010-09-21 16:41:29 +00:00