aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/IPO/FunctionAttrs.cpp8
-rw-r--r--test/Transforms/FunctionAttrs/2010-10-30-volatile.ll10
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp
index d4bce9e48d..39f48145af 100644
--- a/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -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;
}
diff --git a/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll b/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll
new file mode 100644
index 0000000000..f21fabc493
--- /dev/null
+++ b/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll
@@ -0,0 +1,10 @@
+; RUN: opt < %s -functionattrs -S | FileCheck %s
+; PR8279
+
+@g = constant i32 1
+
+define void @foo() {
+; CHECK: void @foo() {
+ %tmp = volatile load i32* @g
+ ret void
+}