aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2016-03-09 23:19:56 +0000
committerPhilip Reames <listmail@philipreames.com>2016-03-09 23:19:56 +0000
commitd9f4a3d18cb6d2fc6a32fdb05089a7b736f83fc5 (patch)
tree9147b748a35a92673a1dfb06f1139df91ec2f8b8 /llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
parentac115ed72fff08426afcaf7031560bb1c6f0282f (diff)
downloadllvm-d9f4a3d18cb6d2fc6a32fdb05089a7b736f83fc5.zip
llvm-d9f4a3d18cb6d2fc6a32fdb05089a7b736f83fc5.tar.gz
llvm-d9f4a3d18cb6d2fc6a32fdb05089a7b736f83fc5.tar.bz2
[BasicAA/MDA] Sink aliasing rules for malloc and calloc into BasicAA
MemoryDependenceAnalysis had a hard-coded exception to the general aliasing rules for malloc and calloc. The reasoning that applied there is equally valid in BasicAA and clarifies the remaining logic in MDA. In principal, this can expose slightly more optimization opportunities, but since essentially all of our aliasing aware memory optimization passes go through MDA, this will likely be NFC in practice. Differential Revision: http://reviews.llvm.org/D15912 llvm-svn: 263075
Diffstat (limited to 'llvm/lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/MemoryDependenceAnalysis.cpp19
1 files changed, 3 insertions, 16 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index a832c8d..457b9e3 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -669,26 +669,13 @@ MemDepResult MemoryDependenceAnalysis::getSimplePointerDependencyFrom(
// If this is an allocation, and if we know that the accessed pointer is to
// the allocation, return Def. This means that there is no dependence and
// the access can be optimized based on that. For example, a load could
- // turn into undef.
- // Note: Only determine this to be a malloc if Inst is the malloc call, not
- // a subsequent bitcast of the malloc call result. There can be stores to
- // the malloced memory between the malloc call and its bitcast uses, and we
- // need to continue scanning until the malloc call.
+ // turn into undef. Note that we can bypass the allocation itself when
+ // looking for a clobber in many cases; that's an alias property and is
+ // handled by BasicAA.
if (isa<AllocaInst>(Inst) || isNoAliasFn(Inst, TLI)) {
const Value *AccessPtr = GetUnderlyingObject(MemLoc.Ptr, DL);
-
if (AccessPtr == Inst || AA->isMustAlias(Inst, AccessPtr))
return MemDepResult::getDef(Inst);
- if (isInvariantLoad)
- continue;
- // Be conservative if the accessed pointer may alias the allocation -
- // fallback to the generic handling below.
- if ((AA->alias(Inst, AccessPtr) == NoAlias) &&
- // If the allocation is not aliased and does not read memory (like
- // strdup), it is safe to ignore.
- (isa<AllocaInst>(Inst) || isMallocLikeFn(Inst, TLI) ||
- isCallocLikeFn(Inst, TLI)))
- continue;
}
if (isInvariantLoad)