summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-10-13 01:42:53 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-10-13 01:42:53 +0000
commit70e8505eb1a5379d884f3bfd8cc7f9f252edcaec (patch)
treeb228c743c5e9f047a26a478f2660dac4acee4c6f /llvm/lib/Analysis
parenta5314b83d168bd1c48cfe5a0ec982fb27e2ed9ad (diff)
downloadbcm5719-llvm-70e8505eb1a5379d884f3bfd8cc7f9f252edcaec.tar.gz
bcm5719-llvm-70e8505eb1a5379d884f3bfd8cc7f9f252edcaec.zip
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. llvm-svn: 83931
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/MemoryDependenceAnalysis.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index 97b791caf92..d6400757a51 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/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 ||
OpenPOWER on IntegriCloud