[llvm] 2acec3e - [ExecutionEngine] Avoid repeated hash lookups (NFC) (#111937)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 08:59:23 PDT 2024


Author: Kazu Hirata
Date: 2024-10-11T08:59:19-07:00
New Revision: 2acec3ee21e846ce48c643b431b804a893d18cde

URL: https://github.com/llvm/llvm-project/commit/2acec3ee21e846ce48c643b431b804a893d18cde
DIFF: https://github.com/llvm/llvm-project/commit/2acec3ee21e846ce48c643b431b804a893d18cde.diff

LOG: [ExecutionEngine] Avoid repeated hash lookups (NFC) (#111937)

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp

Removed: 
    


################################################################################
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