If a function does a volatile load from a global constant, do not
[oota-llvm.git] / lib / Transforms / IPO / FunctionAttrs.cpp
index d4bce9e48dbe23ea33c38c8d4ecd7772e17d98c8..39f48145af1d9ab7fc69b59f91067840711fc834 100644 (file)
@@ -188,12 +188,12 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
             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;
       }