[llvm] d1d5f00 - [Passes] Avoid repeated hash lookups (NFC) (#135542)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 13 05:46:32 PDT 2025
Author: Kazu Hirata
Date: 2025-04-13T05:46:29-07:00
New Revision: d1d5f00a8eb43aaa22274c06b58d567f19e284fe
URL: https://github.com/llvm/llvm-project/commit/d1d5f00a8eb43aaa22274c06b58d567f19e284fe
DIFF: https://github.com/llvm/llvm-project/commit/d1d5f00a8eb43aaa22274c06b58d567f19e284fe.diff
LOG: [Passes] Avoid repeated hash lookups (NFC) (#135542)
Added:
Modified:
llvm/lib/Passes/StandardInstrumentations.cpp
Removed:
################################################################################
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