[llvm] decc194 - MachineCSE.cpp - use auto const& iterators in for-range loops to avoid copies. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 26 06:32:37 PDT 2020


Author: Simon Pilgrim
Date: 2020-09-26T14:31:57+01:00
New Revision: decc1944f38f4205bf53829bf91e3c98ea6fc7ac

URL: https://github.com/llvm/llvm-project/commit/decc1944f38f4205bf53829bf91e3c98ea6fc7ac
DIFF: https://github.com/llvm/llvm-project/commit/decc1944f38f4205bf53829bf91e3c98ea6fc7ac.diff

LOG: MachineCSE.cpp - use auto const& iterators in for-range loops to avoid copies. NFCI.

Added: 
    

Modified: 
    llvm/lib/CodeGen/MachineCSE.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp
index d3eca3ac4128..2bc56cc8ba58 100644
--- a/llvm/lib/CodeGen/MachineCSE.cpp
+++ b/llvm/lib/CodeGen/MachineCSE.cpp
@@ -640,7 +640,7 @@ bool MachineCSE::ProcessBlockCSE(MachineBasicBlock *MBB) {
 
     // Actually perform the elimination.
     if (DoCSE) {
-      for (std::pair<unsigned, unsigned> &CSEPair : CSEPairs) {
+      for (const std::pair<unsigned, unsigned> &CSEPair : CSEPairs) {
         unsigned OldReg = CSEPair.first;
         unsigned NewReg = CSEPair.second;
         // OldReg may have been unused but is used now, clear the Dead flag
@@ -656,7 +656,7 @@ bool MachineCSE::ProcessBlockCSE(MachineBasicBlock *MBB) {
       // we should make sure it is not dead at CSMI.
       for (unsigned ImplicitDefToUpdate : ImplicitDefsToUpdate)
         CSMI->getOperand(ImplicitDefToUpdate).setIsDead(false);
-      for (auto PhysDef : PhysDefs)
+      for (const auto &PhysDef : PhysDefs)
         if (!MI->getOperand(PhysDef.first).isDead())
           CSMI->getOperand(PhysDef.first).setIsDead(false);
 


        


More information about the llvm-commits mailing list