diff options
author | Victor Hernandez <vhernandez@apple.com> | 2009-10-13 01:42:53 +0000 |
---|---|---|
committer | Victor Hernandez <vhernandez@apple.com> | 2009-10-13 01:42:53 +0000 |
commit | 5c78736f85579aa6de38cba2742ea13ff9f79e70 (patch) | |
tree | 02cdb4477646ea25599656ced604675bd7a989d4 /lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | 2b7b37a4c929add924018b717ef9fcc058f1b27f (diff) |
Memory dependence analysis was incorrectly stopping to scan for stores to a pointer at bitcast uses of a malloc call.
It should continue scanning until the malloc call, and this patch fixes that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | lib/Analysis/MemoryDependenceAnalysis.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 97b791caf9..d6400757a5 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -225,16 +225,11 @@ getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad, // 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. - if (AllocationInst *AI = dyn_cast<AllocationInst>(Inst)) { - Value *AccessPtr = MemPtr->getUnderlyingObject(); - - if (AccessPtr == AI || - AA->alias(AI, 1, AccessPtr, 1) == AliasAnalysis::MustAlias) - return MemDepResult::getDef(AI); - continue; - } - - if (isMalloc(Inst)) { + // 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. + if (isa<AllocationInst>(Inst) || extractMallocCall(Inst)) { Value *AccessPtr = MemPtr->getUnderlyingObject(); if (AccessPtr == Inst || |