summaryrefslogtreecommitdiff
path: root/lib/Analysis/MemoryDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2012-09-04 03:30:13 +0000
committerBob Wilson <bob.wilson@apple.com>2012-09-04 03:30:13 +0000
commit2d5c28da0d14883cd0cd6fcf38d7e28040b634c0 (patch)
treee419212e537f573bf782c8455019e2d58faa4fd3 /lib/Analysis/MemoryDependenceAnalysis.cpp
parent2dc88d94c34294184368ef0d9663342be2d42811 (diff)
downloadllvm-2d5c28da0d14883cd0cd6fcf38d7e28040b634c0.tar.gz
llvm-2d5c28da0d14883cd0cd6fcf38d7e28040b634c0.tar.bz2
llvm-2d5c28da0d14883cd0cd6fcf38d7e28040b634c0.tar.xz
Be conservative about allocations that may alias the accessed pointer.
If an allocation has a must-alias relation to the access pointer, we treat it as a Def. Otherwise, without this check, the code here was just skipping over the allocation call and ignoring it. I noticed this by inspection and don't have a specific testcase that it breaks, but it seems like we need to treat a may-alias allocation as a Clobber. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163127 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r--lib/Analysis/MemoryDependenceAnalysis.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp
index 804217a83d..5736c3569d 100644
--- a/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -485,6 +485,9 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad,
if (AccessPtr == Inst || AA->isMustAlias(Inst, AccessPtr))
return MemDepResult::getDef(Inst);
+ // Be conservative if the accessed pointer may alias the allocation.
+ if (AA->alias(Inst, AccessPtr) != AliasAnalysis::NoAlias)
+ return MemDepResult::getClobber(Inst);
// If the allocation is not aliased and does not read memory (like
// strdup), it is safe to ignore.
if (isa<AllocaInst>(Inst) ||