[PATCH] D17400: [CaptureTracking] Support atomicrmw and cmpxchg

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 18 11:28:00 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL261245: [CaptureTracking] Support atomicrmw and cmpxchg (authored by reames).

Changed prior to commit:
  http://reviews.llvm.org/D17400?vs=48355&id=48375#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17400

Files:
  llvm/trunk/lib/Analysis/CaptureTracking.cpp
  llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll

Index: llvm/trunk/lib/Analysis/CaptureTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/CaptureTracking.cpp
+++ llvm/trunk/lib/Analysis/CaptureTracking.cpp
@@ -271,6 +271,17 @@
           return;
       // Storing to the pointee does not cause the pointer to be captured.
       break;
+    case Instruction::AtomicRMW:
+    case Instruction::AtomicCmpXchg:
+      // atomicrmw and cmpxchg conceptually include both a load and store from
+      // the same location.  As with a store, the location being accessed is
+      // not captured, but the value being stored is.  (For cmpxchg, we
+      // probably don't need to capture the original comparison value, but for
+      // the moment, let's be conservative.)
+      if (V != I->getOperand(0))
+        if (Tracker->captured(U))
+          return;
+      break;
     case Instruction::BitCast:
     case Instruction::GetElementPtr:
     case Instruction::PHI:
Index: llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll
===================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll
+++ llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll
@@ -193,3 +193,14 @@
   ret void
 }
 
+; CHECK: define void @test_cmpxchg(i32* nocapture %p)
+define void @test_cmpxchg(i32* %p) {
+  cmpxchg i32* %p, i32 0, i32 1 acquire monotonic
+  ret void
+}
+
+; CHECK: define void @test_atomicrmw(i32* nocapture %p)
+define void @test_atomicrmw(i32* %p) {
+  atomicrmw add i32* %p, i32 1 seq_cst
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17400.48375.patch
Type: text/x-patch
Size: 1570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160218/4cc26682/attachment.bin>


More information about the llvm-commits mailing list