[PATCH] D114990: Avoid by-value copies of referenced objects

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 2 12:46:17 PST 2021


urnathan created this revision.
Herald added a subscriber: hiraditya.
urnathan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

These were detected by the new -Wauto-by-value-copy (D114989 <https://reviews.llvm.org/D114989>) warning, these by-value
constant copies need only be references.


https://reviews.llvm.org/D114990

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
  llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp


Index: llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
===================================================================
--- llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
+++ llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
@@ -349,7 +349,7 @@
           // Add the registers this load reads to those we check for clobbers.
           for (unsigned i = InstrDesc.getNumDefs(),
                         e = InstrDesc.getNumOperands(); i != e; i++) {
-            const auto Operand = NodeInstr.Instruction.getOperand(i);
+            const auto &Operand = NodeInstr.Instruction.getOperand(i);
             if (Operand.isReg())
               CurRegisterNumbers.insert(Operand.getReg());
           }
Index: llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
===================================================================
--- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
+++ llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
@@ -531,7 +531,7 @@
             << LR->Locations.size() << "\n";
         Log << "    " << NumDwarfInlineInfos << " DWARF frames:\n";
         for (size_t Idx = 0; Idx < NumDwarfInlineInfos; ++Idx) {
-          const auto dii = DwarfInlineInfos.getFrame(Idx);
+          const auto &dii = DwarfInlineInfos.getFrame(Idx);
           Log << "    [" << Idx << "]: " << dii.FunctionName << " @ "
               << dii.FileName << ':' << dii.Line << '\n';
         }
@@ -551,7 +551,7 @@
             ++Idx) {
         const auto &gii = LR->Locations[Idx];
         if (Idx < NumDwarfInlineInfos) {
-          const auto dii = DwarfInlineInfos.getFrame(Idx);
+          const auto &dii = DwarfInlineInfos.getFrame(Idx);
           gsymFilename = LR->getSourceFile(Idx);
           // Verify function name
           if (dii.FunctionName.find(gii.Name.str()) != 0)
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -301,7 +301,7 @@
       if (IgnoreNodeResults(N->getOperand(i).getNode()))
         continue;
 
-      const auto Op = N->getOperand(i);
+      const auto &Op = N->getOperand(i);
       LLVM_DEBUG(dbgs() << "Analyzing operand: "; Op.dump(&DAG));
       EVT OpVT = Op.getValueType();
       switch (getTypeAction(OpVT)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114990.391434.patch
Type: text/x-patch
Size: 2330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211202/44df2722/attachment.bin>


More information about the llvm-commits mailing list