[llvm-commits] [llvm] r137702 - in /llvm/trunk: lib/Transforms/IPO/FunctionAttrs.cpp test/Transforms/FunctionAttrs/atomic.ll

Eli Friedman eli.friedman at gmail.com
Mon Aug 15 18:28:22 PDT 2011


Author: efriedma
Date: Mon Aug 15 20:28:22 2011
New Revision: 137702

URL: http://llvm.org/viewvc/llvm-project?rev=137702&view=rev
Log:
Revert a bit of r137667; the logic in question can safely handle atomic load/store.


Added:
    llvm/trunk/test/Transforms/FunctionAttrs/atomic.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=137702&r1=137701&r2=137702&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Mon Aug 15 20:28:22 2011
@@ -163,15 +163,15 @@
           ReadsMemory = true;
         continue;
       } else if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
-        // Ignore non-volatile loads from local memory.
-        if (LI->isUnordered()) {
+        // Ignore non-volatile loads from local memory. (Atomic is okay here.)
+        if (!LI->isVolatile()) {
           AliasAnalysis::Location Loc = AA->getLocation(LI);
           if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
             continue;
         }
       } else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
-        // Ignore non-volatile stores to local memory.
-        if (SI->isUnordered()) {
+        // Ignore non-volatile stores to local memory. (Atomic is okay here.)
+        if (!SI->isVolatile()) {
           AliasAnalysis::Location Loc = AA->getLocation(SI);
           if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
             continue;

Added: llvm/trunk/test/Transforms/FunctionAttrs/atomic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/atomic.ll?rev=137702&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/atomic.ll (added)
+++ llvm/trunk/test/Transforms/FunctionAttrs/atomic.ll Mon Aug 15 20:28:22 2011
@@ -0,0 +1,21 @@
+; RUN: opt -basicaa -functionattrs -S < %s | FileCheck %s
+
+; Atomic load/store to local doesn't affect whether a function is
+; readnone/readonly.
+define i32 @test1(i32 %x) uwtable ssp {
+; CHECK: define i32 @test1(i32 %x) uwtable readnone ssp {
+entry:
+  %x.addr = alloca i32, align 4
+  store atomic i32 %x, i32* %x.addr seq_cst, align 4
+  %r = load atomic i32* %x.addr seq_cst, align 4
+  ret i32 %r
+}
+
+; A function with an Acquire load is not readonly.
+define i32 @test2(i32* %x) uwtable ssp {
+; CHECK: define i32 @test2(i32 %x) uwtable ssp {
+entry:
+  %r = load atomic i32* %x seq_cst, align 4
+  ret i32 %r
+}
+





More information about the llvm-commits mailing list