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

3836 Commits

Author SHA1 Message Date
Chris Lattner
c8a9f4ca2b 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
09cfec2226 rearrange some code, no functionality change.
llvm-svn: 123136
2011-01-09 22:39:48 +00:00
Chris Lattner
4efcd276de 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
b6a67a9068 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
57e9b35653 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
fa37cac39c 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
6430d12360 use isNullValue() to simplify code, add an assert.
llvm-svn: 122977
2011-01-06 22:24:29 +00:00
Chris Lattner
83067bc3e7 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
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
Chris Lattner
dbb1b09731 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
ce48a5e838 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
a52e5dbdfa 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
a7735a573d 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
4840065424 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
e396e846b4 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
aaddf57af9 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
ec8b2b4cc5 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
5acd47c674 Cast away "comparison between signed and unsigned integer" warnings.
llvm-svn: 122598
2010-12-28 13:52:52 +00:00
Chris Lattner
c56d20aa48 move isBytewiseValue out to ValueTracking.h/cpp
llvm-svn: 122565
2010-12-26 20:15:01 +00:00
Jeffrey Yasskin
a199652a3e 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
68d969c2f5 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
9b28a173fe 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
b4497c7e0f 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
7e94cad96b Fix inverted condition noticed by Frits van Bommel.
llvm-svn: 122331
2010-12-21 14:48:48 +00:00
Duncan Sands
6b0ed93a81 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
0bd25425b6 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
2ca8f72575 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
5880f299da 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
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
Duncan Sands
f72cfa961d 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
44a08d5812 Make LazyValueInfo non-recursive.
llvm-svn: 122120
2010-12-18 01:00:40 +00:00
Nate Begeman
063d88d6fb 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
8540450279 Update a comment.
llvm-svn: 121946
2010-12-16 02:55:10 +00:00
Dan Gohman
e106936414 Make memcpyopt TBAA-aware.
llvm-svn: 121944
2010-12-16 02:51:19 +00:00
Dan Gohman
b9583fff47 Enable TBAA by default.
llvm-svn: 121923
2010-12-15 23:58:44 +00:00
Dan Gohman
7c7b24af4d Reapply r121886, and also update DecomposeGEPExpression to keep
it in sync.

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

