[llvm] 9243a58 - X86LoadValueInjectionLoadHardening.cpp - use const-reference in for-range loops to avoid unnecessary copies. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon May 10 06:05:45 PDT 2021


Author: Simon Pilgrim
Date: 2021-05-10T14:00:36+01:00
New Revision: 9243a584d3863d8baae59f6ab0d3c46c7d7b857c

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

LOG: X86LoadValueInjectionLoadHardening.cpp - use const-reference in for-range loops to avoid unnecessary copies. NFCI.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp b/llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp
index 810fee052b5a..165533eba346 100644
--- a/llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp
+++ b/llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp
@@ -372,9 +372,9 @@ X86LoadValueInjectionLoadHardeningPass::getGadgetGraph(
             auto Use = DFG.addr<UseNode *>(UseID);
             if (Use.Addr->getFlags() & NodeAttrs::PhiRef) { // phi node
               NodeAddr<PhiNode *> Phi = Use.Addr->getOwner(DFG);
-              for (auto I : L.getRealUses(Phi.Id)) {
+              for (const auto& I : L.getRealUses(Phi.Id)) {
                 if (DFG.getPRI().alias(RegisterRef(I.first), DefReg)) {
-                  for (auto UA : I.second)
+                  for (const auto &UA : I.second)
                     Uses.emplace(UA.first);
                 }
               }
@@ -417,7 +417,7 @@ X86LoadValueInjectionLoadHardeningPass::getGadgetGraph(
             // Check whether the use propagates to more defs.
             NodeAddr<InstrNode *> Owner{Use.Addr->getOwner(DFG)};
             rdf::NodeList AnalyzedChildDefs;
-            for (auto &ChildDef :
+            for (const auto &ChildDef :
                  Owner.Addr->members_if(DataFlowGraph::IsDef, DFG)) {
               if (!DefsVisited.insert(ChildDef.Id).second)
                 continue; // Already visited this def


        


More information about the llvm-commits mailing list