Commit Graph

138 Commits

Author SHA1 Message Date
Victor Hernandez
5c78736f85 Memory dependence analysis was incorrectly stopping to scan for stores to a pointer at bitcast uses of a malloc call.
It should continue scanning until the malloc call, and this patch fixes that.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83931 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 01:42:53 +00:00
Chris Lattner
66364346e0 Revert r82404, it is causing a bootstrap miscompile. This is very very
scary, as it indicates a lurking bug. yay.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82411 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 22:44:26 +00:00
Chris Lattner
386251341f improve memdep to eliminate bitcasts (and aliases, and noop geps)
early for the stated reasons: this allows it to find more 
equivalences and depend less on code layout.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82404 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-20 21:00:18 +00:00
Victor Hernandez
46e8312fb7 Enhance analysis passes so that they apply the same analysis to malloc calls as to MallocInst.
Reviewed by Eli Friedman.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82281 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 21:34:51 +00:00
Dan Gohman
f581213bfb Make TargetData optional in MemoryDependenceAnalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77727 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-31 20:53:12 +00:00
Dan Gohman
cc726599ae Remove an unnecessary header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77725 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-31 20:47:45 +00:00
Chris Lattner
a2f55dd388 factor the 'optimized sort' code out into a static helper function
and use it from one more place.  Patch by Jakub Staszak!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75478 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 17:20:05 +00:00
Chris Lattner
6fbc1969e9 Move the re-sort of invalidated NonLocalPointerDeps cache earlier
so that all code paths get it.  PR4256 was about a case where the
phi translation loop would find all preds in the Visited cache, so
it could get by without re-sorting the NonLocalPointerDeps cache.
Fix this by resorting it earlier, there is no reason not to do this.

This patch inspired by Jakub Staszak's patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75476 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 17:14:23 +00:00
Chris Lattner
ab9cf1282b make memdep use the getModRefInfo method for stores instead of the
low-level alias() method, allowing it to reason more aggressively
about pointers into constant memory.  PR4189


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72403 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-25 21:28:56 +00:00
Chris Lattner
6a0dcc1077 now that you can put a PointerIntPair in a SmallPtrSet, remove some
hackish workarounds from memdep


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67971 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-29 00:24:04 +00:00
Dale Johannesen
497cb6fd4c Debug intriniscs should be skipped when looking
for a dependency, not terminate the search.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66709 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11 21:13:01 +00:00
Owen Anderson
f6cec85a4b Ignore debug intrinsics when computing dependences.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66399 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-09 05:12:38 +00:00
Zhou Sheng
7157228a58 Remove this as dbginfo intrinsics has been defined as
IntrNoMem.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66256 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 06:05:01 +00:00
Zhou Sheng
9b89f0de12 Ignore the debug info intrinsics when looking for dependency through basic block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66119 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 01:45:43 +00:00
Chris Lattner
95900f2dda fix two more cases where we could let the NLPDI cache get unsorted.
With this, sqlite3 now passes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62839 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23 07:12:16 +00:00
Chris Lattner
4433a09b9f Unconditionally reset 'cache' to zero, even if we don't need to resort it.
This avoids using a dangling pointer.

Reset NumSortedEntries after restoring Cache to avoid extraneous sorts.
This fixes the reduced sqlite3 testcase, but apparently not the whole app.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62838 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23 06:48:41 +00:00
Chris Lattner
b54bfc2636 a minor tweak to my previous patch, handle the invalidation case
when there are multiple iterations of the loop.  This fixes PR3375.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62822 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23 00:27:03 +00:00
Chris Lattner
12a7db3830 Fix PR3358, a really nasty bug where recursive phi translated
analyses could be run without the caches properly sorted.  This
can fix all sorts of weirdness.  Many thanks to Bill for coming
up with the 'issorted' verification idea.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62757 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-22 07:04:01 +00:00
Chris Lattner
f478951b0e fix PR3217: fully cached queries need to be verified against the
visited set before they are used.  If used, their blocks need to be
added to the visited set so that subsequent queries don't use conflicting
pointer values in the cache result blocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61080 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-16 07:10:09 +00:00
Chris Lattner
3af23f8aba if we have a phi translation failure of the start block,
return *just* a clobber of the start block, not other 
random stuff as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61026 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 04:58:29 +00:00
Chris Lattner
9e59c64c14 Implement initial support for PHI translation in memdep. This means that
memdep keeps track of how PHIs affect the pointer in dep queries, which 
allows it to eliminate the load in cases like rle-phi-translate.ll, which
basically end up being:

BB1:
   X = load P
   br BB3
BB2:
   Y = load Q
   br BB3
BB3:
   R = phi [P] [Q]
   load R