llvm-svn: 121892
2010-12-15 20:39:25 +00:00
Dan Gohman
8b09daa387 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
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
Duncan Sands
2699fb1072 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
a9b837f7c7 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
1baada041e Update a comment.
llvm-svn: 121727
2010-12-13 22:53:18 +00:00
Dan Gohman
b187cce266 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
f4e1d91b8e Update memdep to handle PartialAlias as MayAlias.
llvm-svn: 121723
2010-12-13 22:47:57 +00:00
Tobias Grosser
cd3d63e102 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
18e2a55c07 Revert r121520, which may have introduced miscompilations.
llvm-svn: 121573
2010-12-10 21:48:28 +00:00
Dan Gohman
d1bf1d8013 Implement PartialAlias checking in BasicAA.
llvm-svn: 121520
2010-12-10 20:47:03 +00:00
Dan Gohman
b0fa0f7849 Minimally update this code to handle PartialAlias.
llvm-svn: 121518
2010-12-10 20:14:49 +00:00
Dan Gohman
98f5b2ae22 Use PartialAlias to do better noalias lint checking.
llvm-svn: 121514
2010-12-10 20:04:06 +00:00
Dan Gohman
cbee92bb65 Teach AliasAnalysisCounter about PartialAlias.
llvm-svn: 121513
2010-12-10 19:53:05 +00:00
Dan Gohman
26e1b4ac11 Teach AliasAnalysisEvaluator about PartialAlias.
llvm-svn: 121512
2010-12-10 19:52:40 +00:00
Dan Gohman
9e03ffc789 Update this code to handle PartialAlias as MayAlias.
llvm-svn: 121508
2010-12-10 19:40:47 +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
Devang Patel
e515e18523 Use type's file info while describing inheritance relationship.
llvm-svn: 121289
2010-12-08 21:46:37 +00:00
Devang Patel
90fd70aa09 Add support to create debug info for functions and methods.
llvm-svn: 121281
2010-12-08 20:42:44 +00:00
Devang Patel
53f05af4c1 Add support to create class type.
llvm-svn: 121279
2010-12-08 20:18:20 +00:00
Devang Patel
b7a7988b6b Add support to create vector, array, enums etc...
llvm-svn: 121224
2010-12-08 01:50:15 +00:00
Devang Patel
0c0accf6bc Global variable does not need linkage name.
llvm-svn: 121212
2010-12-08 00:06:22 +00:00
Devang Patel
bdbff5f106 Add support to create local variable's debug info.
llvm-svn: 121211
2010-12-07 23:58:00 +00:00
Devang Patel
cef2982b39 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
79e18ed269 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
6f535251de Also inore '()' while creating mdnode name from ObjC symbol name.
llvm-svn: 120856
2010-12-03 23:40:45 +00:00
Devang Patel
fdc570cad4 Ignore '+' while creating mdnode name from ObjC symbol name.
llvm-svn: 120853
2010-12-03 23:29:30 +00:00
Jay Foad
789e8ac4f7 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
58b829f94c move GetPointerBaseWithConstantOffset out of GVN into ValueTracking.h
llvm-svn: 120476
2010-11-30 22:25:26 +00:00
Jay Foad
c663d7e4f6 PR5207: Make APInt::set(), APInt::clear() and APInt::flip() return void.
llvm-svn: 120413
2010-11-30 09:02:01 +00:00
Chris Lattner
84d3d220c1 strength reduce this.
llvm-svn: 120381
2010-11-30 01:56:13 +00:00
Chris Lattner
cbe6b88afe getLocationForDest should work for memset as well.
llvm-svn: 120380
2010-11-30 01:48:20 +00:00
Chris Lattner
083731f3d6 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
8ec1830a01 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
6610b43890 Teach ConstantFoldInstruction() how to fold insertvalue and extractvalue.
llvm-svn: 120316
2010-11-29 20:36:52 +00:00
Michael J. Spencer
d5ec932c3a Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Chandler Carruth
12806a53f3 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
97ada840ed Expand a little on the description of what InstructionSimplify does.
llvm-svn: 120016
2010-11-23 10:50:08 +00:00
Duncan Sands
809b3e3634 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
73f0559779 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
ffcd1f61d9 Move the "gep undef" -> "undef" transform from instcombine to
InstructionSimplify.

