diff --git a/llvm/lib/CodeGen/ImplicitNullChecks.cpp b/llvm/lib/CodeGen/ImplicitNullChecks.cpp index 681103141517..75f4eef5dc1c 100644 --- a/llvm/lib/CodeGen/ImplicitNullChecks.cpp +++ b/llvm/lib/CodeGen/ImplicitNullChecks.cpp @@ -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 diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 4c80b7bfb0b3..0b8e9caa09b7 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -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(); }); }