[llvm] [ExecutionEngine] Avoid repeated hash lookups (NFC) (PR #111275)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 5 19:57:06 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111275
None
>From 0c1eea87e4726fbd72ad3664ae49244fdae8125e Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 5 Oct 2024 10:30:06 -0700
Subject: [PATCH] [ExecutionEngine] Avoid repeated hash lookups (NFC)
---
.../ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index 92f37c22ae5132..25b76c7668350b 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -1610,13 +1610,10 @@ RuntimeDyldELF::processRelocationRef(
RelocationEntry RE(SectionID, Offset, RelType, Value.Addend);
if (r_type == ELF::R_MIPS_CALL16 || r_type == ELF::R_MIPS_GOT_PAGE
|| r_type == ELF::R_MIPS_GOT_DISP) {
- StringMap<uint64_t>::iterator i = GOTSymbolOffsets.find(TargetName);
- if (i != GOTSymbolOffsets.end())
- RE.SymOffset = i->second;
- else {
- RE.SymOffset = allocateGOTEntries(1);
- GOTSymbolOffsets[TargetName] = RE.SymOffset;
- }
+ auto [I, Inserted] = GOTSymbolOffsets.try_emplace(TargetName);
+ if (Inserted)
+ I->second = allocateGOTEntries(1);
+ RE.SymOffset = I->second;
if (Value.SymbolName)
addRelocationForSymbol(RE, Value.SymbolName);
else
More information about the llvm-commits
mailing list