turning "load R" into a phi of X/Y.  In addition to additional exposed
opportunities, this makes memdep safe in many cases that it wasn't before
(which is required for load PRE) and also makes it substantially more 
efficient.  For example, consider:


bb1:  // has many predecessors.
   P = some_operator()
   load P

In this example, previously memdep would scan all the predecessors of BB1
to see if they had something that would mustalias P.  In some cases (e.g.
test/Transforms/GVN/rle-must-alias.ll) it would actually find them and end
up eliminating something.  In many other cases though, it would scan and not
find anything useful.  MemDep now stops at a block if the pointer is defined
in that block and cannot be phi translated to predecessors.  This causes it
to miss the (rare) cases like rle-must-alias.ll, but makes it faster by not
scanning tons of stuff that is unlikely to be useful.  For example, this
speeds up GVN as a whole from 3.928s to 2.448s (60%)!.  IMO, scalar GVN 
should be enhanced to simplify the rle-must-alias pointer base anyway, which
would allow the loads to be eliminated.

In the future, this should be enhanced to phi translate through geps and 
bitcasts as well (as indicated by FIXMEs) making memdep even more powerful.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61022 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 03:35:32 +00:00
Duncan Sands
7050f3d5ec Don't dereference the end() iterator. This was
causing a bunch of failures when running
"make ENABLE_EXPENSIVE_CHECKS=1 check".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60832 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-10 09:38:36 +00:00
Chris Lattner
5a45bf1b48 loosen up an assertion that isn't valid when called from
invalidateCachedPointerInfo.  Thanks to Bill for sending me
a testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60805 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 22:45:32 +00:00
Chris Lattner
bc99be10b8 Teach GVN to invalidate some memdep information when it does an RAUW
of a pointer.  This allows is to catch more equivalencies.  For example,
the type_lists_compatible_p function used to require two iterations of
the gvn pass (!) to delete its 18 redundant loads because the first pass
would CSE all the addressing computation cruft, which would unblock the
second memdep/gvn passes from recognizing them.  This change allows
memdep/gvn to catch all 18 when run just once on the function (as is 
typical :) instead of just 3.

On all of 403.gcc, this bumps up the # reundandancies found from:

     63 gvn    - Number of instructions PRE'd
 153991 gvn    - Number of instructions deleted
  50069 gvn    - Number of loads deleted
to:
     63 gvn    - Number of instructions PRE'd
 154137 gvn    - Number of instructions deleted
  50185 gvn    - Number of loads deleted

+120 loads deleted isn't bad.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60799 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 22:06:23 +00:00
Chris Lattner
20d6f0982a Teach BasicAA::getModRefInfo(CallSite, CallSite) some
tricks based on readnone/readonly functions.

Teach memdep to look past readonly calls when analyzing
deps for a readonly call.  This allows elimination of a
few more calls from 403.gcc:

before:
     63 gvn    - Number of instructions PRE'd
 153986 gvn    - Number of instructions deleted
  50069 gvn    - Number of loads deleted

after:
     63 gvn    - Number of instructions PRE'd
 153991 gvn    - Number of instructions deleted
  50069 gvn    - Number of loads deleted

5 calls isn't much, but this adds plumbing for the next change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60794 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 21:19:42 +00:00
Chris Lattner
3579e44bf3 Fix a fixme: allow memdep to see past read-only calls when doing
load dependence queries.  This allows GVN to eliminate a few more
instructions on 403.gcc:

 152598 gvn    - Number of instructions deleted
  49240 gvn    - Number of loads deleted
