[llvm-commits] [llvm] r117783 - in /llvm/trunk: lib/Transforms/IPO/FunctionAttrs.cpp test/Transforms/FunctionAttrs/2010-10-30-volatile.ll

Duncan Sands baldrick at free.fr
Sat Oct 30 05:59:44 PDT 2010


Author: baldrick
Date: Sat Oct 30 07:59:44 2010
New Revision: 117783

URL: http://llvm.org/viewvc/llvm-project?rev=117783&view=rev
Log:
If a function does a volatile load from a global constant, do not
consider it to be readonly.  In fact, don't even consider it to be
readonly if it does a volatile load from an AllocaInst either (it
is debatable as to whether readonly would be correct or not in this
case; play safe for the moment).  This fixes PR8279.

Added:
    llvm/trunk/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll
Modified:
    llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp

Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=117783&r1=117782&r2=117783&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Sat Oct 30 07:59:44 2010
@@ -188,12 +188,12 @@
             continue;
           }
       } else if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
-        // Ignore loads from local memory.
-        if (PointsToLocalMemory(LI->getPointerOperand()))
+        // Ignore non-volatile loads from local memory.
+        if (!LI->isVolatile() && PointsToLocalMemory(LI->getPointerOperand()))
           continue;
       } else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
-        // Ignore stores to local memory.
-        if (PointsToLocalMemory(SI->getPointerOperand()))
+        // Ignore non-volatile stores to local memory.
+        if (!SI->isVolatile() && PointsToLocalMemory(SI->getPointerOperand()))
           continue;
       }
 

Added: llvm/trunk/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll?rev=117783&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll (added)
+++ llvm/trunk/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll Sat Oct 30 07:59:44 2010
@@ -0,0 +1,10 @@
+; RUN: opt < %s -functionattrs -S | FileCheck %s
+; PR8279
+
+ at g = constant i32 1
+
+define void @foo() {
+; CHECK: void @foo() {
+  %tmp = volatile load i32* @g
+  ret void
+}





More information about the llvm-commits mailing list