[llvm] Use `const auto&` instead of `auto` to avoid copy (PR #113053)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 19 10:04:35 PDT 2024


https://github.com/abhishek-kaushik22 created https://github.com/llvm/llvm-project/pull/113053

None

>From ab2476509e76b9bca8674d4ff5ac3c041ac1df46 Mon Sep 17 00:00:00 2001
From: abhishek-kaushik22 <abhishek.kaushik at intel.com>
Date: Sat, 19 Oct 2024 22:34:08 +0530
Subject: [PATCH] Use `const auto&` instead of `auto` to avoid copy

---
 llvm/utils/TableGen/InstrDocsEmitter.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/TableGen/InstrDocsEmitter.cpp b/llvm/utils/TableGen/InstrDocsEmitter.cpp
index 5f22fb417198bc..54ca7d8ae40da4 100644
--- a/llvm/utils/TableGen/InstrDocsEmitter.cpp
+++ b/llvm/utils/TableGen/InstrDocsEmitter.cpp
@@ -159,7 +159,7 @@ static void EmitInstrDocs(const RecordKeeper &RK, raw_ostream &OS) {
     // Operands.
     for (unsigned i = 0; i < II->Operands.size(); ++i) {
       bool IsDef = i < II->Operands.NumDefs;
-      auto Op = II->Operands[i];
+      const auto &Op = II->Operands[i];
 
       if (Op.MINumOperands > 1) {
         // This operand corresponds to multiple operands on the



More information about the llvm-commits mailing list