llvm-svn: 119970
2010-11-22 13:42:49 +00:00
Benjamin Kramer
3fb7d5556c 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
c2b128ad7d 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
4ef7e7f158 Fix spelling.
llvm-svn: 119941
2010-11-21 12:43:13 +00:00
Chris Lattner
1b3dffa2d1 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
a39a40d351 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
3a0edfb37c implement PR8576, deleting dead stores with intervening may-alias stores.
llvm-svn: 119927
2010-11-21 07:34:32 +00:00
Benjamin Kramer
9141603779 Simplify code. No change in functionality.
llvm-svn: 119908
2010-11-20 18:43:35 +00:00
Benjamin Kramer
821c39433d Silence warning about an uninitialized variable.
llvm-svn: 119800
2010-11-19 11:37:26 +00:00
Duncan Sands
56aefef080 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
4562d3b919 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
87b78a4726 Strip trailing whitespace.
llvm-svn: 119706
2010-11-18 17:06:31 +00:00
Dan Gohman
99ac1c6b83 Use llvm_unreachable for "impossible" situations.
llvm-svn: 119705
2010-11-18 17:05:57 +00:00
Dan Gohman
ec75e876ab 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
3213622610 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
ecff21cc67 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
8e594dfe39 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
fb6ea18d0a 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
9bbb0fa515 Move SCEV::dominates and properlyDominates to ScalarEvolution.
llvm-svn: 119570
2010-11-17 21:41:58 +00:00
Dan Gohman
04df5af12b 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
b5fd5f2124 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
4dc0a20aea 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
a585073323 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
2bd7e7c274 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
a5bd3ff0e4 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
d3c1ca1f00 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
48517dac03 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
7376a19858 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
b10ff802a0 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
825c7d7f79 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
ccdccb2776 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
63e80e0593 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
617030ad18 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
9a914e2b5e 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
ab39985d42 Strip trailing whitespace.
llvm-svn: 119038
2010-11-14 11:23:23 +00:00
Duncan Sands
6ff5e53731 Fix typo pointed out by Trevor Harmon.
llvm-svn: 119001
2010-11-13 12:16:27 +00:00
Dan Gohman
ec55b3ac75 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
f867bfd906 Enable TBAA.
llvm-svn: 118884
2010-11-12 06:20:01 +00:00
Dan Gohman
f3bf6591e0 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
97ce60bfa4 Don't forget the TBAA info, if available.
llvm-svn: 118842
2010-11-11 21:27:26 +00:00
Dan Gohman
b68f197748 Avoid calling alias on non-pointer values.
llvm-svn: 118822
2010-11-11 19:23:51 +00:00
Dan Gohman
50936c7c4b 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
b476dc0f55 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
8895f1c5d5 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
5520a6fc97 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
543edf7e84 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
aef3e95364 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
815e967d98 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
2b4e8302a6 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
8531f14f5b 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
65a3841f03 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
1ecf1f999e 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
1571dfc883 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
ebeb34d412 VAArg doesn't capture its operand.
llvm-svn: 118623
2010-11-09 20:09:35 +00:00
Dan Gohman
f82eabd648 Teach AliasAnalysis about AccessesArgumentsReadonly.
llvm-svn: 118621
2010-11-09 20:06:55 +00:00
Dan Gohman
1308376ebf Teach LICM and AliasSetTracker about AccessesArgumentsReadonly.
llvm-svn: 118618
2010-11-09 19:58:21 +00:00
Duncan Sands
f68789ed87 Factorize code, no functionality change.
llvm-svn: 118516
2010-11-09 17:25:51 +00:00
Dan Gohman
9f78edd2a7 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
46cb7cd7d8 Implement getModRefBehavior for TypeBasedAliasAnalysis.
llvm-svn: 118416
2010-11-08 17:10:22 +00:00
Dan Gohman
6909ecf66e 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
ee58dba24c 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
a8838ec654 Teach BasicAliasAnalysis::getModRefBehavior(const Function *F)
to analyze intrinsic functions.

