[llvm] ab95ed5 - [IPO] Avoid repeated hash lookups (NFC) (#107796)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 07:14:43 PDT 2024
Author: Kazu Hirata
Date: 2024-09-09T07:14:40-07:00
New Revision: ab95ed5ce0b099913eb5c9b03fef7f322c24acd2
URL: https://github.com/llvm/llvm-project/commit/ab95ed5ce0b099913eb5c9b03fef7f322c24acd2
DIFF: https://github.com/llvm/llvm-project/commit/ab95ed5ce0b099913eb5c9b03fef7f322c24acd2.diff
LOG: [IPO] Avoid repeated hash lookups (NFC) (#107796)
Added:
Modified:
llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h b/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
index 8bf902fc8d2841..3e7cc74fcf23b6 100644
--- a/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
+++ b/llvm/include/llvm/Transforms/IPO/ProfiledCallGraph.h
@@ -156,10 +156,8 @@ class ProfiledCallGraph {
ProfiledCallGraphEdge Edge(ProfiledFunctions[CallerName],
CalleeIt->second, Weight);
auto &Edges = ProfiledFunctions[CallerName]->Edges;
- auto EdgeIt = Edges.find(Edge);
- if (EdgeIt == Edges.end()) {
- Edges.insert(Edge);
- } else {
+ auto [EdgeIt, Inserted] = Edges.insert(Edge);
+ if (!Inserted) {
// Accumulate weight to the existing edge.
Edge.Weight += EdgeIt->Weight;
Edges.erase(EdgeIt);
More information about the llvm-commits
mailing list