diff --git a/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp b/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp index 3686c7c153999..5021425152f6c 100644 --- a/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp +++ b/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp @@ -70,11 +70,12 @@ struct RematGraph { std::deque> &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(Def.get()); if (!D || !MaterializableCallback(*D) ||