llvm-svn: 118409
2010-11-08 16:08:43 +00:00
Duncan Sands
0a5bcce250 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
c9c7d54930 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
ed73c2619e Use arrays instead of constant-sized SmallVectors.
llvm-svn: 118257
2010-11-04 18:45:27 +00:00
Devang Patel
6c1b802673 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
9af731f560 Fix DIType verifier. The element 3 is DIFile now.
llvm-svn: 118054
2010-11-02 20:41:13 +00:00
Dan Gohman
85557399a1 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
753c9ce807 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
ef977ab6b6 Support TBAA attachments on calls. This is somewhat experimental.
llvm-svn: 117317
2010-10-25 21:38:20 +00:00
Dan Gohman
20a3dd4ee1 Fix chaining in TBAA's pointsToConstantMemory.
llvm-svn: 117314
2010-10-25 21:24:55 +00:00
Dan Gohman
cdc30324f1 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
3bce49a02a Add a comment.
llvm-svn: 117288
2010-10-25 19:47:25 +00:00
Dan Gohman
9d63075905 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
67e229bec7 Reintroduce these asserts, now that BasicAA is a normal AliasAnalysis pass.
llvm-svn: 117266
2010-10-25 16:28:57 +00:00
Benjamin Kramer
9e988fe81e Make some symbols static, move classes into anonymous namespaces.
llvm-svn: 117111
2010-10-22 17:35:07 +00:00
Dan Gohman
fe5489a0ac Add some more documentation.
llvm-svn: 117070
2010-10-21 21:55:35 +00:00
Dan Gohman
6fb125afc8 Explain what "constant" means here.
llvm-svn: 117053
2010-10-21 19:45:09 +00:00
Dan Gohman
8cb659e892 Update comments.
llvm-svn: 117048
2010-10-21 19:01:22 +00:00
Dan Gohman
369ce9c96c 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
3376c4f08d Factor out the main aliasing check into a separate function.
llvm-svn: 116958
2010-10-20 22:11:14 +00:00
Dan Gohman
599a664758 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
88ce93b0eb 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
1e64599cb3 Fix CMake build
llvm-svn: 116903
2010-10-20 01:36:56 +00:00
Dan Gohman
399ef0b44a 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
befe1767ff 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
de3c49438f Revert r116831 and r116839, which are breaking selfhost builds.
llvm-svn: 116858
2010-10-19 21:06:16 +00:00
Dan Gohman
03f86df2e5 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
46990c17f7 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
6e3755905e Consistently use AliasAnalysis::UnknownSize instead of hardcoding ~0u.
llvm-svn: 116815
2010-10-19 17:06:23 +00:00
Dan Gohman
8b332ffb8c 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
6efd04961b 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
64affb7be2 Make AliasSetTracker TBAA-aware, enabling TBAA-enabled LICM.
llvm-svn: 116743
2010-10-18 20:44:50 +00:00
Dan Gohman
35def103f7 Fix BasicAA to pass TBAAInfo through to the chained analysis.
llvm-svn: 116730
2010-10-18 18:45:11 +00:00
Dan Gohman
7820328076 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
97f3b0cac1 Use chaining in TypeBasedAliasAnalysis::pointsToConstantMemory.
llvm-svn: 116721
2010-10-18 18:10:31 +00:00
Dan Gohman
6aff5b94ff 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
a0e156fe6d Eliminate some calls to Value::getNameStr.
llvm-svn: 116670
2010-10-16 11:28:23 +00:00
Dan Gohman
d93278f6b6 Tolerate a null parent pointer.
llvm-svn: 116533
2010-10-14 22:55:57 +00:00
Chris Lattner
451a0accb5 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
c65395a991 Analysis groups need to initialize their default implementations.
llvm-svn: 116441
2010-10-13 21:49:58 +00:00
Tobias Grosser
70507511ae Add Region::isTopLevelRegion().
llvm-svn: 116402
2010-10-13 11:02:44 +00:00
Tobias Grosser
1eba2917fa RegionInfo: Fix trivial error that slipped in last minute.
llvm-svn: 116400
2010-10-13 08:00:53 +00:00
Tobias Grosser
85dce73ab5 RegionInfo: Update RegionInfo after a BB was split.
llvm-svn: 116398
2010-10-13 05:54:13 +00:00
Tobias Grosser
6aac855519 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
ecfaf92c1a RegionInfo: Allow to update exit and entry of a region.
llvm-svn: 116396
2010-10-13 05:54:10 +00:00
Tobias Grosser
84dd4b54fc RegionInfo: Enhance addSubregion.
llvm-svn: 116395
2010-10-13 05:54:09 +00:00
Tobias Grosser
a2b5df5a6d RegionInfo: Allow to set the parent region of a basic block.
llvm-svn: 116394
2010-10-13 05:54:07 +00:00
Tobias Grosser
e5d4a07ab3 RegionInfo: Free the RegionNodes in cache.
Contributed by: ether

