[PATCH] D57593: Fix a bug in the definition of isUnordered on MachineMemOperand

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 1 09:19:26 PST 2019


reames created this revision.
reames added reviewers: jlebar, kzhuravl, stoklund.
Herald added subscribers: jfb, bollu, mcrosier.

Background: At the moment, we record the AtomicOrdering of an access in the MMO, but also mark any atomic access as volatile in SelectionDAG.  GlobalIsel keeps the two separate, but currently doesn't know how to lower an atomic G_LOAD at all.  This is the first patch in what is likely to be a long slow series with the intention of separating volatility and atomicity/ordering in SelectionDAG, and eventually, the x86 backend so that we can improve code quality for unordered atomics.

The definition used for unordered was only checking volatility, not atomicity.  As noted above, all atomic MMOs are currently also volatile, so this is a latent bug only.  Copy the definition used in IR, after auditing the two (2) uses of the function to be sure the desired semantics are the same.


https://reviews.llvm.org/D57593

Files:
  include/llvm/CodeGen/MachineMemOperand.h


Index: include/llvm/CodeGen/MachineMemOperand.h
===================================================================
--- include/llvm/CodeGen/MachineMemOperand.h
+++ include/llvm/CodeGen/MachineMemOperand.h
@@ -266,13 +266,13 @@
   bool isAtomic() const { return getOrdering() != AtomicOrdering::NotAtomic; }
 
   /// Returns true if this memory operation doesn't have any ordering
-  /// constraints other than normal aliasing. Volatile and atomic memory
-  /// operations can't be reordered.
-  ///
-  /// Currently, we don't model the difference between volatile and atomic
-  /// operations. They should retain their ordering relative to all memory
-  /// operations.
-  bool isUnordered() const { return !isVolatile(); }
+  /// constraints other than normal aliasing. Volatile and (ordered) atomic
+  /// memory operations can't be reordered. 
+  bool isUnordered() const {
+    return (getOrdering() == AtomicOrdering::NotAtomic ||
+            getOrdering() == AtomicOrdering::Unordered) &&
+           !isVolatile();
+  }
 
   /// Update this MachineMemOperand to reflect the alignment of MMO, if it has a
   /// greater alignment. This must only be used when the new alignment applies


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57593.184761.patch
Type: text/x-patch
Size: 1193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190201/16f9ea3e/attachment.bin>


More information about the llvm-commits mailing list