Commit Graph

53 Commits

Author SHA1 Message Date
Duncan Sands 44b8721de8 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.

llvm-svn: 43620
2007-11-01 20:53:16 +00:00
Dan Gohman c731c97fac Use empty() member functions when that's what's being tested for instead
of comparing begin() and end().

llvm-svn: 42585
2007-10-03 19:26:29 +00:00
Chris Lattner 688b2807df when merging two alias sets together, be sure to propagate the volatility of
the inner set.  This fixes PR1435 and Transforms/LICM/2007-05-22-VolatileSink.ll

llvm-svn: 37305
2007-05-23 06:36:35 +00:00
Nick Lewycky e7da2d6ac3 Fix typo in comment.
llvm-svn: 36873
2007-05-06 13:37:16 +00:00
Devang Patel 8c78a0bff0 Drop 'const'
llvm-svn: 36662
2007-05-03 01:11:54 +00:00
Devang Patel e95c6ad802 Use 'static const char' instead of 'static const int'.
Due to darwin gcc bug, one version of darwin linker coalesces
static const int, which defauts PassID based pass identification.

llvm-svn: 36652
2007-05-02 21:39:20 +00:00
Devang Patel 09f162ca6a Do not use typeinfo to identify pass in pass manager.
llvm-svn: 36632
2007-05-01 21:15:47 +00:00
Reid Spencer f75727ab14 Make classes in anonymous namespaces use VISIBILITY_HIDDEN to help reduce
LLVM's footprint and speed up linking.

llvm-svn: 33941
2007-02-05 23:42:17 +00:00
Bill Wendling f3baad3ee1 Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.

llvm-svn: 32298
2006-12-07 01:30:32 +00:00
Bill Wendling 597d451fea Removed some of the iostream #includes. Moved towards converting to using
llvm streams

llvm-svn: 31983
2006-11-28 22:46:12 +00:00
Nick Lewycky 241211939d Explain change with a comment.
llvm-svn: 30443
2006-09-17 17:51:00 +00:00
Nick Lewycky c7b465366a Fix PR912. The input to erase() must not be a reference to the data
being erased.

llvm-svn: 30442
2006-09-17 16:23:36 +00:00
Chris Lattner c2d3d3112e eliminate RegisterOpt. It does the same thing as RegisterPass.
llvm-svn: 29925
2006-08-27 22:42:52 +00:00
Chris Lattner 90213c6c18 Handle alias sets that have been unified, and thus can have other references
to them.  This fixes a regression in my previous checkin.

llvm-svn: 28951
2006-06-27 23:56:13 +00:00
Chris Lattner f4e0653b3a Don't implement AliasSetTracker::remove in terms of deleteValue. deleteValue
causes the pointer to be removed from the underlying alias analysis
implementation as well.  This impl of remove is also significantly faster than
the old one.  This fixes:
Regression/Transforms/DeadStoreElimination/2006-06-27-AST-Remove.ll

llvm-svn: 28950
2006-06-27 23:48:59 +00:00
Chris Lattner e7d4e56961 Fix a stale pointer issue that caused 300.twolf to fail to build on zion
last night.

llvm-svn: 28916
2006-06-26 19:20:48 +00:00
Chris Lattner 44497859f9 Make the -print-alias-sets pass work for printing out something other than
the default aa impl results.

llvm-svn: 25062
2006-01-03 06:05:22 +00:00
Misha Brukman 01808caded Remove trailing whitespace
llvm-svn: 21416
2005-04-21 21:13:18 +00:00
Chris Lattner 8d9f3735cd Treat free operations as volatile, since they cannot be moved. This fixes
Transforms/LICM/2005-03-24-LICM-Aggregate-Crash.ll

llvm-svn: 20830
2005-03-25 05:49:37 +00:00
Chris Lattner 7b9020a059 Fix the missing symbols problem Bill was hitting. Patch contributed by
Bill Wendling!!

llvm-svn: 20649
2005-03-17 15:38:16 +00:00
Chris Lattner 71d04bce55 Adjust to new alias analysis interfaces
llvm-svn: 18957
2004-12-15 07:22:13 +00:00
Reid Spencer 9083936835 For PR387:\
Make only one print method to avoid overloaded virtual warnings when \
compiled with -Woverloaded-virtual

llvm-svn: 18589
2004-12-07 04:03:45 +00:00
Chris Lattner 24bba4d237 When merging to alias sets, if they are both must alias, the result is not
a must alias set unless all of the pointers in the resultant set are must
aliased together.