llvm-svn: 116380
2010-10-13 00:07:59 +00:00
Owen Anderson
63f757463c 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
4231230501 Support AA chaining.
llvm-svn: 116264
2010-10-11 23:39:34 +00:00
Kenneth Uildriks
e9771f15f7 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
0545afa8fd 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
69cbf2e8b7 Now with fewer extraneous semicolons!
llvm-svn: 115996
2010-10-07 22:25:06 +00:00
Owen Anderson
0dd283aa50 Add an implementation of the initialization routine for IPA.
llvm-svn: 115947
2010-10-07 18:31:27 +00:00
Owen Anderson
704998fa6f Add initialization routines for Analysis and IPA.
llvm-svn: 115946
2010-10-07 18:31:00 +00:00
Owen Anderson
ab71dcd0ad Fix a warning when building with clang++.
llvm-svn: 115924
2010-10-07 17:04:18 +00:00
Owen Anderson
a8a7bf484f 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
65684877c5 Appease the clang self-host buildbot by providing a correct instantiation.
llvm-svn: 115857
2010-10-06 22:23:20 +00:00
Owen Anderson
2a670815f6 Hide analysis group registration behind a macro, just like pass registration.
llvm-svn: 115835
2010-10-06 21:02:27 +00:00
Devang Patel
eeb0b64560 Add support for DW_TAG_unspecified_parameters.
llvm-svn: 115833
2010-10-06 20:50:40 +00:00
Dan Gohman
ff478951be 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
41e2a94595 Let FE mark a variable as artificial variable.
llvm-svn: 115102
2010-09-29 23:07:21 +00:00
Devang Patel
bbd003ab48 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
963980649e Remove PointerTracking from cmakelists …
llvm-svn: 115076
2010-09-29 19:39:50 +00:00
Chris Lattner
b7bfd3de07 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
eb27a44982 Removed a bunch of unnecessary target_link_libraries.
llvm-svn: 114999
2010-09-28 22:39:14 +00:00
Devang Patel
e1f502ee26 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
c9755c5213 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
d69790d841 Teach memdep about TBAA tags.
llvm-svn: 114588
2010-09-22 21:41:02 +00:00
Benjamin Kramer
98e1aab5a8 Simplify code.
llvm-svn: 114444
2010-09-21 16:41:29 +00:00
Benjamin Kramer
a81f2ba27e Make CreateComplexVariable independent of SmallVector.
llvm-svn: 114439
2010-09-21 16:00:03 +00:00
Jakob Stoklund Olesen
37131971c3 Don't include <fenv.h> now that we have llvm/System/FEnv.h.
llvm-svn: 114219
2010-09-17 21:47:03 +00:00
Dan Gohman
8058e1b851 Attempt to support platforms which don't have fenv.h.
llvm-svn: 114196
2010-09-17 20:06:27 +00:00
Dan Gohman
9dc559bdef Fix the folding of floating-point math library calls, like sin(infinity),
so that it detects errors on platforms where libm doesn't set errno.
It's still subject to host libm details though.

llvm-svn: 114148
2010-09-17 01:38:06 +00:00
Dan Gohman
2f0d88bcbe Add an #include of raw_ostream.h. Previously, this only compiled
because it was using Twine.h's declaration of operator<<(const Twine &).

llvm-svn: 114141
2010-09-17 00:33:43 +00:00
Benjamin Kramer
c8808012f9 Update CMake build.
llvm-svn: 114128
2010-09-16 23:06:18 +00:00
Dan Gohman
54fa09d403 Rename a variable to avoid a declaration conflict.
llvm-svn: 114126
2010-09-16 22:50:09 +00:00
Dan Gohman
836ce09592 Add a pass which prints out all the memdep dependencies.
llvm-svn: 114121
2010-09-16 22:08:32 +00:00
Owen Anderson
3d4644bad9 Revert r114097, adding back in the assertion against replacing an Instruction by itself. Now that CorrelatedValuePropagation is
more careful not to call SimplifyInstructionsInBlock() on an unreachable block, the issue has been fixed at a higher level.  Add
a big warning to SimplifyInstructionsInBlock() to hopefully prevent this in the future.

llvm-svn: 114117
2010-09-16 20:51:41 +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
521e8dfef8 Fix PR8161, in which an unreachable loop causes recursive instruction simplification to try
to replace an instruction with itself.  Add a predicate to the simplifier to prevent this case.

llvm-svn: 114097
2010-09-16 17:42:36 +00:00
Eli Friedman
b5aea103fc PR7959: Handle negative scales in GEPs correctly in BasicAA for non-64-bit
targets.

llvm-svn: 114015
2010-09-15 20:08:03 +00:00
Dan Gohman
a2e5bf005e Convert TBAA to use the new TBAATag field of AliasAnalysis::Location.
llvm-svn: 113892
2010-09-14 23:28:12 +00:00
Dan Gohman
ebbc4df924 Remove the experimental AliasAnalysis::getDependency interface, which
isn't a good level of abstraction for memdep. Instead, generalize
AliasAnalysis::alias and related interfaces with a new Location
class for describing a memory location. For now, this is the same
Pointer and Size as before, plus an additional field for a TBAA tag.

Also, introduce a fixed MD_tbaa metadata tag kind.

