[llvm] [BOLT] Avoid repeated map lookups (NFC) (PR #112118)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 12 21:13:35 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/112118.diff
1 Files Affected:
- (modified) bolt/lib/Core/BinaryFunction.cpp (+2-6)
``````````diff
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index 36c42fced93d08..ef3fba37817daa 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -3684,9 +3684,8 @@ BinaryFunction::BasicBlockListType BinaryFunction::dfs() const {
BinaryBasicBlock *BB = Stack.top();
Stack.pop();
- if (Visited.find(BB) != Visited.end())
+ if (!Visited.insert(BB).second)
continue;
- Visited.insert(BB);
DFS.push_back(BB);
for (BinaryBasicBlock *SuccBB : BB->landing_pads()) {
@@ -3879,11 +3878,8 @@ void BinaryFunction::disambiguateJumpTables(
JumpTable *JT = getJumpTable(Inst);
if (!JT)
continue;
- auto Iter = JumpTables.find(JT);
- if (Iter == JumpTables.end()) {
- JumpTables.insert(JT);
+ if (JumpTables.insert(JT).second)
continue;
- }
// This instruction is an indirect jump using a jump table, but it is
// using the same jump table of another jump. Try all our tricks to
// extract the jump table symbol and make it point to a new, duplicated JT
``````````
</details>
https://github.com/llvm/llvm-project/pull/112118
More information about the llvm-commits
mailing list