[llvm] [ExecutionEngine] Avoid repeated hash lookups (NFC) (PR #131423)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 14 19:37:14 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/131423
None
>From f8afcfc567fe79f5a5d92cde863f020376a23ccc Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 14 Mar 2025 07:27:27 -0700
Subject: [PATCH] [ExecutionEngine] Avoid repeated hash lookups (NFC)
---
.../ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp
index 69e95654666e1..16ec136480cba 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp
@@ -86,17 +86,17 @@ uint64_t RuntimeDyldCOFF::getDLLImportOffset(unsigned SectionID, StubMap &Stubs,
"Not a DLLImport symbol?");
RelocationValueRef Reloc;
Reloc.SymbolName = Name.data();
- auto I = Stubs.find(Reloc);
- if (I != Stubs.end()) {
- LLVM_DEBUG(dbgs() << format("{0:x8}", I->second) << "\n");
- return I->second;
+ auto [It, Inserted] = Stubs.try_emplace(Reloc);
+ if (!Inserted) {
+ LLVM_DEBUG(dbgs() << format("{0:x8}", It->second) << "\n");
+ return It->second;
}
assert(SectionID < Sections.size() && "SectionID out of range");
auto &Sec = Sections[SectionID];
auto EntryOffset = alignTo(Sec.getStubOffset(), PointerSize);
Sec.advanceStubOffset(EntryOffset + PointerSize - Sec.getStubOffset());
- Stubs[Reloc] = EntryOffset;
+ It->second = EntryOffset;
RelocationEntry RE(SectionID, EntryOffset, PointerReloc, 0, false,
Log2_64(PointerSize));
More information about the llvm-commits
mailing list