Commit Graph

2678 Commits

Author SHA1 Message Date
Dan Gohman 6a976bbcb7 Simplify ComputeMultiple so that it doesn't depend on TargetData.
llvm-svn: 89175
2009-11-18 00:58:27 +00:00
Devang Patel ee07075010 Remove dead code.
llvm-svn: 89156
2009-11-17 22:39:08 +00:00
Chris Lattner e58c05780e typo spotted by duncan.
llvm-svn: 88884
2009-11-16 03:51:42 +00:00
Chris Lattner 7735878591 teach LVI to infer edge information from switch instructions.
This allows JT to eliminate a ton of infeasible edges when
handling code like the templates in PatternMatch.h

llvm-svn: 88869
2009-11-15 20:02:12 +00:00
Chris Lattner b0c0a0df3e fix a logic error that would cause LVI-JT to miscompile
some conditionals

llvm-svn: 88868
2009-11-15 20:01:24 +00:00
Chris Lattner 2c708562f5 implement the first stab at caching queries. This isn't correct
(because the invalidation logic is missing) but LVI isn't enabled
by default anyway.

llvm-svn: 88867
2009-11-15 20:00:52 +00:00
Chris Lattner af025d3f6e refactor a bunch of code forming the new LazyValueInfoCache
and LVIQuery classes, no functionality change.

llvm-svn: 88866
2009-11-15 19:59:49 +00:00
Nick Lewycky c53e2ecf02 Teach BasicAA that a constant expression can't alias memory provably not
allocated until runtime (such as an alloca). Patch by Hans Wennborg!

llvm-svn: 88760
2009-11-14 06:15:14 +00:00
Devang Patel 76a06074eb Revert r87059 for now. It is failing clang tests.
llvm-svn: 87070
2009-11-13 02:27:33 +00:00
Victor Hernandez 41e7648e09 Remove unnecessary llvm.dbg.declare bitcast
llvm-svn: 87059
2009-11-13 01:44:55 +00:00
Devang Patel 2904aa9f6e "Attach debug info with llvm instructions" mode was enabled a month ago. Now make it permanent and remove old way of inserting intrinsics to encode debug info for line number and scopes.
llvm-svn: 87014
2009-11-12 19:02:56 +00:00
Evan Cheng 85a9f430e9 - Teach LSR to avoid changing cmp iv stride if it will create an immediate that
cannot be folded into target cmp instruction.
- Avoid a phase ordering issue where early cmp optimization would prevent the
  later count-to-zero optimization.
- Add missing checks which could cause LSR to reuse stride that does not have
  users.
- Fix a bug in count-to-zero optimization code which failed to find the pre-inc
  iv's phi node.
- Remove, tighten, loosen some incorrect checks disable valid transformations.
- Quite a bit of code clean up.

llvm-svn: 86969
2009-11-12 07:35:05 +00:00
Chris Lattner 22db4b5e0c various fixes to the lattice transfer functions.
llvm-svn: 86952
2009-11-12 04:57:13 +00:00
Chris Lattner 565ee2f1bd Add a new getPredicateOnEdge method which returns more rich information for
constant constraints.  Improve the LVI lattice to include inequality 
constraints.

llvm-svn: 86950
2009-11-12 04:36:58 +00:00
Chris Lattner d5e25436a1 expose edge information and switch j-t to use it.
llvm-svn: 86920
2009-11-12 01:29:10 +00:00
Chris Lattner b584d1e456 move some stuff into DEBUG's and turn on lazy-value-info for
the basic.ll testcase.

llvm-svn: 86918
2009-11-12 01:22:16 +00:00
Devang Patel 862ef782de Do not use StringRef in DebugInfo interface.
This allows StringRef to skip controversial if(str) check in constructor.
Buildbots, wait for corresponding clang and llvm-gcc FE check-ins!

llvm-svn: 86914
2009-11-12 00:50:58 +00:00
Chris Lattner 19019eaf00 make LazyValueInfo actually to some stuff. This isn't very tested but improves
strswitch.

llvm-svn: 86889
2009-11-11 22:48:44 +00:00
Chris Lattner fde1f8d0d8 stub out some LazyValueInfo interfaces, and have JumpThreading
start using them in a trivial way when -enable-jump-threading-lvi
is passed.  enable-jump-threading-lvi will be my playground for 
awhile.

llvm-svn: 86789
2009-11-11 02:08:33 +00:00
Chris Lattner 741c94c719 Stub out a new lazy value info pass, which will eventually
vend value constraint information to the optimizer.

llvm-svn: 86767
2009-11-11 00:22:30 +00:00
Chris Lattner c4e03b7ac7 remove redundant foward declaration. This function is already in
Analysis/Passes.h

llvm-svn: 86765
2009-11-11 00:21:21 +00:00
Devang Patel f6eeaebd76 Implement support to debug inlined functions.
llvm-svn: 86748
2009-11-10 23:06:00 +00:00
Chris Lattner 852d6d64ff move some generally useful functions out of jump threading
into libanalysis and transformutils.

