[llvm] [Coroutines] Avoid repeated hash lookups (NFC) (PR #126466)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 9 21:29:44 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-coroutines
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/126466.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp (+3-2)
``````````diff
diff --git a/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp b/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp
index 3686c7c153999c..5021425152f6cc 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) ||
``````````
</details>
https://github.com/llvm/llvm-project/pull/126466
More information about the llvm-commits
mailing list