[llvm] [BOLT] Avoid repeated hash lookups (NFC) (PR #112822)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 20:26:32 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/112822.diff


1 Files Affected:

- (modified) bolt/lib/Passes/VeneerElimination.cpp (+3-3) 


``````````diff
diff --git a/bolt/lib/Passes/VeneerElimination.cpp b/bolt/lib/Passes/VeneerElimination.cpp
index 87fe625e8c3b3e..8bf0359477c658 100644
--- a/bolt/lib/Passes/VeneerElimination.cpp
+++ b/bolt/lib/Passes/VeneerElimination.cpp
@@ -73,12 +73,12 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
           continue;
 
         const MCSymbol *TargetSymbol = BC.MIB->getTargetSymbol(Instr, 0);
-        if (VeneerDestinations.find(TargetSymbol) == VeneerDestinations.end())
+        auto It = VeneerDestinations.find(TargetSymbol);
+        if (It == VeneerDestinations.end())
           continue;
 
         VeneerCallers++;
-        BC.MIB->replaceBranchTarget(Instr, VeneerDestinations[TargetSymbol],
-                                    BC.Ctx.get());
+        BC.MIB->replaceBranchTarget(Instr, It->second, BC.Ctx.get());
       }
     }
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/112822


More information about the llvm-commits mailing list