]> granicus.if.org Git - llvm/commitdiff
Be conservative about unordered accesses for the moment
authorPhilip Reames <listmail@philipreames.com>
Mon, 11 Feb 2019 23:34:33 +0000 (23:34 +0000)
committerPhilip Reames <listmail@philipreames.com>
Mon, 11 Feb 2019 23:34:33 +0000 (23:34 +0000)
Background: As described in https://reviews.llvm.org/D57601, I'm working towards separating volatile and atomic in the MMO uses for atomic instructions.

In https://reviews.llvm.org/D57593, I fixed a bug where isUnordered was returning the wrong result, but didn't account for the fact I was getting slightly ahead of myself. While both uses of isUnordered are correct (as far as I can tell), we don't have tests to demonstrate this and being aggressive gets in the way of having the removal of volatile truly be non-functional. Once D57601 lands, I will return to these call sites, revert this patch, and add the appropriate tests to show the expected behaviour.

Differential Revision: https://reviews.llvm.org/D57802

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353766 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/ImplicitNullChecks.cpp
lib/CodeGen/MachineInstr.cpp

index 681103141517c8c973ea513796a044f8a420aa74..75f4eef5dc1c3091e4b41224807f949a598ef345 100644 (file)
@@ -235,8 +235,11 @@ bool ImplicitNullChecks::canHandle(const MachineInstr *MI) {
   assert(!llvm::any_of(MI->operands(), IsRegMask) &&
          "Calls were filtered out above!");
 
-  auto IsUnordered = [](MachineMemOperand *MMO) { return MMO->isUnordered(); };
-  return llvm::all_of(MI->memoperands(), IsUnordered);
+  // TODO: This should be isUnordered (see D57601) once test cases are written
+  // demonstrating that.
+  auto IsSimple = [](MachineMemOperand *MMO) {
+    return !MMO->isVolatile() && !MMO->isAtomic(); };
+  return llvm::all_of(MI->memoperands(), IsSimple);
 }
 
 ImplicitNullChecks::DependenceResult
index 4c80b7bfb0b3c914bbe10ad451198da24c11912d..0b8e9caa09b7db00094ffa473d6552db097e3a59 100644 (file)
@@ -1291,8 +1291,10 @@ bool MachineInstr::hasOrderedMemoryRef() const {
     return true;
 
   // Check if any of our memory operands are ordered.
+  // TODO: This should probably be be isUnordered (see D57601), but the callers
+  // need audited and test cases written to be sure.
   return llvm::any_of(memoperands(), [](const MachineMemOperand *MMO) {
-    return !MMO->isUnordered();
+    return MMO->isVolatile() || MMO->isAtomic();
   });
 }