summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/GlobalOpt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.Duncan Sands2007-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix a logic error in ValueIsOnlyUsedLocallyOrStoredToOneGlobal that caused Chris Lattner2007-09-141-4/+4
| | | | | | | miscompilation of 188.ammp. Reject select and bitcast in ValueIsOnlyUsedLocallyOrStoredToOneGlobal because RewriteHeapSROALoadUser can't handle it. llvm-svn: 41950
* Teach GlobalLoadUsesSimpleEnoughForHeapSRA and the SROA rewriter how to handleChris Lattner2007-09-131-14/+62
| | | | | | | a limited form of PHI nodes. This finally fixes PR1639, speeding 179.art up from 7.84s to 3.13s on PPC. llvm-svn: 41933
* be tolerant of PHI nodes when rewriting heap SROA code. This is a stepChris Lattner2007-09-131-26/+50
| | | | | | along the way of PR1639 llvm-svn: 41930
* refactor some code, no functionality change. On the path to PR1639Chris Lattner2007-09-131-50/+56
| | | | llvm-svn: 41929
* Make ValueIsOnlyUsedLocallyOrStoredToOneGlobal smart enough to see throughChris Lattner2007-09-131-5/+16
| | | | | | bitcasts and phis. This is a step to fixing PR1639. llvm-svn: 41928
* Make AllUsesOfLoadedValueWillTrapIfNull strong enough to see through PHIChris Lattner2007-09-131-6/+15
| | | | | | nodes. This is the first step of the fix for PR1639. llvm-svn: 41927
* Update GEP constructors to use an iterator interface to fixDavid Greene2007-09-041-3/+3
| | | | | | GLIBCXX_DEBUG issues. llvm-svn: 41697
* When rebuilding constant structs, make sure to honor the isPacked bit.Chris Lattner2007-06-041-1/+1
| | | | | | This fixes PR1491 and GlobalOpt/2007-06-04-PackedStruct.ll llvm-svn: 37423
* selects can also reach hereChris Lattner2007-05-151-2/+3
| | | | llvm-svn: 37081
* Fix Transforms/GlobalOpt/2007-05-13-Crash.llChris Lattner2007-05-131-1/+4
| | | | llvm-svn: 37020
* Fix typo in comment.Nick Lewycky2007-05-061-1/+1
| | | | llvm-svn: 36873
* Drop 'const'Devang Patel2007-05-031-2/+2
| | | | llvm-svn: 36662
* Use 'static const char' instead of 'static const int'.Devang Patel2007-05-021-2/+2
| | | | | | | Due to darwin gcc bug, one version of darwin linker coalesces static const int, which defauts PassID based pass identification. llvm-svn: 36652
* Do not use typeinfo to identify pass in pass manager.Devang Patel2007-05-011-0/+3
| | | | llvm-svn: 36632
* Implement the "thread_local" keyword.Lauro Ramos Venancio2007-04-121-7/+19
| | | | llvm-svn: 35950
* Fix Transforms/GlobalOpt/2007-04-05-Crash.llChris Lattner2007-04-051-1/+1
| | | | llvm-svn: 35689
* Prefer non-virtual calls to ConstantInt::isZero over virtual calls toReid Spencer2007-03-021-1/+1
| | | | | | Constant::isNullValue() in situations where it is possible. llvm-svn: 34821
* For PR1195:Reid Spencer2007-02-151-3/+3
| | | | | | | Rename PackedType -> VectorType, ConstantPacked -> ConstantVector, and PackedTyID -> VectorTyID. No functional changes. llvm-svn: 34293
* stop using methods that take vectors.Chris Lattner2007-02-121-3/+4
| | | | llvm-svn: 34205
* simplify name juggling through the use of Value::takeName.Chris Lattner2007-02-111-8/+6
| | | | llvm-svn: 34175
* Apply the VISIBILITY_HIDDEN field to the remaining anonymous classes inReid Spencer2007-02-051-2/+3
| | | | | | | the Transforms library. This reduces debug library size by 132 KB, debug binary size by 376 KB, and reduces link time for llvm tools slightly. llvm-svn: 33939
* Changes to support making the shift instructions be true BinaryOperators.Reid Spencer2007-02-021-4/+0
| | | | | | | | | | | | This feature is needed in order to support shifts of more than 255 bits on large integer types. This changes the syntax for llvm assembly to make shl, ashr and lshr instructions look like a binary operator: shl i32 %X, 1 instead of shl i32 %X, i8 1 Additionally, this should help a few passes perform additional optimizations. llvm-svn: 33776
* eliminate temporary vectorsChris Lattner2007-01-311-6/+5
| | | | llvm-svn: 33712
* eliminate temporary vectorsChris Lattner2007-01-311-9/+12
| | | | llvm-svn: 33693
* Adjust #includes to match movement of constant folding code from ↵Chris Lattner2007-01-301-2/+2
| | | | | | transformutils to libanalysis. llvm-svn: 33680
* adjust to api changeChris Lattner2007-01-301-1/+2
| | | | llvm-svn: 33671
* For PR1136: Rename GlobalVariable::isExternal as isDeclaration to avoidReid Spencer2007-01-301-2/+2
| | | | | | confusion with external linkage types. llvm-svn: 33663
* For PR970:Reid Spencer2007-01-211-0/+1
| | | | | | | Clean up handling of isFloatingPoint() and dealing with PackedType. Patch by Gordon Henriksen! llvm-svn: 33415
* Branch conditions must be i1Chris Lattner2007-01-121-3/+1
| | | | llvm-svn: 33129
* Implement review feedback for the ConstantBool->ConstantInt merge. ChrisReid Spencer2007-01-121-2/+2
| | | | | | | | recommended that getBoolValue be replaced with getZExtValue and that get(bool) be replaced by get(const Type*, uint64_t). This implements those changes. llvm-svn: 33110
* Rename BoolTy as Int1Ty. Patch by Sheng Zhou.Reid Spencer2007-01-111-5/+5
| | | | llvm-svn: 33076
* For PR1043:Zhou Sheng2007-01-111-9/+12
| | | | | | | Merge ConstantIntegral and ConstantBool into ConstantInt. Remove ConstantIntegral and ConstantBool from LLVM. llvm-svn: 33073
* Fix a bug in heap-sra that caused compilation failure of office-ispell.Chris Lattner2007-01-091-3/+19
| | | | llvm-svn: 33043
* For PR950:Reid Spencer2006-12-311-9/+8
| | | | | | | | | | | | | This patch replaces signed integer types with signless ones: 1. [US]Byte -> Int8 2. [U]Short -> Int16 3. [U]Int -> Int32 4. [U]Long -> Int64. 5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion and other methods related to signedness. In a few places this warranted identifying the signedness information from other sources. llvm-svn: 32785
* For PR950:Reid Spencer2006-12-231-28/+36
| | | | | | | | This patch removes the SetCC instructions and replaces them with the ICmp and FCmp instructions. The SetCondInst instruction has been removed and been replaced with ICmpInst and FCmpInst. llvm-svn: 32751
* Eliminate static ctors due to Statistic objectsChris Lattner2006-12-191-16/+12
| | | | llvm-svn: 32693
* Replace inferred getCast(V,Ty) calls with more strict variants.Reid Spencer2006-12-121-5/+4
| | | | | | | Rename getZeroExtend and getSignExtend to getZExt and getSExt to match the the casting mnemonics in the rest of LLVM. llvm-svn: 32514
* Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, areBill Wendling2006-12-071-18/+18
| | | | | | now cerr, cout, and NullStream resp. llvm-svn: 32298
* Detemplatize the Statistic class. The only type it is instantiated withChris Lattner2006-12-061-11/+11
| | | | | | is 'unsigned'. llvm-svn: 32279
* make it clear that this is always a zextChris Lattner2006-11-301-1/+1
| | | | llvm-svn: 32044
* One more bugfix, 3 cases of making casts explicit.Chris Lattner2006-11-301-5/+8
| | | | llvm-svn: 32043
* Fix a bug in globalopt due to the recent cast patch.Chris Lattner2006-11-301-1/+2
| | | | llvm-svn: 32042
* For PR950:Reid Spencer2006-11-271-2/+2
| | | | | | | | | | The long awaited CAST patch. This introduces 12 new instructions into LLVM to replace the cast instruction. Corresponding changes throughout LLVM are provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the exception of 175.vpr which fails only on a slight floating point output difference. llvm-svn: 31931
* Replace #include <iostream> with llvm_* streams.Bill Wendling2006-11-261-35/+35
| | | | llvm-svn: 31924
* For PR786:Reid Spencer2006-11-021-1/+1
| | | | | | | | | | Turn on -Wunused and -Wno-unused-parameter. Clean up most of the resulting fall out by removing unused variables. Remaining warnings have to do with unused functions (I didn't want to delete code without review) and unused variables in generated code. Maintainers should clean up the remaining issues when they see them. All changes pass DejaGnu tests and Olden. llvm-svn: 31380
* Fix GlobalOpt/2006-11-01-ShrinkGlobalPhiCrash.ll and McGill/chompChris Lattner2006-11-011-8/+14
| | | | llvm-svn: 31352
* For PR950:Reid Spencer2006-10-201-20/+19
| | | | | | | | This patch implements the first increment for the Signless Types feature. All changes pertain to removing the ConstantSInt and ConstantUInt classes in favor of just using ConstantInt. llvm-svn: 31063
* Fix debug outputChris Lattner2006-09-301-2/+1
| | | | llvm-svn: 30680
* Implement SRA of heap allocations.Chris Lattner2006-09-301-10/+266
| | | | llvm-svn: 30679
OpenPOWER on IntegriCloud