[llvm] [Passes] Avoid repeated hash lookups (NFC) (PR #135542)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 13 04:48:57 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/135542
None
>From f8102445f64aa6f5432f3daa4a2a57653a87437c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 13 Apr 2025 04:39:44 -0700
Subject: [PATCH] [Passes] Avoid repeated hash lookups (NFC)
---
llvm/lib/Passes/StandardInstrumentations.cpp | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 4c59278eaaa01..dc1dd5d9c7f4c 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -2001,14 +2001,12 @@ DotCfgDiff::DotCfgDiff(StringRef Title, const FuncDataT<DCData> &Before,
for (auto &A : After.getData()) {
StringRef Label = A.getKey();
const BlockDataT<DCData> &BD = A.getValue();
- unsigned C = NodePosition.count(Label);
- if (C == 0)
+ auto It = NodePosition.find(Label);
+ if (It == NodePosition.end())
// This only exists in the after IR. Create the node.
createNode(Label, BD, AfterColour);
- else {
- assert(C == 1 && "Unexpected multiple nodes.");
- Nodes[NodePosition[Label]].setCommon(BD);
- }
+ else
+ Nodes[It->second].setCommon(BD);
// Add in the edges between the nodes (as common or only in after).
for (StringMap<std::string>::const_iterator Sink = BD.getData().begin(),
E = BD.getData().end();
More information about the llvm-commits
mailing list