diff options
author | Justin Lebar <jlebar@google.com> | 2016-07-13 22:35:19 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-07-13 22:35:19 +0000 |
commit | dede81ea72a786cdbd88fe8e3ff74865a03d464c (patch) | |
tree | 516380d0324b08fc57bb87650ad908876af2a478 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | dfd358f597cea078061476991bfeea06b9c3a7d4 (diff) | |
download | bcm5719-llvm-dede81ea72a786cdbd88fe8e3ff74865a03d464c.tar.gz bcm5719-llvm-dede81ea72a786cdbd88fe8e3ff74865a03d464c.zip |
[MI] Clean up some loops over MachineInstr::memoperands(). NFC
Use range-based for loops and llvm::any_of instead of explicit
iterators.
llvm-svn: 275332
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 0b107c0abe5..112e0ce3c92 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -1556,12 +1556,10 @@ bool MachineInstr::hasOrderedMemoryRef() const { if (memoperands_empty()) return true; - // Check the memory reference information for ordered references. - for (mmo_iterator I = memoperands_begin(), E = memoperands_end(); I != E; ++I) - if (!(*I)->isUnordered()) - return true; - - return false; + // Check if any of our memory operands are ordered. + return any_of(memoperands(), [](const MachineMemOperand *MMO) { + return !MMO->isUnordered(); + }); } /// isInvariantLoad - Return true if this instruction is loading from a @@ -1581,22 +1579,21 @@ bool MachineInstr::isInvariantLoad(AliasAnalysis *AA) const { const MachineFrameInfo *MFI = getParent()->getParent()->getFrameInfo(); - for (mmo_iterator I = memoperands_begin(), - E = memoperands_end(); I != E; ++I) { - if ((*I)->isVolatile()) return false; - if ((*I)->isStore()) return false; - if ((*I)->isInvariant()) continue; + for (MachineMemOperand *MMO : memoperands()) { + if (MMO->isVolatile()) return false; + if (MMO->isStore()) return false; + if (MMO->isInvariant()) continue; // A load from a constant PseudoSourceValue is invariant. - if (const PseudoSourceValue *PSV = (*I)->getPseudoValue()) + if (const PseudoSourceValue *PSV = MMO->getPseudoValue()) if (PSV->isConstant(MFI)) continue; - if (const Value *V = (*I)->getValue()) { + if (const Value *V = MMO->getValue()) { // If we have an AliasAnalysis, ask it whether the memory is constant. if (AA && AA->pointsToConstantMemory( - MemoryLocation(V, (*I)->getSize(), (*I)->getAAInfo()))) + MemoryLocation(V, MMO->getSize(), MMO->getAAInfo()))) continue; } |