llvm-svn: 18275
2004-11-27 18:37:42 +00:00
Chris Lattner eeaa29c377 Add a new interface
llvm-svn: 18266
2004-11-26 21:36:25 +00:00
Chris Lattner 303bdd1e4b Remove dead var
llvm-svn: 17485
2004-11-05 04:52:08 +00:00
Chris Lattner 6fa9665095 Add some assertions
llvm-svn: 16366
2004-09-15 16:59:47 +00:00
Chris Lattner ab64481f1d Implement an AliasSetTracker::copyValue method
llvm-svn: 16344
2004-09-14 19:15:32 +00:00
Misha Brukman 63b38bd2ed Fix #includes of i*.h => Instructions.h as per PR403.
llvm-svn: 15334
2004-07-29 17:30:56 +00:00
Chris Lattner 731381dc0e Remove a bogus assertion
llvm-svn: 15261
2004-07-27 07:22:21 +00:00
Chris Lattner 9b323c3521 Use context-sensitive alias analysis to avoid pessimization in clients of
AliasSetTracker (dse and licm).  This implements
DeadStoreElimination/context-sensitive.llx

llvm-svn: 15254
2004-07-27 02:20:26 +00:00
Chris Lattner bf8c3c405e Add some new methods
llvm-svn: 15230
2004-07-26 05:50:23 +00:00
Chris Lattner 0c73a1ff05 Fix a latent bug in the AliasSetTracker that was exposed by the FreeInst additions and broke a bunch of programs last night.
llvm-svn: 15214
2004-07-25 18:32:01 +00:00
Chris Lattner 924c68dcb2 Add support for free instructions
llvm-svn: 15197
2004-07-25 07:57:37 +00:00
Chris Lattner 053427ff4f Clean up reference counting to stop "leaking" alias sets
llvm-svn: 15099
2004-07-22 07:58:18 +00:00
Chris Lattner abc4f4523f Add capability to remove aliasing aliassets from an AST
llvm-svn: 15066
2004-07-21 07:04:26 +00:00
Chris Lattner 2cfaef23e4 Make the AST interface a bit richer by returning whether an insertion caused
an insertion or not (because the pointer set already existed).

llvm-svn: 15064
2004-07-21 05:18:04 +00:00
Reid Spencer eb04d9bcb4 Add #include <iostream> since Value.h does not #include it any more.
llvm-svn: 14622
2004-07-04 12:19:56 +00:00
Chris Lattner 746e1e1808 Rename a method
llvm-svn: 13676
2004-05-23 21:10:58 +00:00
Chris Lattner 2d3a7a6ff0 Changes to fix up the inst_iterator to pass to boost iterator checks. This
patch was graciously contributed by Vladimir Prus.

llvm-svn: 13185
2004-04-27 15:13:33 +00:00
Chris Lattner 3022b1bc2c Fix a HORRIBLY NASTY bug that caused siod to stop working last night.
llvm-svn: 12479
2004-03-17 23:22:04 +00:00
Chris Lattner 7f04ebc858 Ok, the assertion was bogus. Calls that do not read/write memory should not
have an alias set, just like adds and subtracts don't.

llvm-svn: 12422
2004-03-15 06:28:07 +00:00
Chris Lattner f5c8f4cea6 This assertion is bogus now that calls do not necessarily read/write memory
llvm-svn: 12421
2004-03-15 06:24:15 +00:00
Chris Lattner 21c60f1549 Don't be COMPLETELY pessimistic in the face of function calls
llvm-svn: 12413
2004-03-15 04:08:36 +00:00
Chris Lattner 44fea5416d Add a new AliassetTracker::remove method. Because we need to be able to remove
a pointer from an AliasSet, maintain the pointer values on a doubly linked
list instead of a singly linked list, to permit efficient removal from the
middle of the list.

llvm-svn: 10506
2003-12-18 08:11:56 +00:00
Chris Lattner 0a14060ce2 Finegrainify namespacification
Add capability to represent volatile AliasSet's
Propagate this information from loads&stores into the aliassets

llvm-svn: 10457
2003-12-14 04:52:11 +00:00
Brian Gaeke 960707c335 Put all LLVM code into the llvm namespace, as per bug 109.
llvm-svn: 9903
2003-11-11 22:41:34 +00:00
John Criswell 482202a601 Added LLVM project notice to the top of every C++ source file.
Header files will be on the way.

llvm-svn: 9298
2003-10-20 19:43:21 +00:00
Chris Lattner d14c200425 Fix miscompilation in Fhourstones and bug: LICM/2003-05-02-LoadHoist.ll
llvm-svn: 5994
2003-05-03 03:42:08 +00:00
Chris Lattner c048bb3add ADd two new 'add' methods
llvm-svn: 5691
2003-03-03 23:28:05 +00:00
Chris Lattner b5b0b7a934 Make the aliassettracker much more precise by actually tracking size
information for various accesses.  What a concept.

llvm-svn: 5647
2003-02-26 22:11:00 +00:00