[llvm] [Coroutines] Avoid repeated hash lookups (NFC) (PR #126466)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 9 21:29:11 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/126466
None
>From a1dcb565347f7788d4e4a473a63e2a5ef3b6bf3d Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 9 Feb 2025 13:52:17 -0800
Subject: [PATCH] [Coroutines] Avoid repeated hash lookups (NFC)
---
llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp b/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp
index 3686c7c153999cb..5021425152f6cc0 100644
--- a/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp
+++ b/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp
@@ -70,11 +70,12 @@ struct RematGraph {
std::deque<std::unique_ptr<RematNode>> &WorkList,
User *FirstUse) {
RematNode *N = NUPtr.get();
- if (Remats.count(N->Node))
+ auto [It, Inserted] = Remats.try_emplace(N->Node);
+ if (!Inserted)
return;
// We haven't see this node yet - add to the list
- Remats[N->Node] = std::move(NUPtr);
+ It->second = std::move(NUPtr);
for (auto &Def : N->Node->operands()) {
Instruction *D = dyn_cast<Instruction>(Def.get());
if (!D || !MaterializableCallback(*D) ||
More information about the llvm-commits
mailing list