[llvm] [utils/TableGen/X86CompressEVEXTablesEmitter.cpp] Make sure the tablegen output for the `checkPredicate` function is deterministic (PR #84533)
Argyrios Kyrtzidis via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 8 19:58:15 PST 2024
https://github.com/akyrtzi updated https://github.com/llvm/llvm-project/pull/84533
>From 20c374820dfed4aa1702871ecee75e87481a1233 Mon Sep 17 00:00:00 2001
From: Argyrios Kyrtzidis <kyrtzidis at apple.com>
Date: Fri, 8 Mar 2024 10:41:16 -0800
Subject: [PATCH] [utils/TableGen/X86CompressEVEXTablesEmitter.cpp] Make sure
the tablegen output for the `checkPredicate` function is deterministic
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.
---
llvm/utils/TableGen/X86CompressEVEXTablesEmitter.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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