Commit Graph

37 Commits

Author SHA1 Message Date
Owen Anderson
5fc4abac3d Fix several cache coherence bugs in MemDep/GVN that were found. Also add some (disabled) debugging code
to make such problems easier to diagnose in the future, written by Duncan Sands.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44695 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-08 01:37:09 +00:00
Duncan Sands
dff6710717 Integrate the readonly/readnone logic more deeply
into alias analysis.  This meant updating the API
which now has versions of the getModRefBehavior,
doesNotAccessMemory and onlyReadsMemory methods
which take a callsite parameter.  These should be
used unless the callsite is not known, since in
general they can do a better job than the versions
that take a function.  Also, users should no longer
call the version of getModRefBehavior that takes
both a function and a callsite.  To reduce the
chance of misuse it is now protected.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44487 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-01 07:51:45 +00:00
Owen Anderson
97d4e51df1 Fix a silly bug that Nicholas noticed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44324 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-26 03:27:38 +00:00
Owen Anderson
00a6d1448d Allow GVN to eliminate read-only function calls when it can detect that they are redundant.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44323 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-26 02:26:36 +00:00
Duncan Sands
514ab348fd Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment.  This gives a primitive type for
which getTypeSize differed from getABITypeSize.  For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).

This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition).  Instead there is:

(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type.  For a primitive type, this is the minimum number
of bits.  For an i36 this is 36 bits.  For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.

(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it).  For an
i36 this is 40 bits, for an x86 long double it is 80 bits.  This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes).  There doesn't seem to be anything
corresponding to this in gcc.

(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment.  For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS.  This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes).  This is
TYPE_SIZE in gcc.

Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize.  This means that the size of an array
is the length times the getABITypeSize.  It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize.  Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case.  So alloca's and mallocs should use getABITypeSize.  Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.

Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.

In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases).  I will get around to auditing these too at some point,
but I could do with some help.

Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize.  I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers.  If someone wants to pack these types more
tightly they can always use a packed struct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43620 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 20:53:16 +00:00
Owen Anderson
ce4d88aa64 Add partial caching of non-local memory dependence queries. This provides a modest
speedup for GVN.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42185 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-21 03:53:52 +00:00
Owen Anderson
742f9b6682 Add a flag to mark a dirty cache entry. This is not yet used, but will eventually
help non-local memdep caching.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42137 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-19 16:13:57 +00:00
Owen Anderson
0a890e2fb5 Fix a typo in memdep, which was causing PR1648.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41833 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-11 04:31:00 +00:00
Owen Anderson
7fad7e3db8 Remove an un-needed dependence query. This improves compile time marginally on 401.bzip2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41792 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-09 21:43:49 +00:00
Owen Anderson
4d13de4e3b Cache non-local memory dependence analysis. This is a significant compile
time performance win in most cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41126 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-16 21:27:05 +00:00
Owen Anderson
9528f11481 Make NonLocal and None const in the right way. :-)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40961 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-09 04:42:44 +00:00
Owen Anderson
642a9e3436 Add more comments to memdep.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40953 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-08 22:26:03 +00:00
Owen Anderson
80b1f09693 Make memdep fit in 80 cols.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40950 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-08 22:01:54 +00:00
Owen Anderson
8cad423d94 Change the None and NonLocal markers in memdep to be const.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40946 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-08 21:39:39 +00:00
Owen Anderson
dbbe816757 Clean up a bunch of caching stuff in memdep. This reduces the time to run GVN
on 403.gcc from ~15s to ~10s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40884 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-07 00:33:45 +00:00
Owen Anderson
8f35315798 Improve the accuracy of memdep for determining the dependencies of loads.
This brings GVN to parity with GCSE+LoadVN.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40882 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-06 23:26:03 +00:00
Owen Anderson
1c2763d3fe Fix a bug that was causing several miscompilations on SPEC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40746 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 17:56:05 +00:00
Owen Anderson
9066020993 Make non-local memdep not be recursive, and fix a bug on 403.gcc that this exposed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40692 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 22:01:54 +00:00
David Greene
df464195fe Fix GLIBCXX_DEBUG error owing to dereference of end iterator. There's
no guarantee that an instruction returned by getDependency exists in
the maps.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40647 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 20:01:27 +00:00
Owen Anderson
45c8388e2a Use more caching when computing non-local dependence. This makes bzip2 not
use up the entire 32-bit address space.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40596 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-30 17:29:24 +00:00
Owen Anderson
a377a24771 Fix a bug introduced in my last commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40542 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-26 18:57:04 +00:00
Owen Anderson
45537917ee Fix a couple more bugs in the phi construction by pulling in code that does
almost the same things from LCSSA.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40540 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-26 18:26:51 +00:00
Owen Anderson
3dfcf33cf8 Fix a bug in non-local memdep that was causing an infinite loop on 175.vpr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40495 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-25 21:26:36 +00:00
Owen Anderson
0cd320362e Add basic support for performing whole-function RLE.
Note: This has not yet been thoroughly tested.  Use at your own risk.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40489 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-25 19:57:03 +00:00
Owen Anderson
4beedbd006 Add initial support for non-local memory dependence analysis.
NOTE: This has only been cursorily tested.  Expected improvements soon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40476 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-24 21:52:37 +00:00
Owen Anderson
521a20207c When removing instructions from the analysis, be sure to check the confirmed
flag when determining what to do with dependencies.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40079 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-20 06:16:07 +00:00
Owen Anderson
faac518ce0 Add support for walking up memory def chains, which enables finding many more
dead stores on 400.perlbench.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39929 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 21:52:50 +00:00
Owen Anderson
1cb960a4bb Let MemoryDependenceAnalysis take care of updating AliasAnalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39769 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-12 00:06:21 +00:00
Owen Anderson
8e85048d7b Calculate the size of a array allocation correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38511 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-10 20:48:38 +00:00
Owen Anderson
202da14fe0 Fix a crasher when finding the dependency of a call.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38510 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-10 20:39:07 +00:00
Owen Anderson
776ee1fb33 Make this pass registration static as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38509 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-10 20:21:08 +00:00
Owen Anderson
06b6e82f79 Handle vaarg instructions correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38504 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-10 18:43:15 +00:00
Owen Anderson
e314eb3255 Volatile loads and stores depend on each other.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38502 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-10 18:11:42 +00:00
Owen Anderson
5f32320797 Add support for finding the dependencies of call and invoke instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38497 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-10 17:59:22 +00:00
Owen Anderson
7a616a1012 Fix the build, and fix the handling of pointer sizes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38494 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-10 17:25:03 +00:00
Owen Anderson
6b278fc786 Fix a bunch of things from Chris' feedback
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38493 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-10 17:08:11 +00:00
Owen Anderson
78e02f78ce A first stab at memory dependence analysis. This is an interface on top of
alias analysis, adding caching and lazy computation of queries.  This will
be used in planned improvements to memory access optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37958 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-06 23:14:35 +00:00