Commit Graph

4435 Commits

Author SHA1 Message Date
Chris Lattner
459f4f8c25 tidy up
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122190 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 20:24:28 +00:00
Chris Lattner
1dec0d2704 Enhance LICM to promote alias sets whose pointers themselves are stored,
which doesn't affect the memory address being promoted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122172 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 05:57:25 +00:00
Chris Lattner
1c0af0ed25 fix PR8602, a bug in an assertion: a volatile store *of* a pointer
does not make the alias set for that pointer volatile, just stores
*to* the pointer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122171 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 05:51:54 +00:00
Chris Lattner
a0d172f7fe revert r122164, I'm going to go with a different approach.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122168 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 04:23:03 +00:00
Chris Lattner
140f4a315b first step to fixing PR8642: don't fold away empty basic blocks
which have trapping constant exprs in them due to PHI nodes.
Eliminating them can cause the constant expr to be evalutated
on new paths if the input edges are critical.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122164 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 03:02:34 +00:00
Dan Gohman
c32046e6ea Revert r64460. strtol and friends cannot be marked readonly, even with
a null endptr argument, because they may write to errno.

This fixes a seflhost miscompile observed on Linux targets when TBAA
was enabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122014 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-17 01:09:43 +00:00
Frits van Bommel
01abcf339f Fix a bug in the loop in JumpThreading::ProcessThreadableEdges() where it could falsely produce a MultipleDestSentinel value if the first predecessor ended with an 'indirectbr'. If that happened, it caused an unnecessary FindMostPopularDest() call.
This wasn't a correctness problem, but it broke the fast path for single-predecessor blocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121966 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-16 12:16:00 +00:00
Dan Gohman
387f28aff4 Make memcpyopt TBAA-aware.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121944 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-16 02:51:19 +00:00
Dan Gohman
f4177aa019 Preserve TBAA tags when doing load PRE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121921 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 23:53:55 +00:00
Dan Gohman
5034dd318a Move Value::getUnderlyingObject to be a standalone
function so that it can live in Analysis instead of
VMCore.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121885 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 20:02:24 +00:00
Frits van Bommel
26e097ca4b Teach jump threading to "look through" a select when the branch direction of a terminator depends on it.
When it sees a promising select it now tries to figure out whether the condition of the select is known in any of the predecessors and if so it maps the operands appropriately.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121859 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 09:51:20 +00:00
Owen Anderson
86e8a700f5 Fix PR8790, another instance where unreachable code can cause instruction simplification to fail,
this case involve a select that simplifies to itself.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121817 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 00:55:35 +00:00
Owen Anderson
93f83deba1 Cleanup trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121816 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 00:52:44 +00:00
Chris Lattner
e991b5fdd5 simplify code and reduce indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121670 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-13 02:38:13 +00:00
Chris Lattner
8fdca6a873 enhance memcpyopt to zap memcpy's that have the same src/dst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121362 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-09 07:45:45 +00:00
Chris Lattner
f7f35467a9 fix PR8753, eliminating a case where we'd infinitely make a
substitution because it doesn't actually change the IR.  Patch by
Jakub Staszak!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121361 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-09 07:39:50 +00:00
Frits van Bommel
8e8cdc8fe0 Remove some dead code from the jump threading pass.
The last uses of these functions were removed in r113852 when LazyValueInfo was permanently enabled and removed the need for them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121133 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 13:08:07 +00:00
Jay Foad
40f8f6264d 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 08:25:19 +00:00
Frits van Bommel
6033b346e2 Implement jump threading of 'indirectbr' by keeping track of whether we're looking for ConstantInt*s or BlockAddress*s.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121066 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 23:36:56 +00:00
Chris Lattner
29d8d6b039 Use a stronger predicate here, pointed out by Duncan
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121040 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 21:48:10 +00:00
Chris Lattner
a9d4da85d6 add some DEBUG statements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121038 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 21:13:51 +00:00
Chris Lattner
cc10244d77 Fix PR8728, a miscompilation I recently introduced. When optimizing
memcpy's like:
  memcpy(A, B)
  memcpy(A, C)

we cannot delete the first memcpy as dead if A and C might be aliases.
If so, we actually get:

  memcpy(A, B)
  memcpy(A, A)

which is not correct to transform into:

  memcpy(A, A)

