[llvm] [CodeGen] Avoid repeated map lookups (NFC) (PR #140662)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon May 19 20:05:49 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140662
None
>From e7d45ce2ee7e3fbd175ff59375f76862d3414032 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 19 May 2025 12:38:11 -0700
Subject: [PATCH] [CodeGen] Avoid repeated map lookups (NFC)
---
llvm/lib/CodeGen/RDFLiveness.cpp | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/CodeGen/RDFLiveness.cpp b/llvm/lib/CodeGen/RDFLiveness.cpp
index b0f0f2501515a..318422b46e811 100644
--- a/llvm/lib/CodeGen/RDFLiveness.cpp
+++ b/llvm/lib/CodeGen/RDFLiveness.cpp
@@ -603,11 +603,8 @@ void Liveness::computePhiInfo() {
for (NodeAddr<DefNode *> D : Ds) {
if (D.Addr->getFlags() & NodeAttrs::PhiRef) {
NodeId RP = D.Addr->getOwner(DFG).Id;
- std::map<NodeId, RegisterAggr> &M = PhiUp[PUA.Id];
- auto F = M.find(RP);
- if (F == M.end())
- M.insert(std::make_pair(RP, DefRRs));
- else
+ auto [F, Inserted] = PhiUp[PUA.Id].try_emplace(RP, DefRRs);
+ if (!Inserted)
F->second.insert(DefRRs);
}
DefRRs.insert(D.Addr->getRegRef(DFG));
More information about the llvm-commits
mailing list