Commit Graph

2689 Commits

Author SHA1 Message Date
Chris Lattner
e34537856a add a new SimplifyInstruction API, which is like ConstantFoldInstruction,
except that the result may not be a constant.  Switch jump threading to 
use it so that it gets things like (X & 0) -> 0, which occur when phi preds
are deleted and the remaining phi pred was a zero.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86637 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 01:08:51 +00:00
Jeffrey Yasskin
81cf432569 Fix DenseMap iterator constness.
This patch forbids implicit conversion of DenseMap::const_iterator to
DenseMap::iterator which was possible because DenseMapIterator inherited
(publicly) from DenseMapConstIterator. Conversion the other way around is now
allowed as one may expect.

The template DenseMapConstIterator is removed and the template parameter
IsConst which specifies whether the iterator is constant is added to
DenseMapIterator.

Actually IsConst parameter is not necessary since the constness can be
determined from KeyT but this is not relevant to the fix and can be addressed
later.

Patch by Victor Zverovich!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86636 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 01:02:17 +00:00
Chris Lattner
d06094f068 factor simplification logic for AND and OR out to InstSimplify from instcombine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86635 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 00:55:12 +00:00
Chris Lattner
210c5d4880 pull a bunch of logic out of instcombine into instsimplify for compare
simplification, this handles the foldable fcmp x,x cases among many others.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86627 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 23:55:12 +00:00
Dan Gohman
1ba3b6c565 Pass the (optional) TargetData object to ConstantFoldInstOperands
and ConstantFoldCompareInstOperands.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86626 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 23:34:17 +00:00
Chris Lattner
9dbb42944c rename SimplifyCompare -> SimplifyCmpInst and split it into
Simplify[IF]Cmp pieces.  Add some predicates to CmpInst to 
determine whether a predicate is fp or int.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86624 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 23:28:39 +00:00
Chris Lattner
8f73deaa87 fix ConstantFoldCompareInstOperands to take the LHS/RHS as
individual operands instead of taking a temporary array


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86619 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 23:06:58 +00:00
Chris Lattner
9f3c25aeb3 stub out a new libanalysis "instruction simplify" interface that
takes decimated instructions and applies identities to them.  This
is pretty minimal at this point, but I plan to pull some instcombine
logic out into these and similar routines.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86613 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 22:57:59 +00:00
Dan Gohman
f75ef668a7 Default-addressspace null pointers don't alias anything. This allows
GVN to be more aggressive. Patch by Hans Wennborg! (with a comment added by me)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86582 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 19:29:11 +00:00
Dan Gohman
81d893ccf2 Minor tidiness fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86565 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 18:19:43 +00:00
Victor Hernandez
9d0b704e3e Re-commit r86077 now that r86290 fixes the 179.art and 175.vpr ARM regressions.
Here is the original commit message:

This commit updates malloc optimizations to operate on malloc calls that have constant int size arguments.

Update CreateMalloc so that its callers specify the size to allocate:
MallocInst-autoupgrade users use non-TargetData-computed allocation sizes.
Optimization uses use TargetData to compute the allocation size.

Now that malloc calls can have constant sizes, update isArrayMallocHelper() to use TargetData to determine the size of the malloced type and the size of malloced arrays.
Extend getMallocType() to support malloc calls that have non-bitcast uses.

Update OptimizeGlobalAddressOfMalloc() to optimize malloc calls that have non-bitcast uses.  The bitcast use of a malloc call has to be treated specially here because the uses of the bitcast need to be replaced and the bitcast needs to be erased (just like the malloc call) for OptimizeGlobalAddressOfMalloc() to work correctly.

Update PerformHeapAllocSRoA() to optimize malloc calls that have non-bitcast uses.  The bitcast use of the malloc is not handled specially here because ReplaceUsesOfMallocWithGlobal replaces through the bitcast use.

Update OptimizeOnceStoredGlobal() to not care about the malloc calls' bitcast use.

