[llvm-commits] [llvm] r163127 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Bob Wilson bob.wilson at apple.com
Mon Sep 3 20:30:13 PDT 2012


Author: bwilson
Date: Mon Sep  3 22:30:13 2012
New Revision: 163127

URL: http://llvm.org/viewvc/llvm-project?rev=163127&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=163127&r1=163126&r2=163127&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Mon Sep  3 22:30:13 2012
@@ -485,6 +485,9 @@
       
       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) ||





More information about the llvm-commits mailing list