[llvm] [TableGen] Avoid repeated hash lookups (NFC) (PR #120873)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 21 22:19:00 PST 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/120873

None

>From 15f2faf24426e0910bcec7f971f9cb21c8011519 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 21 Dec 2024 10:19:53 -0800
Subject: [PATCH] [TableGen] Avoid repeated hash lookups (NFC)

---
 llvm/utils/TableGen/CallingConvEmitter.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/llvm/utils/TableGen/CallingConvEmitter.cpp b/llvm/utils/TableGen/CallingConvEmitter.cpp
index 444b10719cb034..b315aa7d86fe91 100644
--- a/llvm/utils/TableGen/CallingConvEmitter.cpp
+++ b/llvm/utils/TableGen/CallingConvEmitter.cpp
@@ -378,10 +378,11 @@ void CallingConvEmitter::emitArgRegisterLists(raw_ostream &O) {
         const std::string &InnerCCName = InnerEntry.first;
         std::set<std::string> &InnerRegisters = InnerEntry.second;
 
-        if (InnerRegisters.find(CCName) != InnerRegisters.end()) {
-          AssignedRegsMap[InnerCCName].insert(AssignedRegsMap[CCName].begin(),
-                                              AssignedRegsMap[CCName].end());
-          InnerRegisters.erase(CCName);
+        auto It = InnerRegisters.find(CCName);
+        if (It != InnerRegisters.end()) {
+          const auto &Src = AssignedRegsMap[CCName];
+          AssignedRegsMap[InnerCCName].insert(Src.begin(), Src.end());
+          InnerRegisters.erase(It);
         }
       }
 



More information about the llvm-commits mailing list