after:
 153986 gvn    - Number of instructions deleted
  50069 gvn    - Number of loads deleted



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60786 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 19:47:40 +00:00
Chris Lattner
1559b3625b rename getNonLocalDependency -> getNonLocalCallDependency, and remove
pointer stuff from it, simplifying the code a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60783 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 19:38:05 +00:00
Chris Lattner
9f1e12a2f2 fix typos gabor noticed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60754 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 08:38:36 +00:00
Chris Lattner
6563371bad restructure the top level non-local ptr dep query to handle
the first block of a query specially.  This makes the "complete query
caching" subsystem more effective, avoiding predecessor queries.  This
speeds up GVN another 4%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60752 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 07:52:59 +00:00
Chris Lattner
9863c3f507 rename getNonLocalPointerDepInternal -> getNonLocalPointerDepFromBB
and split its inner loop out into a new GetNonLocalInfoForBlock
function.  No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60751 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 07:47:11 +00:00
Chris Lattner
ba4dacc875 if we have two elements, insert both, don't use std::sort.
This speeds up the new GVN by another 3%


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60747 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 07:05:45 +00:00
Chris Lattner
1aeadacdad If we're only adding one new element to 'Cache', insert it into its known
position instead of using a full sort. This speeds up GVN by ~4% with the
new memdep stuff.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60746 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 06:58:04 +00:00
Chris Lattner
511b36c00f convert a couple other places that use pred_iterator to use the caching
pred iterator.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60745 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 06:44:17 +00:00
Chris Lattner
4012fdda13 use hte new pred cache to speed up the new non-local memdep
queries.  This speeds up GVN using the new queries (not yet
checked in) by just over 10%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60743 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 06:28:49 +00:00
Chris Lattner
11dcd8d38d add another level of caching for non-local pointer queries, keeping
track of whether the CachedNonLocalPointerInfo for a block is specific
to a block.  If so, just return it without any pred scanning.  This is
good for a 6% speedup on GVN (when it uses this lookup method, which
it doesn't right now).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60695 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-08 07:31:50 +00:00
Chris Lattner
3f7eb5b795 add an assert. the cast<> below would catch this but a message is more
useful.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60674 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 18:45:15 +00:00
Chris Lattner
0655f73ef7 factor some code better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60673 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 18:42:51 +00:00
Chris Lattner
d44745d241 factor some code, fixing some fixme's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 18:39:13 +00:00
Chris Lattner
6290f5cac2 add support for caching pointer dependence queries. Nothing uses this yet
so it "can't" break anything.  That said, it does appear to work.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60654 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 08:50:20 +00:00
Chris Lattner
9a193fd8ae Some internal refactoring to make it easier to cache results.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60650 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 02:56:57 +00:00
Chris Lattner
7ebcf03246 Introduce a new MemDep::getNonLocalPointerDependency
method.  This will eventually take over load/store dep
queries from getNonLocalDependency.  For now it works
fine, but is incredibly slow because it does no caching.
Lets not switch GVN to use it until that is fixed :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60649 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 02:15:47 +00:00
Chris Lattner
e79be944c8 push the "pointer case" up the analysis stack a bit. This causes
duplication of logic (in 2 places) to determine what pointer a 
load/store touches.  This will be addressed in a future commit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60648 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 01:50:16 +00:00
Chris Lattner
d8dd934d16 make clients have to know how to call getCallSiteDependencyFrom
instead of making getDependencyFrom do it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60647 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 01:21:14 +00:00
Chris Lattner
106c6ca7b0 rename some variables for consistency
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60644 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 00:39:19 +00:00
Chris Lattner
fbc72e3e61 I love how using out of scope variables is not an error with GCC, no really I do.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60643 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 00:38:27 +00:00
Chris Lattner
8ef57c5faf Rename getCallSiteDependency -> getCallSiteDependencyFrom to
emphasize the scanning and make it more similar to 
getDependencyFrom
 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60642 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 00:35:51 +00:00
Chris Lattner
745291a6ce a memdep query on a volatile load/store will always return
clobber with the current implementation.  Instead of returning
a "precise clobber" just return a fuzzy one.  This doesn't 
matter to any clients anyway and should speed up analysis time
very very slightly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60641 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 00:28:02 +00:00
Chris Lattner
84b9a56d11 remove the ability to get memdep info for vaarg. I don't think the
original impl was correct and noone actually makes the query anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60639 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 00:21:18 +00:00
Chris Lattner
b51deb929c Make a few major changes to memdep and its clients:
1. Merge the 'None' result into 'Normal', making loads
   and stores return their dependencies on allocations as Normal.
2. Split the 'Normal' result into 'Clobber' and 'Def' to
   distinguish between the cases when memdep knows the value is
   produced from when we just know if may be changed.
3. Move some of the logic for determining whether readonly calls
   are CSEs into memdep instead of it being in GVN.  This still
   leaves verification that the arguments are hte same to GVN to
   let it know about value equivalences in different contexts.
4. Change memdep's call/call dependency analysis to use 
   getModRefInfo(CallSite,CallSite) instead of doing something 
   very weak.  This only really matters for things like DSA, but
   someday maybe we'll have some other decent context sensitive
   analyses :)
5. This reimplements the guts of memdep to handle the new results.
6. This simplifies GVN significantly:
   a) readonly call CSE is slightly simpler
   b) I eliminated the "getDependencyFrom" chaining for load 
      elimination and load CSE doesn't have to worry about 
      volatile (they are always clobbers) anymore.
   c) GVN no longer does any 'lastLoad' caching, leaving it to 
      memdep.
7. The logic in DSE is simplified a bit and sped up.  A potentially
   unsafe case was eliminated.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60607 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 21:04:20 +00:00
Chris Lattner
6951381995 Make it illegal to call getDependency* on non-memory instructions
like binary operators.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60600 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 18:46:19 +00:00