This patch was heavily influenced by Jakub Staszak's patch in PR8728, thanks
Jakub!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120974 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 01:48:06 +00:00
Frits van Bommel
ea388f217b Refactor jump threading.
Should have no functional change other than the order of two transformations that are mutually-exclusive and the exact formatting of debug output.
Internally, it now stores the ConstantInt*s as Constant*s, and actual undef values instead of nulls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120946 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-05 19:06:41 +00:00
Frits van Bommel
6f9a8307e0 Remove trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120945 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-05 19:02:47 +00:00
Chris Lattner
b5a3196f80 fix a bozo bug I introduced in r119930, causing a miscompile of
20040709-1.c from the gcc testsuite.  I was using the size of a
pointer instead of the pointee.  This fixes rdar://8713376


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120519 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-01 01:24:55 +00:00
Chris Lattner
3161ae1867 Enhance DSE to handle the variable index case in PR8657.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120498 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 23:43:23 +00:00
Chris Lattner
a04096580a teach DSE to use GetPointerBaseWithConstantOffset to analyze
may-aliasing stores that partially overlap with different base
pointers.  This implements PR6043 and the non-variable part of
PR8657


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120485 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 23:05:20 +00:00
Chris Lattner
ed58a6f96f move GetPointerBaseWithConstantOffset out of GVN into ValueTracking.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120476 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 22:25:26 +00:00
Chris Lattner
fcf8d7c73d remove a fixed fixme
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120474 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 22:18:11 +00:00
Chris Lattner
7c80c15a8b Make DeleteDeadInstruction be a static function, move some code around.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120471 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 21:58:14 +00:00
Chris Lattner
d8d35316de switch RemoveAccessedObjects to use AliasAnalysis::Location to simplify
the code.  We now get accurate sizes on Loads, though it surely doesn't
matter in practice.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120469 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 21:47:58 +00:00
Chris Lattner
42cb684f8d two improvements to RemoveAccessedObjects:
1. if the underlying pointer passed in can be resolved
   to any argument or alloca, then we don't need to scan.
   Previously we would only avoid the scan if the alloca
   or byval was actually considered dead.
2. The dead store processing code is itself completely
   dead and didn't handle volatile stores right anyway,
   so delete it.  This allows simplifying the interface
   to RemoveAccessedObjects.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120467 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 21:38:30 +00:00
Chris Lattner
5fb0fb397c remove the "undead" terminology, which is nonstandard and never
made sense to me.  We now have a set of dead stack objects, and
they become live when loaded.  Fix a theoretical problem where
we'd pass in the wrong pointer to the alias query.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120465 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 21:32:12 +00:00
Chris Lattner
86dc6c08cf move call handling in handleEndBlock up a bit, and simplify it.
If the call might read all the allocas, stop scanning early.
Convert a vector to smallvector, shrink SmallPtrSet to 16 instead
of 64 to avoid crazy linear scans.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120463 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 21:18:46 +00:00
Dale Johannesen
f619b5a665 Avoid exponential growth of a table. It feels like
there should be a better way to do this.  PR 8679.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120457 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 20:23:21 +00:00
Chris Lattner
83d6759403 various cleanups and code simplification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120454 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 19:48:15 +00:00
Chris Lattner
e3c611085e make getPointerSize a static function. Add ivars to DSE for
AA and MD pass info instead of using getAnalysis<> all over.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120453 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 19:34:42 +00:00
Chris Lattner
9801651193 reduce indentation, clean up TD use a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120452 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 19:28:23 +00:00
Chris Lattner
55ee75d571 enhance isRemovable to refuse to delete volatile mem transfers
now that DSE hacks on them.  This fixes a regression I introduced,
by generalizing DSE to hack on transfers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120445 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 19:12:10 +00:00
Chris Lattner
cf82dc376a Rewrite the main DSE loop to be written in terms of reasoning
about pairs of AA::Location's instead of looking for MemDep's
"Def" predicate.  This is more powerful and general, handling
memset/memcpy/store all uniformly, and implementing PR8701 and
probably obsoleting parts of memcpyoptimizer.

This also fixes an obscure bug with init.trampoline and i8
stores, but I'm not surprised it hasn't been hit yet.  Enhancing
init.trampoline to carry the size that it stores would allow
DSE to be much more aggressive about optimizing them.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120406 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 07:23:21 +00:00
Anders Carlsson
303023d9ff Add a puts optimization that converts puts() to putchar('\n').
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120398 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 06:19:18 +00:00
Chris Lattner
bbdc3703a3 rename a function and reduce some indentation, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120391 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 05:30:45 +00:00
Chris Lattner
72987a2742 rename doesClobberMemory -> hasMemoryWrite to be more specific, and
remove an actively-wrong comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120378 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 01:37:52 +00:00
Chris Lattner
1ab4285b72 clean up handling of 'free', detangling it from everything else.
It can be seriously improved, but at least now it isn't intertwined
with the other logic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120377 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 01:28:33 +00:00
Chris Lattner
201d1e56bb 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120368 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 00:28:45 +00:00
Chris Lattner
184d1ba738 my previous patch would cause us to start deleting some volatile
stores, fix and add a testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120363 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 00:12:39 +00:00
Chris Lattner
0f53f592ad two changes to DSE that shouldn't affect anything:
1. Don't bother trying to optimize:

lifetime.end(ptr)
store(ptr)

as it is undefined, and therefore shouldn't exist.

2. Move the 'storing a loaded pointer' xform up, simplifying
  the may-aliased store code.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120359 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 00:01:19 +00:00
Chris Lattner
7a0b4fdd14 prune an llvmcontext include and simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120347 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-29 23:35:33 +00:00
Chris Lattner
e9e973018a fix PR8677, patch by Jakub Staszak!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120325 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-29 21:59:31 +00:00
Owen Anderson
35bf4d6d80 Second attempt at fixing the performance regressions introduced
by my recent GVN improvement.  Looking through a single layer of
PHI nodes when attempting to sink GEPs, we need to iteratively
look through arbitrary PHI nests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120202 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-27 08:15:55 +00:00