llvm-svn: 86735
2009-11-10 22:26:15 +00:00
Devang Patel 42c1d17dd1 Process InlinedAt location info.
Update InsertDeclare to return newly inserted llvm.dbg.declare intrinsic.

llvm-svn: 86727
2009-11-10 22:05:35 +00:00
Victor Hernandez fcc77b1c02 Update computeArraySize() to use ComputeMultiple() to determine the array size associated with a malloc; also extend PerformHeapAllocSRoA() to check if the optimized malloc's arg had its highest bit set, so that it is safe for ComputeMultiple() to look through sext instructions while determining the optimized malloc's array size
llvm-svn: 86676
2009-11-10 08:32:25 +00:00
Victor Hernandez 4744488e8d Add ComputeMultiple() analysis function that recursively determines if a Value V is a multiple of unsigned Base
llvm-svn: 86675
2009-11-10 08:28:35 +00:00
Chris Lattner ab799110c6 I misread the parens, not so redundant after all.
llvm-svn: 86648
2009-11-10 02:04:54 +00:00
Chris Lattner ee89d5a4d0 remove some redundant parens.
llvm-svn: 86645
2009-11-10 01:56:04 +00:00
Chris Lattner fb7f87d5a3 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.

llvm-svn: 86637
2009-11-10 01:08:51 +00:00
Jeffrey Yasskin b40d3f76a0 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!

llvm-svn: 86636
2009-11-10 01:02:17 +00:00
Chris Lattner a71e9d61be factor simplification logic for AND and OR out to InstSimplify from instcombine.
llvm-svn: 86635
2009-11-10 00:55:12 +00:00
Chris Lattner ccfdceb22c pull a bunch of logic out of instcombine into instsimplify for compare
simplification, this handles the foldable fcmp x,x cases among many others.

llvm-svn: 86627
2009-11-09 23:55:12 +00:00
Dan Gohman 2ac504729b Pass the (optional) TargetData object to ConstantFoldInstOperands
and ConstantFoldCompareInstOperands.

llvm-svn: 86626
2009-11-09 23:34:17 +00:00
Chris Lattner c1f19071f8 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.

llvm-svn: 86624
2009-11-09 23:28:39 +00:00
Chris Lattner cdfb80de16 fix ConstantFoldCompareInstOperands to take the LHS/RHS as
individual operands instead of taking a temporary array

llvm-svn: 86619
2009-11-09 23:06:58 +00:00
Chris Lattner 084a1b5581 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.

llvm-svn: 86613
2009-11-09 22:57:59 +00:00
Dan Gohman ccb4584edd 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)

llvm-svn: 86582
2009-11-09 19:29:11 +00:00
Dan Gohman 5196e415ad Minor tidiness fixes.
llvm-svn: 86565
2009-11-09 18:19:43 +00:00
Victor Hernandez f3db915294 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.

llvm-svn: 86311
2009-11-07 00:16:28 +00:00
Devang Patel 33e0c99d67 Tolerate invalid derived type.
llvm-svn: 86269
2009-11-06 18:24:05 +00:00
Devang Patel cc11371b77 Do not bother to emit debug info for nameless global variable.
llvm-svn: 86259
2009-11-06 17:58:12 +00:00
Chris Lattner 46b5c642b9 remove a bunch of extraneous LLVMContext arguments
from various APIs, addressing PR5325.

llvm-svn: 86231
2009-11-06 04:27:31 +00:00
Victor Hernandez b9f5899779 Revert r86077 because it caused crashes in 179.art and 175.vpr on ARM
llvm-svn: 86213
2009-11-06 01:33:24 +00:00
Dan Gohman 2267f8aa72 Fix IVUsers to avoid assuming that the loop has a unique backedge.
llvm-svn: 86161
2009-11-05 19:41:37 +00:00
Dan Gohman e3a1706e33 Factor out the predicate code for loopsimplify form exit blocks into
a separate helper function.

llvm-svn: 86159
2009-11-05 19:21:41 +00:00
Victor Hernandez 492ed30a32 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.

llvm-svn: 86077
2009-11-05 00:03:03 +00:00
Devang Patel f05d57283e While calculating original type size for a derived type, handle type variants encoded as DIDerivedType appropriately.
This improves bitfield support.

llvm-svn: 86073
2009-11-04 23:48:00 +00:00
Victor Hernandez 3318858efd Changes requested (avoid getFunction(), avoid Type creation via isVoidTy(), and avoid redundant isFreeCall cases) in feedback to r85176
llvm-svn: 85936
2009-11-03 20:39:35 +00:00
Victor Hernandez 5cd73a3470 Changes (* location in pointer variables, avoiding include, and using APInt::getLimitedValue) based on feedback to r85814
llvm-svn: 85933
2009-11-03 20:02:35 +00:00
Chris Lattner 03d1bca60a remove unneeded checks of isFreeCall
llvm-svn: 85866
2009-11-03 05:35:19 +00:00