[llvm] [BOLT] Avoid repeated set lookups (NFC) (PR #112157)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 13 21:03:47 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/112157
None
>From d2f890fd26cf8c772654251c8527d1a36fc9e2dc Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 13 Oct 2024 07:40:59 -0700
Subject: [PATCH] [BOLT] Avoid repeated set lookups (NFC)
---
bolt/lib/Passes/Instrumentation.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/bolt/lib/Passes/Instrumentation.cpp b/bolt/lib/Passes/Instrumentation.cpp
index ebb3925749b4d2..76766b05b91760 100644
--- a/bolt/lib/Passes/Instrumentation.cpp
+++ b/bolt/lib/Passes/Instrumentation.cpp
@@ -109,9 +109,8 @@ static bool hasAArch64ExclusiveMemop(
BinaryBasicBlock *BB = BBQueue.front().first;
bool IsLoad = BBQueue.front().second;
BBQueue.pop();
- if (Visited.find(BB) != Visited.end())
+ if (!Visited.insert(BB).second)
continue;
- Visited.insert(BB);
for (const MCInst &Inst : *BB) {
// Two loads one after another - skip whole function
@@ -126,8 +125,7 @@ static bool hasAArch64ExclusiveMemop(
if (BC.MIB->isAArch64ExclusiveLoad(Inst))
IsLoad = true;
- if (IsLoad && BBToSkip.find(BB) == BBToSkip.end()) {
- BBToSkip.insert(BB);
+ if (IsLoad && BBToSkip.insert(BB).second) {
if (opts::Verbosity >= 2) {
outs() << "BOLT-INSTRUMENTER: skip BB " << BB->getName()
<< " due to exclusive instruction in function "
More information about the llvm-commits
mailing list