summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2012-09-03 05:15:15 +0000
committerBob Wilson <bob.wilson@apple.com>2012-09-03 05:15:15 +0000
commitdcc54decd5329da3ec3c7ab7cf94d72a1ed53c9b (patch)
tree27ba1e426ea5578af817a3f1799608d25f5bb14a /llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
parentfd648a0320131e73b9db0d622f59ff2fe80e3e4b (diff)
downloadbcm5719-llvm-dcc54decd5329da3ec3c7ab7cf94d72a1ed53c9b.tar.gz
bcm5719-llvm-dcc54decd5329da3ec3c7ab7cf94d72a1ed53c9b.zip
Fix more fallout from r158919, similar to PR13547.
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
Diffstat (limited to 'llvm/lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/MemoryDependenceAnalysis.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index 2accaefb2e4..804217a83d1 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -479,12 +479,17 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad,
// 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.
- if (isa<AllocaInst>(Inst) || isNoAliasFn(Inst, AA->getTargetLibraryInfo())){
+ const TargetLibraryInfo *TLI = AA->getTargetLibraryInfo();
+ if (isa<AllocaInst>(Inst) || isNoAliasFn(Inst, TLI)) {
const Value *AccessPtr = GetUnderlyingObject(MemLoc.Ptr, TD);
if (AccessPtr == Inst || AA->isMustAlias(Inst, AccessPtr))
return MemDepResult::getDef(Inst);
- continue;
+ // If the allocation is not aliased and does not read memory (like
+ // strdup), it is safe to ignore.
+ if (isa<AllocaInst>(Inst) ||
+ isMallocLikeFn(Inst, TLI) || isCallocLikeFn(Inst, TLI))
+ continue;
}
// See if this instruction (e.g. a call or vaarg) mod/ref's the pointer.
OpenPOWER on IntegriCloud