[llvm] d2353ae - [utils/TableGen/X86CompressEVEXTablesEmitter.cpp] Make sure the tablegen output for the `checkPredicate` function is deterministic (#84533)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 9 22:34:22 PST 2024
Author: Argyrios Kyrtzidis
Date: 2024-03-09T22:34:18-08:00
New Revision: d2353ae00c3b0b0e9a9b93578e9bb067f699f193
URL: https://github.com/llvm/llvm-project/commit/d2353ae00c3b0b0e9a9b93578e9bb067f699f193
DIFF: https://github.com/llvm/llvm-project/commit/d2353ae00c3b0b0e9a9b93578e9bb067f699f193.diff
LOG: [utils/TableGen/X86CompressEVEXTablesEmitter.cpp] Make sure the tablegen output for the `checkPredicate` function is deterministic (#84533)
The output for the `checkPredicate` function was depending on a
`std::map` iteration that was non-deterministic from run to run, because
the keys were pointer values.
Make a change so that the keys are `StringRef`s so the ordering is
stable.
Added:
Modified:
llvm/utils/TableGen/X86CompressEVEXTablesEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/X86CompressEVEXTablesEmitter.cpp b/llvm/utils/TableGen/X86CompressEVEXTablesEmitter.cpp
index b96d16b9797cf3..0a9abbfe186ed6 100644
--- a/llvm/utils/TableGen/X86CompressEVEXTablesEmitter.cpp
+++ b/llvm/utils/TableGen/X86CompressEVEXTablesEmitter.cpp
@@ -46,7 +46,7 @@ class X86CompressEVEXTablesEmitter {
typedef std::pair<const CodeGenInstruction *, const CodeGenInstruction *>
Entry;
- typedef std::map<const Record *, std::vector<const CodeGenInstruction *>>
+ typedef std::map<StringRef, std::vector<const CodeGenInstruction *>>
PredicateInstMap;
std::vector<Entry> Table;
@@ -90,7 +90,7 @@ void X86CompressEVEXTablesEmitter::printCheckPredicate(
for (const auto &[Key, Val] : PredicateInsts) {
for (const auto &Inst : Val)
OS << " case X86::" << Inst->TheDef->getName() << ":\n";
- OS << " return " << Key->getValueAsString("CondString") << ";\n";
+ OS << " return " << Key << ";\n";
}
OS << " }\n";
@@ -226,7 +226,7 @@ void X86CompressEVEXTablesEmitter::run(raw_ostream &OS) {
Name == "HasAVXIFMA";
});
if (It != Predicates.end())
- PredicateInsts[*It].push_back(NewInst);
+ PredicateInsts[(*It)->getValueAsString("CondString")].push_back(NewInst);
}
printTable(Table, OS);
More information about the llvm-commits
mailing list