Update all globalopt malloc tests to not rely on autoupgraded-MallocInsts, but instead use explicit malloc calls with correct allocation sizes.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86311 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 00:16:28 +00:00
Devang Patel
5ebfa2d181 Tolerate invalid derived type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86269 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 18:24:05 +00:00
Devang Patel
84c73e9b82 Do not bother to emit debug info for nameless global variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86259 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 17:58:12 +00:00
Chris Lattner
7b550ccfc5 remove a bunch of extraneous LLVMContext arguments
from various APIs, addressing PR5325.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86231 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 04:27:31 +00:00
Victor Hernandez
df98761d08 Revert r86077 because it caused crashes in 179.art and 175.vpr on ARM
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86213 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 01:33:24 +00:00
Dan Gohman
a6a4aaefee Fix IVUsers to avoid assuming that the loop has a unique backedge.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86161 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 19:41:37 +00:00
Dan Gohman
f17e9511f1 Factor out the predicate code for loopsimplify form exit blocks into
a separate helper function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86159 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 19:21:41 +00:00
Victor Hernandez
24f934d055 Update CreateMalloc so that its callers specify the size to allocate:
MallocInst-autoupgrade users use non-TargetData-computed allocation sizes.
Optimization uses use TargetData to compute the allocation size.

Now that malloc calls can have constant sizes, update isArrayMallocHelper() to use TargetData to determine the size of the malloced type and the size of malloced arrays.
Extend getMallocType() to support malloc calls that have non-bitcast uses.

Update OptimizeGlobalAddressOfMalloc() to optimize malloc calls that have non-bitcast uses.  The bitcast use of a malloc call has to be treated specially here because the uses of the bitcast need to be replaced and the bitcast needs to be erased (just like the malloc call) for OptimizeGlobalAddressOfMalloc() to work correctly.

Update PerformHeapAllocSRoA() to optimize malloc calls that have non-bitcast uses.  The bitcast use of the malloc is not handled specially here because ReplaceUsesOfMallocWithGlobal replaces through the bitcast use.

Update OptimizeOnceStoredGlobal() to not care about the malloc calls' bitcast use.

