[llvm] [ExecutionEngine] Avoid repeated hash lookups (NFC) (PR #127577)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 22:55:52 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/127577
None
>From aef8ab367ba62af4acbd513a0315815c135dc970 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 17 Feb 2025 02:07:19 -0800
Subject: [PATCH] [ExecutionEngine] Avoid repeated hash lookups (NFC)
---
llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
index 7f0a45941cf9b..9ac8c5ef66de6 100644
--- a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
@@ -469,11 +469,12 @@ void ELFNixPlatform::pushInitializersLoop(
Worklist.pop_back();
// If we've already visited this JITDylib on this iteration then continue.
- if (JDDepMap.count(DepJD))
+ auto [It, Inserted] = JDDepMap.try_emplace(DepJD);
+ if (!Inserted)
continue;
// Add dep info.
- auto &DM = JDDepMap[DepJD];
+ auto &DM = It->second;
DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
for (auto &KV : O) {
if (KV.first == DepJD)
More information about the llvm-commits
mailing list