[llvm] r295807 - Use const-ref in range-loop for to avoid copying pairs of std::string

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 22:34:04 PST 2017


Author: silvas
Date: Wed Feb 22 00:34:04 2017
New Revision: 295807

URL: http://llvm.org/viewvc/llvm-project?rev=295807&view=rev
Log:
Use const-ref in range-loop for to avoid copying pairs of std::string

No reason to create temporaries.

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

Patch by sergio.martins!

Modified:
    llvm/trunk/lib/IR/Attributes.cpp
    llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=295807&r1=295806&r2=295807&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Wed Feb 22 00:34:04 2017
@@ -1380,7 +1380,7 @@ bool AttrBuilder::overlaps(const AttrBui
     return true;
 
   // Then check if any target dependent ones do.
-  for (auto I : td_attrs())
+  for (const auto &I : td_attrs())
     if (B.contains(I.first))
       return true;
 

Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=295807&r1=295806&r2=295807&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Wed Feb 22 00:34:04 2017
@@ -364,7 +364,7 @@ Function *CodeExtractor::constructFuncti
   //           attribute can not be inherited.
   AttributeSet OldFnAttrs = oldFunction->getAttributes().getFnAttributes();
   AttrBuilder AB(OldFnAttrs, AttributeSet::FunctionIndex);
-  for (auto Attr : AB.td_attrs())
+  for (const auto &Attr : AB.td_attrs())
     newFunction->addFnAttr(Attr.first, Attr.second);
 
   newFunction->getBasicBlockList().push_back(newRootNode);




More information about the llvm-commits mailing list