[llvm] [ExecutionEngine] Avoid repeated hash lookups (NFC) (PR #111937)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 20:40:50 PDT 2024


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

None

>From 201304809ba9a232e95254ae06125b85d4c2e612 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 10 Oct 2024 08:29:46 -0700
Subject: [PATCH] [ExecutionEngine] Avoid repeated hash lookups (NFC)

---
 llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
index c11577b03fd7e9..f0cf551ffae5ab 100644
--- a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
@@ -136,12 +136,10 @@ Error EHFrameEdgeFixer::processBlock(ParseContext &PC, Block &B) {
       // Otherwise check if we previously had exactly one relocation at this
       // offset. If so, we now have a second one and move it from the TargetMap
       // into the Multiple set.
-      auto It = BlockEdges.TargetMap.find(E.getOffset());
-      if (It != BlockEdges.TargetMap.end()) {
+      auto [It, Inserted] = BlockEdges.TargetMap.try_emplace(E.getOffset(), E);
+      if (!Inserted) {
         BlockEdges.TargetMap.erase(It);
         BlockEdges.Multiple.insert(E.getOffset());
-      } else {
-        BlockEdges.TargetMap[E.getOffset()] = EdgeTarget(E);
       }
     }
 



More information about the llvm-commits mailing list