diff options
author | Bob Wilson <bob.wilson@apple.com> | 2012-09-03 05:15:15 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2012-09-03 05:15:15 +0000 |
commit | dcc54decd5329da3ec3c7ab7cf94d72a1ed53c9b (patch) | |
tree | 27ba1e426ea5578af817a3f1799608d25f5bb14a /llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | fd648a0320131e73b9db0d622f59ff2fe80e3e4b (diff) | |
download | bcm5719-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.cpp | 9 |
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. |