[PATCH] D146694: Fix auto usage to avoid copies

Akshay Khadse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 23:11:39 PDT 2023


akshaykhadse created this revision.
Herald added subscribers: ecnelises, hiraditya.
Herald added a project: All.
akshaykhadse requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146694

Files:
  llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/utils/TableGen/InstrInfoEmitter.cpp


Index: llvm/utils/TableGen/InstrInfoEmitter.cpp
===================================================================
--- llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -117,7 +117,7 @@
 static void PrintDefList(const std::vector<Record *> &Uses, unsigned Num,
                          raw_ostream &OS) {
   OS << "static const MCPhysReg ImplicitList" << Num << "[] = { ";
-  for (auto [Idx, U] : enumerate(Uses))
+  for (auto const& [Idx, U] : enumerate(Uses))
     OS << (Idx ? ", " : "") << getQualifiedName(U);
   OS << " };\n";
 }
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -20963,7 +20963,7 @@
         SDValue RHS = SVN->getOperand(1);
         SmallVector<int, 16> Mask(SVN->getMask());
         bool Merged = true;
-        for (auto I : enumerate(Ops)) {
+        for (auto const& I : enumerate(Ops)) {
           SDValue &Op = I.value();
           if (Op) {
             SmallVector<int, 16> NewMask;
@@ -22451,7 +22451,7 @@
   // Recreate the BUILD_VECTOR, with elements now being Factor times smaller.
   SmallVector<SDValue, 16> NewOps;
   NewOps.reserve(NewIntVT.getVectorNumElements());
-  for (auto I : enumerate(N->ops())) {
+  for (auto const& I : enumerate(N->ops())) {
     SDValue Op = I.value();
     assert(!Op.isUndef() && "FIXME: after allowing UNDEF's, handle them here.");
     unsigned SrcOpIdx = I.index();
Index: llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
===================================================================
--- llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -854,15 +854,15 @@
     }
 
     // Insert new location defs.
-    for (auto Pair : BBInsertBeforeMap) {
+    for (auto& Pair : BBInsertBeforeMap) {
       InsertMap &Map = Pair.second;
-      for (auto Pair : Map) {
+      for (auto& Pair : Map) {
         Instruction *InsertBefore = Pair.first;
         assert(InsertBefore && "should never be null");
         auto FragMemLocs = Pair.second;
         auto &Ctx = Fn.getContext();
 
-        for (auto FragMemLoc : FragMemLocs) {
+        for (auto& FragMemLoc : FragMemLocs) {
           DIExpression *Expr = DIExpression::get(Ctx, std::nullopt);
           Expr = *DIExpression::createFragmentExpression(
               Expr, FragMemLoc.OffsetInBits, FragMemLoc.SizeInBits);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146694.507621.patch
Type: text/x-patch
Size: 2520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230323/341c2b4c/attachment.bin>


More information about the llvm-commits mailing list