llvm-svn: 113858
2010-09-14 21:25:10 +00:00
Michael J. Spencer
90f807fda5 Revert "CMake: Get rid of LLVMLibDeps.cmake and export the libraries normally."
This reverts commit r113632

Conflicts:

	cmake/modules/AddLLVM.cmake

llvm-svn: 113819
2010-09-13 23:59:48 +00:00
Benjamin Kramer
6110efbf8c Teach InstructionSimplify to fold (A & B) & A -> A & B and (A | B) | A -> A | B.
Reassociate does this but it doesn't catch all cases (e.g. if the operands are i1).

llvm-svn: 113651
2010-09-10 22:39:55 +00:00
Michael J. Spencer
98ad3f2ea7 CMake: Get rid of LLVMLibDeps.cmake and export the libraries normally.
llvm-svn: 113632
2010-09-10 21:14:25 +00:00
Owen Anderson
f7276d42d3 What the loop unroller cares about, rather than just not unrolling loops with calls, is
not unrolling loops that contain calls that would be better off getting inlined.  This mostly
comes up when an interleaved devirtualization pass has devirtualized a call which the inliner
will inline on a future pass.  Thus, rather than blocking all loops containing calls, add
a metric for "inline candidate calls" and block loops containing those instead.

llvm-svn: 113535
2010-09-09 20:32:23 +00:00
Dan Gohman
7fbaed00bf Extend the getDependence query with support for PHI translation.
llvm-svn: 113521
2010-09-09 18:37:31 +00:00
Owen Anderson
9a194c80c4 Refactor code-size reduction estimation methods out of InlineCostAnalyzer and into CodeMetrics. They
don't use any InlineCostAnalyzer state, and are useful for other clients who don't necessarily want to use
all of InlineCostAnalyzer's logic, some of which is fairly inlining-specific.

No intended functionality change.

llvm-svn: 113499
2010-09-09 16:56:42 +00:00
Dan Gohman
de56ae353b Add a new experimental generalized dependence query interface to
AliasAnalysis, and some code for implementing the new query on top of
existing implementations by making standard alias and getModRefInfo
queries.

llvm-svn: 113329
2010-09-08 01:32:20 +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
cec733bec6 cleanup some of the lifetime/invariant marker stuff, add a big fixme.
llvm-svn: 113144
2010-09-06 03:58:04 +00:00
Chris Lattner
7576ffb974 speed up -gvn 3.4% on the testcase in PR7023
llvm-svn: 113135
2010-09-06 01:26:29 +00:00
Chris Lattner
818045f208 pull a simple method out of LICM into a new
Loop::hasLoopInvariantOperands method. Remove
a useless and confusing Loop::isLoopInvariant(Instruction)
method, which didn't do what you thought it did.

No functionality change.

llvm-svn: 113133
2010-09-06 01:05:37 +00:00
Chris Lattner
4dccd368f3 fix PR8063, a crash in globalopt in the malloc analysis code.
llvm-svn: 113109
2010-09-05 17:20:46 +00:00
Chris Lattner
238e7c2fbe dead method.
llvm-svn: 113077
2010-09-04 18:19:16 +00:00
Chris Lattner
8df3ffd7ac zap dead code.
llvm-svn: 113073
2010-09-04 18:12:00 +00:00
Dan Gohman
96e1af24f6 Disable the asserts that check that normalization is perfectly
invertible. ScalarEvolution's folding routines don't always succeed
in canonicalizing equal expressions to a single canonical form, and
this can cause these asserts to fail, even though there's no actual
correctness problem. This fixes PR8066.

llvm-svn: 113021
2010-09-03 22:12:56 +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
Chris Lattner
d0dce46416 stop forcing a noop AssemblyAnnotationWriter to silence #uses
comments, these don't happen anymore.

llvm-svn: 112901
2010-09-02 23:03:10 +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
Dan Gohman
ad593f9d93 Revert 112442 and 112440 until the compile time problems introduced
by 112440 are resolved.

llvm-svn: 112692
2010-09-01 01:45:53 +00:00
Dan Gohman
fb64948296 Reapply r112432, now that the real problem is addressed.
llvm-svn: 112667
2010-08-31 22:53:17 +00:00