[llvm] 618ac90 - [TableGen] Avoid repeated hash lookups (NFC) (#123018)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 07:57:33 PST 2025
Author: Kazu Hirata
Date: 2025-01-15T07:57:30-08:00
New Revision: 618ac908db72c312e1fbdfe974b4a084b4fc4c45
URL: https://github.com/llvm/llvm-project/commit/618ac908db72c312e1fbdfe974b4a084b4fc4c45
DIFF: https://github.com/llvm/llvm-project/commit/618ac908db72c312e1fbdfe974b4a084b4fc4c45.diff
LOG: [TableGen] Avoid repeated hash lookups (NFC) (#123018)
Added:
Modified:
llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
index 149ba7a1d9032d..bc300c3461100e 100644
--- a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
@@ -2645,8 +2645,8 @@ GICombinerEmitter::buildMatchTable(MutableArrayRef<RuleMatcher> Rules) {
for (RuleMatcher &Rule : Rules) {
const StringRef Opcode = Rule.getOpcode();
assert(!Opcode.empty() && "Didn't expect an undefined opcode");
- if (OpcodeOrder.count(Opcode) == 0)
- OpcodeOrder[Opcode] = CurrentOrdering++;
+ if (OpcodeOrder.try_emplace(Opcode, CurrentOrdering).second)
+ ++CurrentOrdering;
}
llvm::stable_sort(InputRules, [&OpcodeOrder](const Matcher *A,
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 3b334ea4ce152c..04ebdbb0ffc90b 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -2216,8 +2216,8 @@ GlobalISelEmitter::buildMatchTable(MutableArrayRef<RuleMatcher> Rules,
for (RuleMatcher &Rule : Rules) {
const StringRef Opcode = Rule.getOpcode();
assert(!Opcode.empty() && "Didn't expect an undefined opcode");
- if (OpcodeOrder.count(Opcode) == 0)
- OpcodeOrder[Opcode] = CurrentOrdering++;
+ if (OpcodeOrder.try_emplace(Opcode, CurrentOrdering).second)
+ ++CurrentOrdering;
}
llvm::stable_sort(
More information about the llvm-commits
mailing list