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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mc

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) llvm/lib/MC/ELFObjectWriter.cpp (+2-1) 


``````````diff
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index bf911e29a19c449..5f586fe19a5bb4a 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;

``````````

</details>


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


More information about the llvm-commits mailing list