Update all globalopt malloc tests to not rely on autoupgraded-MallocInsts, but instead use explicit malloc calls with correct allocation sizes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86077 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 00:03:03 +00:00
Devang Patel
61ecbd196c While calculating original type size for a derived type, handle type variants encoded as DIDerivedType appropriately.
This improves bitfield support.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86073 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 23:48:00 +00:00
Victor Hernandez
3ad70d5d61 Changes requested (avoid getFunction(), avoid Type creation via isVoidTy(), and avoid redundant isFreeCall cases) in feedback to r85176
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85936 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 20:39:35 +00:00
Victor Hernandez
88efeaee22 Changes (* location in pointer variables, avoiding include, and using APInt::getLimitedValue) based on feedback to r85814
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85933 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 20:02:35 +00:00
Chris Lattner
ff2f683143 remove unneeded checks of isFreeCall
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85866 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 05:35:19 +00:00
Chris Lattner
b8d264aa6b remove a check of isFreeCall: the argument to free is already nocapture so the generic call code works fine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85865 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 05:34:51 +00:00
Victor Hernandez
bc117b83f6 Set bit instead of calling pow() to compute 2 << n
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85814 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 18:51:28 +00:00
Edward O'Callaghan
438b00b2ad Fix for warning seen on DF-BSD, Victor, please fix this to use a shift instead of pow()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85781 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 03:14:31 +00:00
Edward O'Callaghan
2afd0723a2 Apply fix for PR5135, Credit to Andreas Neustifter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85779 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02 02:55:39 +00:00
Duncan Sands
b046964101 Add a missing closing parenthesis, and tweak to fit in 80
columns.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85732 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 19:12:43 +00:00
Chris Lattner
66588707ac add a comment about why we don't allow inlining indbr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85724 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 18:16:30 +00:00
Douglas Gregor
076124ef26 Reverting 85714, 85715, 85716, which are breaking the build
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85717 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 16:42:53 +00:00
Dan Gohman
2166f62290 Add a function to Passes.h to allow clients to create instances
of the ScalarEvolution pass without needing to #include ScalarEvolution.h.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85716 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 15:28:36 +00:00
Dan Gohman
34e9d7b6be Don't #include Pass.h from CallGraph.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85715 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 15:23:35 +00:00
Chris Lattner
b93a23a532 pull check for return inst out of loop, never inline a callee that contains
an indirectbr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 03:07:53 +00:00
Dan Gohman
4c7279ac72 Rename forgetLoopBackedgeTakenCount to forgetLoop, because it
clears out more information than just the stored backedge taken count.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85664 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-31 15:04:55 +00:00
Dan Gohman
576fd76a68 Make ScalarEvolutionAliasAnalysis slightly more aggressive, by making an
underlying alias call even for non-identified-object values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85656 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-31 14:32:25 +00:00
Devang Patel
5e8e2d7ad9 If string field is empty then return NULL.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85630 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 22:52:47 +00:00
Devang Patel
7cb7e12c08 If a type is derived from a derived type then calculate size appropriately.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85619 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 22:09:30 +00:00
Devang Patel
94dfaec32c First bitcase use may not lead to a dbg.declare intrinsic. Iterate uses until one find's dbg.declare intrinsic.
Patch by Sunae Seo.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85518 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 18:20:34 +00:00
Zhongxing Xu
06ff7505e1 fix 80-col.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85480 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 04:41:24 +00:00
Zhongxing Xu
8370057f0c Explicitly convert to double to suppress Visual C++ 2008 build error C2668 pow is ambiguous call to overloaded function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85478 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 03:43:06 +00:00
Victor Hernandez
90f48e7c91 Extend getMallocArraySize() to determine the array size if the malloc argument is:
ArraySize * ElementSize
ElementSize * ArraySize
ArraySize << log2(ElementSize)
ElementSize << log2(ArraySize)

Refactor isArrayMallocHelper and delete isSafeToGetMallocArraySize, so that there is only 1 copy of the malloc array determining logic.
Update users of getMallocArraySize() to not bother calling isArrayMalloc() as well.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85421 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 20:18:55 +00:00
Owen Anderson
b62f792e78 Treat lifetime begin/end markers as allocations/frees respectively for the
purposes for GVN/DSE.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85383 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 07:05:35 +00:00
Owen Anderson
a85a66423d Be more careful about invariance reasoning on "store" queries. Stores still need
to depend on Ref and ModRef calls within the invariant region.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85380 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 06:30:52 +00:00
Owen Anderson
4bc737c5ef Add trivial support for the invariance intrinsics to memdep. This logic is
purely local for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85378 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 06:18:42 +00:00
Chris Lattner
ab21db79ef rename indbr -> indirectbr to appease the residents of #llvm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85351 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 00:19:10 +00:00
Chris Lattner
7b876e4644 make the build build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85319 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 21:43:39 +00:00
Chris Lattner
2688bcbee1 Random updates to passes for indbr, I need blockaddress before I can do much more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 21:27:42 +00:00
Victor Hernandez
f006b183e2 Rename MallocFreeHelper as MemoryBuiltins
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85286 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 20:05:49 +00:00
Victor Hernandez
f2becca90b Rename MallocHelper as MallocFreeHelper, since it now also identifies calls to free()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85181 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 23:58:56 +00:00
Victor Hernandez
046e78ce55 Remove FreeInst.
Remove LowerAllocations pass.
Update some more passes to treate free calls just like they were treating FreeInst.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 23:43:48 +00:00
Dan Gohman
6665b0ea68 Teach BasicAA how to analyze Select instructions, and make it more
aggressive on PHI instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85158 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 21:55:43 +00:00