Nick Lewycky
7b751873f1
Don't forget that strcpy and friends return a pointer to the destination, so
...
it's not a dead store if that pointer is used. Whoops!
llvm-svn: 164583
2012-09-25 01:55:59 +00:00
Nick Lewycky
063e28dd5d
Remove unused name of variable to quiet a warning. Also canonicalize a
...
declaration to use the same form as in the rest of the file. No functionality
change.
llvm-svn: 164576
2012-09-24 23:47:23 +00:00
Nick Lewycky
74f862b349
Teach DSE that strcpy, strncpy, strcat and strncat are all stores which may be
...
dead.
llvm-svn: 164561
2012-09-24 22:09:10 +00:00
Nick Lewycky
f9ea118d45
Move all the calls to AA.getTargetLibraryInfo() to using a TLI member variable.
...
No functionality change.
llvm-svn: 164560
2012-09-24 22:07:09 +00:00
Benjamin Kramer
56915b8d2f
DSE: Poking holes into a SetVector is expensive, avoid it if possible.
...
llvm-svn: 163480
2012-09-09 16:44:05 +00:00
Benjamin Kramer
b92d13cc42
Make MemoryBuiltins aware of TargetLibraryInfo.
...
This disables malloc-specific optimization when -fno-builtin (or -ffreestanding)
is specified. This has been a problem for a long time but became more severe
with the recent memory builtin improvements.
Since the memory builtin functions are used everywhere, this required passing
TLI in many places. This means that functions that now have an optional TLI
argument, like RecursivelyDeleteTriviallyDeadFunctions, won't remove dead
mallocs anymore if the TLI argument is missing. I've updated most passes to do
the right thing.
Fixes PR13694 and probably others.
llvm-svn: 162841
2012-08-29 15:32:21 +00:00
Craig Topper
6a2fe056ce
Change greater than to greater than or equal so that an identical sized store to the same offset is treated as completing overwriting.
...
llvm-svn: 161857
2012-08-14 07:32:05 +00:00
Eli Friedman
a64c4c130d
isAllocLikeFn is allowed to return true for functions which read memory; make
...
sure we account for that correctly in DeadStoreElimination. Fixes a regression
from r158919. PR13547.
llvm-svn: 161468
2012-08-08 02:17:32 +00:00
Nadav Rotem
bd2b55bc74
Clean whitespaces.
...
llvm-svn: 160668
2012-07-24 10:51:42 +00:00
Nuno Lopes
c9edab11db
refactor the MemoryBuiltin analysis:
...
- provide more extensive set of functions to detect library allocation functions (e.g., malloc, calloc, strdup, etc)
- provide an API to compute the size and offset of an object pointed by
Move a few clients (GVN, AA, instcombine, ...) to the new API.
This implementation is a lot more aggressive than each of the custom implementations being replaced.
Patch reviewed by Nick Lewycky and Chandler Carruth, thanks.
llvm-svn: 158919
2012-06-21 15:45:28 +00:00
Evan Cheng
28043bad07
It's not deterministic to iterate over SmallPtrSet. Replace it with SmallSetVector. Patch by Daniel Reynaud. rdar://11671029
...
llvm-svn: 158594
2012-06-16 04:28:11 +00:00
Dan Gohman
8b1a3cec89
Teach DeadStoreElimination to eliminate exit-block stores with phi addresses.
...
llvm-svn: 156558
2012-05-10 18:57:38 +00:00
Nuno Lopes
ea7b37e3ae
teach DSE and isInstructionTriviallyDead() about calloc
...
llvm-svn: 156553
2012-05-10 17:14:00 +00:00
Pete Cooper
ab5f2302dc
Reverted r152620 - DSE: Shorten memset when a later store overwrites the start of it. There were all sorts of buildbot issues
...
llvm-svn: 151621
2012-02-28 05:06:24 +00:00
Pete Cooper
93352dcd53
DSE: Shorten memset when a later store overwrites the start of it
...
llvm-svn: 151620
2012-02-28 04:27:10 +00:00
Craig Topper
639b152ca5
Convert assert(0) to llvm_unreachable
...
llvm-svn: 149967
2012-02-07 05:05:23 +00:00
Nick Lewycky
d2c1661e9f
Fix infinite loop in DSE when deleting a free in a reachable loop that's also
...
trivially infinite.
llvm-svn: 146197
2011-12-08 22:36:35 +00:00
Pete Cooper
32e376f7e1
Fixed deadstoreelimination bug where negative indices were incorrectly causing the optimisation to occur
...
Turns out long long + unsigned long long is unsigned. Doh!
Fixes http://llvm.org/bugs/show_bug.cgi?id=11455
llvm-svn: 145731
2011-12-03 00:04:30 +00:00
Nick Lewycky
ff690249a9
Merge isObjectPointerWithTrustworthySize with getPointerSize. Use it when
...
looking at the size of the pointee. Fixes PR11390!
llvm-svn: 144773
2011-11-16 03:49:48 +00:00
Pete Cooper
93d3c835a0
Fixed bug in DeadStoreElimination commit r144239
...
Size of data being pointed to wasn't always being checked so some small writes were killing big writes
Fixes <rdar://problem/10426753>
llvm-svn: 144312
2011-11-10 20:22:08 +00:00
Pete Cooper
38700a1201
DeadStoreElimination can now trim the size of a store if the end of the store is dead.
...
Currently checks alignment and killing stores on a power of 2 boundary as this is likely
to trim the size of the earlier store without breaking large vector stores into scalar ones.
Fixes <rdar://problem/10140300>
llvm-svn: 144239
2011-11-09 23:07:35 +00:00
Nick Lewycky
7ea3dd8ae5
Do simple cross-block DSE when we encounter a free statement. Fixes PR11240.
...
llvm-svn: 143808
2011-11-05 10:48:42 +00:00
Daniel Dunbar
0193e03f99
Speculatively revert "DeadStoreElimination can now trim the size of a store if
...
the end of it is dead.", which appears to break bootstrapping LLVM.
llvm-svn: 143668
2011-11-04 00:48:26 +00:00
Pete Cooper
4902705b5f
DeadStoreElimination can now trim the size of a store if the end of it is dead.
...
Only currently done if the later store is writing to a power of 2 address or
has the same alignment as the earlier store as then its likely to not break up
large stores into smaller ones
Fixes <rdar://problem/10140300>
llvm-svn: 143630
2011-11-03 18:01:56 +00:00
Nick Lewycky
25e5f6896b
A non-escaping malloc in the entry block is not unlike an alloca. Do dead-store
...
elimination on them too.
llvm-svn: 142735
2011-10-22 21:59:35 +00:00
Eli Friedman
e702d68556
Enhance the memdep interface so that users can tell the difference between a dependency which cannot be calculated and a path reaching the entry point of the function. This patch introduces isNonFuncLocal, which replaces isUnknown in some cases.
...
Patch by Xiaoyi Guo.
llvm-svn: 141896
2011-10-13 22:14:57 +00:00
Eli Friedman
3f92f87989
Add comment to clarify the behavior of a helper in DSE.
...
llvm-svn: 139571
2011-09-13 01:28:59 +00:00
Owen Anderson
ca0326a423
Try again at r138809 (make DSE more aggressive in removing dead stores at the end of a function), now with less deleting stores before memcpy's.
...
llvm-svn: 139150
2011-09-06 18:14:09 +00:00
Owen Anderson
d3a9f00a58
Speculatively revert r138809 in an attempt to fix DragonEgg.
...
llvm-svn: 138829
2011-08-30 21:11:06 +00:00
Owen Anderson
3ec8beb8c8
When walking backwards to eliminate final stores to allocas at the end of a function, encountering an unrelated store should not cause us to give up like encountering a load does.
...
llvm-svn: 138809
2011-08-30 18:51:55 +00:00
Eli Friedman
775a316a06
Atomic load/store handling for the passes using memdep (GVN, DSE, memcpyopt).
...
llvm-svn: 137888
2011-08-17 22:22:24 +00:00
Eli Friedman
f226974353
Misc mid-level changes for new 'fence' instruction.
...
llvm-svn: 136205
2011-07-27 01:08:30 +00:00
Chris Lattner
e1fe7061ce
land David Blaikie's patch to de-constify Type, with a few tweaks.
...
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Eli Friedman
47b3cd9fff
Add "unknown" results for memdep, which mean "I don't know whether a dependence for the given instruction exists in the given block". This cleans up all the existing hacks in memdep which represent this concept by returning clobber with various unrelated instructions.
...
llvm-svn: 133031
2011-06-15 00:47:34 +00:00
Chris Lattner
0304b82f80
Fix a ton of comment typos found by codespell. Patch by
...
Luis Felipe Strano Moraes!
llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Bill Wendling
59a1021dc6
* The DSE code that tested for overlapping needed to take into account the fact
...
that one of the numbers is signed while the other is unsigned. This could lead
to a wrong result when the signed was promoted to an unsigned int.
* Add the data layout line to the testcase so that it will test the appropriate
thing.
Patch by David Terei!
llvm-svn: 128577
2011-03-30 21:37:19 +00:00
Benjamin Kramer
a28b1da096
DSE: Remove an early exit optimization that depended on the ordering of a SmallPtrSet.
...
Fixes PR9569 and will hopefully make selfhost on ASLR-enabled systems more deterministic.
llvm-svn: 128482
2011-03-29 20:28:57 +00:00
Bill Wendling
24757df3f3
Simplification noticed by Frits.
...
llvm-svn: 128333
2011-03-26 09:32:07 +00:00
Bill Wendling
0e3e7257ef
Rework the logic that determines if a store completely overlaps an ealier store.
...
There are two ways that a later store can comletely overlap a previous store:
1. They both start at the same offset, but the earlier store's size is <= the
later's size, or
2. The earlier store's offset is > the later's offset, but it's offset + size
doesn't extend past the later's offset + size.
llvm-svn: 128332
2011-03-26 08:02:59 +00:00
Bill Wendling
72b390743d
PR9561: A store with a negative offset (via GEP) could erroniously say that it
...
completely overlaps a previous store, thus mistakenly deleting that store. Check
for this condition.
llvm-svn: 128319
2011-03-26 01:20:37 +00:00
Dan Gohman
db0dc19c04
Give GetUnderlyingObject a TargetData, to keep it in sync
...
with BasicAA's DecomposeGEPExpression, which recently began
using a TargetData. This fixes PR8968, though the testcase
is awkward to reduce.
Also, update several off GetUnderlyingObject's users
which happen to have a TargetData handy to pass it in.
llvm-svn: 124134
2011-01-24 18:53:32 +00:00
Cameron Zwarich
c93f994801
Remove code for updating dominance frontiers and some outdated references to
...
dominance and post-dominance frontiers.
llvm-svn: 123725
2011-01-18 04:11:31 +00:00
Dan Gohman
295ba3ab26
Move Value::getUnderlyingObject to be a standalone
...
function so that it can live in Analysis instead of
VMCore.
llvm-svn: 121885
2010-12-15 20:02:24 +00:00
Chris Lattner
2f134ca2cc
Use a stronger predicate here, pointed out by Duncan
...
llvm-svn: 121040
2010-12-06 21:48:10 +00:00
Chris Lattner
2907722386
add some DEBUG statements.
...
llvm-svn: 121038
2010-12-06 21:13:51 +00:00
Chris Lattner
db6c348f31
Fix PR8728, a miscompilation I recently introduced. When optimizing
...
memcpy's like:
memcpy(A, B)
memcpy(A, C)
we cannot delete the first memcpy as dead if A and C might be aliases.
If so, we actually get:
memcpy(A, B)
memcpy(A, A)
which is not correct to transform into:
memcpy(A, A)
This patch was heavily influenced by Jakub Staszak's patch in PR8728, thanks
Jakub!
llvm-svn: 120974
2010-12-06 01:48:06 +00:00
Chris Lattner
c888f3ec58
Enhance DSE to handle the variable index case in PR8657.
...
llvm-svn: 120498
2010-11-30 23:43:23 +00:00
Chris Lattner
b9c5a6fa04
teach DSE to use GetPointerBaseWithConstantOffset to analyze
...
may-aliasing stores that partially overlap with different base
pointers. This implements PR6043 and the non-variable part of
PR8657
llvm-svn: 120485
2010-11-30 23:05:20 +00:00
Chris Lattner
5f5c9a75cb
Make DeleteDeadInstruction be a static function, move some code around.
...
llvm-svn: 120471
2010-11-30 21:58:14 +00:00
Chris Lattner
e58643bcd7
switch RemoveAccessedObjects to use AliasAnalysis::Location to simplify
...
the code. We now get accurate sizes on Loads, though it surely doesn't
matter in practice.
llvm-svn: 120469
2010-11-30 21:47:58 +00:00