summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove the `hasFnAttr' method from Function.Bill Wendling2012-09-261-1/+1
| | | | | | | The hasFnAttr method has been replaced by querying the Attributes explicitly. No intended functionality change. llvm-svn: 164725
* Be conservative about allocations that may alias the accessed pointer.Bob Wilson2012-09-041-0/+3
| | | | | | | | | | If an allocation has a must-alias relation to the access pointer, we treat it as a Def. Otherwise, without this check, the code here was just skipping over the allocation call and ignoring it. I noticed this by inspection and don't have a specific testcase that it breaks, but it seems like we need to treat a may-alias allocation as a Clobber. llvm-svn: 163127
* Fix more fallout from r158919, similar to PR13547.Bob Wilson2012-09-031-2/+7
| | | | | | | | | This code used to only handle malloc-like calls, which do not read memory. r158919 changed it to check isNoAliasFn(), which includes strdup-like and realloc-like calls, but it was not checking for dependencies on the memory read by those calls. llvm-svn: 163106
* Make MemoryBuiltins aware of TargetLibraryInfo.Benjamin Kramer2012-08-291-2/+2
| | | | | | | | | | | | | | | | 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
* MemoryDependenceAnalysis attempts to find the first memory dependency for ↵Nadav Rotem2012-08-131-2/+7
| | | | | | | | | | | function calls. Currently, if GetLocation reports that it did not find a valid pointer (this is the case for volatile load/stores), we ignore the result. This patch adds code to handle the cases where we did not obtain a valid pointer. rdar://11872864 PR12899 llvm-svn: 161802
* refactor the MemoryBuiltin analysis:Nuno Lopes2012-06-211-2/+1
| | | | | | | | | | | | - 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
* Fix typos found by http://github.com/lyda/misspell-checkBenjamin Kramer2012-06-021-1/+1
| | | | llvm-svn: 157885
* Move the capture analysis from MemoryDependencyAnalysis to a more general placeChad Rosier2012-05-141-85/+5
| | | | | | | | | so that it can be reused in MemCpyOptimizer. This analysis is needed to remove an unnecessary memcpy when returning a struct into a local variable. rdar://11341081 PR12686 llvm-svn: 156776
* Hoist simpler checks above llvm::PointerMayBeCaptured. No functional change ↵Chad Rosier2012-05-121-4/+6
| | | | | | intended. llvm-svn: 156687
* Don't call dominates on unreachable instructions. Should fix the dragoneggRafael Espindola2012-02-261-2/+6
| | | | | | build. Testcase is still reducing. llvm-svn: 151474
* The patch resolves the conflict between AddressSanitizer and load widening ↵Kostya Serebryany2012-02-061-0/+8
| | | | | | | | | (GVN). The problem initially reported by Mozilla folks (http://code.google.com/p/address-sanitizer/issues/detail?id=20), but it also prevents us from enabling LLVM bootstrap with AddressSanitizer. llvm-svn: 149925
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-2/+0
| | | | llvm-svn: 148578
* Change CaptureTracking to pass a Use* instead of a Value* when a value isNick Lewycky2011-12-281-1/+2
| | | | | | | | | | | | | | captured. This allows the tracker to look at the specific use, which may be especially interesting for function calls. Use this to fix 'nocapture' deduction in FunctionAttrs. The existing one does not iterate until a fixpoint and does not guarantee that it produces the same result regardless of iteration order. The new implementation builds up a graph of how arguments are passed from function to function, and uses a bottom-up walk on the argument-SCCs to assign nocapture. This gets us nocapture more often, and does so rather efficiently and independent of iteration order. llvm-svn: 147327
* Fix crasher in GVN due to my recent capture tracking changes.Nick Lewycky2011-11-211-1/+1
| | | | llvm-svn: 145047
* Less template, more virtual! Refactoring suggested by Chris in code review.Nick Lewycky2011-11-201-2/+2
| | | | llvm-svn: 145014
* Refactor code to use new attribute getters on CallSite for NoCapture and ByVal.Nick Lewycky2011-11-201-2/+1
| | | | | | | | Suggested in code review by Eli. That code in InstCombine looks kinda suspicious. llvm-svn: 145013
* Refactor capture tracking (which already had a couple flags for whether returnsNick Lewycky2011-11-141-1/+79
| | | | | | | | | | and stores capture) to permit the caller to see each capture point and decide whether to continue looking. Use this inside memdep to do an analysis that basicaa won't do. This lets us solve another devirtualization case, fixing PR8908! llvm-svn: 144580
* Enhance the memdep interface so that users can tell the difference between a ↵Eli Friedman2011-10-131-5/+5
| | | | | | | | 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
* Misc analysis passes that need to be aware of atomic load/store.Eli Friedman2011-08-151-10/+26
| | | | llvm-svn: 137650
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-1/+1
| | | | llvm-svn: 135375
* Add a limit to the number of instructions memdep will scan in a single ↵Eli Friedman2011-06-151-1/+22
| | | | | | | | | | block. This prevents (at least in some cases) O(N^2) runtime in passes like DSE. The limit in this patch is probably too high, but it is enough to stop DSE from going completely insane on a testcase I have (which has a single block with around 50,000 non-aliasing stores in it). rdar://9471075 llvm-svn: 133111
* Add "unknown" results for memdep, which mean "I don't know whether a ↵Eli Friedman2011-06-151-22/+18
| | | | | | 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
* Disable the main feature of 130180, the elimination of loads that areDan Gohman2011-06-041-0/+6
| | | | | | | | | | redundant with partially-aliasing loads. When computing what portion of a clobbering load value is needed, it doesn't consider phi-translation which may have occurred between the clobbing load and the redundant load. llvm-svn: 132631
* When marking a block as being unanalyzable, use "Clobber" on the terminator ↵Eli Friedman2011-06-021-2/+2
| | | | | | | | | | | | instead of the first instruction in the block. This is a bit of a hack; "Clobber" isn't really the right marking in the first place. memdep doesn't really have any way of properly expressing "unanalyzable" at the moment. Using it on the terminator is much less ambiguous than using it on an arbitrary instruction, though. In the given testcase, the "Clobber" was pointing to a load, and GVN was incorrectly assuming that meant that the "Clobber" load overlapped the load being analyzed (when they are actually unrelated). The included testcase tests both this commit and r132434. Part two of rdar://9429882. (r132434 was mislabeled.) llvm-svn: 132442
* In MemoryDependenceAnalysis::getNonLocalPointerDepFromBB, if a given block ↵Eli Friedman2011-06-011-20/+58
| | | | | | | | is is deemed unanalyzable (and we execute one of the "goto PredTranslationFailure" statements), make sure we don't put information about the predecessors of that block into the returned data structures; this can lead to, among other things, extraneous results (which will confuse passes using memdep). Fixes an assert in GVN compiling ruby. Part of rdar://problem/9521954 . Testcase coming up soon. llvm-svn: 132434
* @llvm.lifetime.begin acts as a load, not @llvm.lifetime.end.Owen Anderson2011-05-171-1/+1
| | | | llvm-svn: 131437
* teach GVN to widen integer loads when they are overaligned, when doing an Chris Lattner2011-04-281-10/+31
| | | | | | | | | | | wider load would allow elimination of subsequent loads, and when the wider load is still a native integer type. This eliminates a ton of loads on various benchmarks involving struct fields, though it is somewhat hobbled by clang not being very aggressive about field alignment. This is yet another step along the way towards resolving PR6627. llvm-svn: 130390
* Enhance memdep to return clobber relation between noalias loads whenChris Lattner2011-04-261-3/+95
| | | | | | | | | | | | | | | | an earlier load could be widened to encompass a later load. For example, if we see: X = load i8* P, align 4 Y = load i8* (P+3), align 1 and we have a 32-bit native integer type, we can widen the former load to i32 which then makes the second load redundant. GVN can't actually do anything with this load/load relation yet, so this isn't testable, but it is the next step to resolving PR6627, and a fairly general class of "merge neighboring loads" missed optimizations. llvm-svn: 130250
* use AA::isMustAlias to simplify some calls.Chris Lattner2011-04-261-5/+3
| | | | llvm-svn: 130248
* remove support for llvm.invariant.end from memdep. It is a Chris Lattner2011-04-261-37/+0
| | | | | | work-in-progress that is not progressing, and it has issues. llvm-svn: 130247
* Enhance MemDep: When alias analysis returns a partial alias result,Chris Lattner2011-04-261-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | return it as a clobber. This allows GVN to do smart things. Enhance GVN to be smart about the case when a small load is clobbered by a larger overlapping load. In this case, forward the value. This allows us to compile stuff like this: int test(void *P) { int tmp = *(unsigned int*)P; return tmp+*((unsigned char*)P+1); } into: _test: ## @test movl (%rdi), %ecx movzbl %ch, %eax addl %ecx, %eax ret which has one load. We already handled the case where the smaller load was from a must-aliased base pointer. llvm-svn: 130180
* Give GetUnderlyingObject a TargetData, to keep it in syncDan Gohman2011-01-241-1/+1
| | | | | | | | | | | 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
* Revert r123207: "Turn on memdep's verifyRemoved() in an attempt to smoke out ↵Jakob Stoklund Olesen2011-01-111-3/+1
| | | | | | | | the cause of our gcc bootstrap miscompare." It didn't. llvm-svn: 123215
* Turn on memdep's verifyRemoved() in an attempt to smoke out the cause of our ↵Jakob Stoklund Olesen2011-01-111-1/+3
| | | | | | gcc bootstrap miscompare. llvm-svn: 123207
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-231-1/+1
| | | | | | | new gcc warning that complains on self-assignments and self-initializations. llvm-svn: 122458
* Move Value::getUnderlyingObject to be a standaloneDan Gohman2010-12-151-1/+2
| | | | | | | function so that it can live in Analysis instead of VMCore. llvm-svn: 121885
* Update memdep to handle PartialAlias as MayAlias.Dan Gohman2010-12-131-4/+4
| | | | llvm-svn: 121723
* strength reduce this.Chris Lattner2010-11-301-1/+1
| | | | llvm-svn: 120381
* Initialize MemDep's TD member so buildbots don't trip over an uninitialized ↵Benjamin Kramer2010-11-211-0/+2
| | | | | | | | pointer (TD is passed to PHITransAddr). I wonder why this didn't explode earlier. llvm-svn: 119944
* implement PR8576, deleting dead stores with intervening may-alias stores.Chris Lattner2010-11-211-2/+2
| | | | llvm-svn: 119927
* Add helper functions for computing the Location of load, store,Dan Gohman2010-11-111-20/+6
| | | | | | and vaarg instructions. llvm-svn: 118845
* It's not necessary to clear out the Size and TBAATag at each ofDan Gohman2010-11-111-12/+1
| | | | | | these points. llvm-svn: 118752
* Set NonLocalDepInfo's Size field to UnknownSize when invalidatingDan Gohman2010-11-111-5/+5
| | | | | | it, so that it doesn't appear to be a known size. llvm-svn: 118748
* When clearing a non-local pointer dependency cache entry, clearDan Gohman2010-11-101-0/+8
| | | | | | the reverse map too. This fixes seflhost build errors. llvm-svn: 118729
* Factor out the code for computing an AliasAnalysis::LocationDan Gohman2010-11-101-82/+101
| | | | | | for a given instruction into a helper function. llvm-svn: 118723
* Fully invalidate cached results when a prior query's size orDan Gohman2010-11-101-10/+23
| | | | | | type is insufficient for, or incompatible with, the current query. llvm-svn: 118721
* Enhance GVN to do more precise alias queries for non-local memoryDan Gohman2010-11-101-9/+38
| | | | | | | | | | | | | | | references. For example, this allows gvn to eliminate the load in this example: void foo(int n, int* p, int *q) { p[0] = 0; p[1] = 1; if (n) { *q = p[0]; } } llvm-svn: 118714
* Teach memdep to use pointsToConstantMemory to determine that loadsDan Gohman2010-10-291-5/+10
| | | | | | from constant memory don't alias any stores. llvm-svn: 117636
* Get rid of static constructors for pass registration. Instead, every pass ↵Owen Anderson2010-10-191-0/+1
| | | | | | | | | | | | | | | | | exposes an initializeMyPassFunction(), which must be called in the pass's constructor. This function uses static dependency declarations to recursively initialize the pass's dependencies. Clients that only create passes through the createFooPass() APIs will require no changes. Clients that want to use the CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h before parsing commandline arguments. I have tested this with all standard configurations of clang and llvm-gcc on Darwin. It is possible that there are problems with the static dependencies that will only be visible with non-standard options. If you encounter any crash in pass registration/creation, please send the testcase to me directly. llvm-svn: 116820
* Begin adding static dependence information to passes, which will allow us toOwen Anderson2010-10-121-1/+4
| | | | | | | | | perform initialization without static constructors AND without explicit initialization by the client. For the moment, passes are required to initialize both their (potential) dependencies and any passes they preserve. I hope to be able to relax the latter requirement in the future. llvm-svn: 116334
OpenPOWER on IntegriCloud