[llvm] [Transforms] Avoid repeated hash lookups (NFC) (PR #110400)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 28 19:04:31 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/110400
None
>From 9ebf43dd1576b70b34e83667e596bb096204b544 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 28 Sep 2024 13:16:39 -0700
Subject: [PATCH] [Transforms] Avoid repeated hash lookups (NFC)
---
llvm/include/llvm/Transforms/Utils/SampleProfileInference.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h b/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
index b4ea1ad840f9d9..7231e45fe8eb72 100644
--- a/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
+++ b/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
@@ -247,9 +247,10 @@ FlowFunction SampleProfileInference<BT>::createFlowFunction(
// Create FlowBlocks
for (const auto *BB : BasicBlocks) {
FlowBlock Block;
- if (SampleBlockWeights.contains(BB)) {
+ auto It = SampleBlockWeights.find(BB);
+ if (It != SampleBlockWeights.end()) {
Block.HasUnknownWeight = false;
- Block.Weight = SampleBlockWeights[BB];
+ Block.Weight = It->second;
} else {
Block.HasUnknownWeight = true;
Block.Weight = 0;
More information about the llvm-commits
mailing list