[llvm] [MC] Avoid repeated hash lookups (NFC) (PR #123502)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 18 22:21:03 PST 2025


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

None

>From 4fb69a89869aad86b0778e5aa9940e8ea4a051f0 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 18 Jan 2025 10:07:28 -0800
Subject: [PATCH] [MC] Avoid repeated hash lookups (NFC)

---
 llvm/lib/MC/ELFObjectWriter.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index bf911e29a19c44..5f586fe19a5bb4 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1219,7 +1219,8 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
       continue;
     }
 
-    if (Renames.count(&Symbol) && Renames[&Symbol] != Alias) {
+    if (auto It = Renames.find(&Symbol);
+        It != Renames.end() && It->second != Alias) {
       Asm.getContext().reportError(S.Loc, Twine("multiple versions for ") +
                                               Symbol.getName());
       continue;



More information about the llvm-commits mailing list