[llvm] [NFC] Use references to avoid copying (PR #110462)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 01:00:00 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tablegen

Author: Pratyay Pande (pratyay-p)

<details>
<summary>Changes</summary>

Modifying some uses of `auto` to `auto&` to avoid unnecessary copying.

---
Full diff: https://github.com/llvm/llvm-project/pull/110462.diff


1 Files Affected:

- (modified) llvm/utils/TableGen/IntrinsicEmitter.cpp (+4-4) 


``````````diff
diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp
index efa067e60de439..469d0bbf3ae4b6 100644
--- a/llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ b/llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -229,8 +229,8 @@ struct IntrinsicTargetInfo {
 };
 static constexpr IntrinsicTargetInfo TargetInfos[] = {
 )";
-  for (const auto [Name, Offset, Count] : Ints.Targets)
-    OS << formatv("  {{\"{}\", {}, {}},\n", Name, Offset, Count);
+  for (const auto &Target : Ints.Targets)
+    OS << formatv("  {{\"{}\", {}, {}},\n", Target.Name, Target.Offset, Target.Count);
   OS << R"(};
 #endif
 
@@ -255,7 +255,7 @@ void IntrinsicEmitter::EmitIntrinsicToOverloadTable(
 static constexpr uint8_t OTable[] = {
   0
   )";
-  for (auto [I, Int] : enumerate(Ints)) {
+  for (const auto& [I, Int] : enumerate(Ints)) {
     // Add one to the index so we emit a null bit for the invalid #0 intrinsic.
     size_t Idx = I + 1;
 
@@ -345,7 +345,7 @@ static constexpr {} IIT_Table[] = {{
                 FixedEncodingTypeName);
 
   unsigned MaxOffset = 0;
-  for (auto [Idx, FixedEncoding, Int] : enumerate(FixedEncodings, Ints)) {
+  for (const auto& [Idx, FixedEncoding, Int] : enumerate(FixedEncodings, Ints)) {
     if ((Idx & 7) == 7)
       OS << "\n  ";
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/110462


More information about the llvm-commits mailing list