From b9dde9a9aec923b8141bc2bf72b6bbdf110ebda5 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 19 Dec 2024 13:04:46 -0800 Subject: [PATCH 1/2] [TableGen] Avoid repeated hash lookups (NFC) --- llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp index 1a393beaa14f9..7a82581f2240c 100644 --- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp @@ -3508,9 +3508,8 @@ void CodeGenDAGPatterns::FindPatternInputsAndOutputs( Val->getDef()->isSubClassOf("PointerLikeRegClass")) { if (Dest->getName().empty()) I.error("set destination must have a name!"); - if (InstResults.count(Dest->getName())) + if (!InstResults.try_emplace(Dest->getName(), Dest).second) I.error("cannot set '" + Dest->getName() + "' multiple times"); - InstResults[Dest->getName()] = Dest; } else if (Val->getDef()->isSubClassOf("Register")) { InstImpResults.push_back(Val->getDef()); } else { From cc47d4cee8b080a1a3430beb2d2fa62646377b38 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 19 Dec 2024 22:51:49 -0800 Subject: [PATCH 2/2] Address comments. --- llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp index 7a82581f2240c..1a61d32b4869a 100644 --- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp @@ -3508,7 +3508,7 @@ void CodeGenDAGPatterns::FindPatternInputsAndOutputs( Val->getDef()->isSubClassOf("PointerLikeRegClass")) { if (Dest->getName().empty()) I.error("set destination must have a name!"); - if (!InstResults.try_emplace(Dest->getName(), Dest).second) + if (!InstResults.insert_or_assign(Dest->getName(), Dest).second) I.error("cannot set '" + Dest->getName() + "' multiple times"); } else if (Val->getDef()->isSubClassOf("Register")) { InstImpResults.push_back(Val->getDef());