[PATCH] D54062: [COFF, ARM64] Implement InterlockedCompareExchange*_* builtins
    Eli Friedman via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Mon Nov  5 15:57:01 PST 2018
    
    
  
efriedma added inline comments.
================
Comment at: lib/CodeGen/CGBuiltin.cpp:233
 
+static Value *EmitAtomicCmpXchgValue(CodeGenFunction &CGF, const CallExpr *E,
+    AtomicOrdering SuccessOrdering = AtomicOrdering::SequentiallyConsistent) {
----------------
Please rename this function; it's very confusing to have both EmitAtomicCmpXchgValue and MakeAtomicCmpXchgValue which do almost the same thing, but expect the arguments in the opposite order.
================
Comment at: lib/CodeGen/CGBuiltin.cpp:259-262
+  // For Release ordering, the failure ordering should be Monotonic.
+  auto FailureOrdering = SuccessOrdering == AtomicOrdering::Release ?
+                         AtomicOrdering::Monotonic :
+                         SuccessOrdering;
----------------
rnk wrote:
> I don't know enough about the memory model to really say if this is right, so I'll pass the buck to @efriedma.
This is equivalent to what you'd get for the C++ `a.compare_exchange_strong(x, y, memory_order::release)`, which should match general intuition about "release" operations.  (There are only three possible failure orderings: seq_cst, acquire, and monotonic.)
Repository:
  rC Clang
https://reviews.llvm.org/D54062
    
    
More information about the cfe-commits
mailing list