Skip to content

Commit d2353ae

Browse files
authored
[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.
1 parent e95040f commit d2353ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/utils/TableGen/X86CompressEVEXTablesEmitter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class X86CompressEVEXTablesEmitter {
4646

4747
typedef std::pair<const CodeGenInstruction *, const CodeGenInstruction *>
4848
Entry;
49-
typedef std::map<const Record *, std::vector<const CodeGenInstruction *>>
49+
typedef std::map<StringRef, std::vector<const CodeGenInstruction *>>
5050
PredicateInstMap;
5151

5252
std::vector<Entry> Table;
@@ -90,7 +90,7 @@ void X86CompressEVEXTablesEmitter::printCheckPredicate(
9090
for (const auto &[Key, Val] : PredicateInsts) {
9191
for (const auto &Inst : Val)
9292
OS << " case X86::" << Inst->TheDef->getName() << ":\n";
93-
OS << " return " << Key->getValueAsString("CondString") << ";\n";
93+
OS << " return " << Key << ";\n";
9494
}
9595

9696
OS << " }\n";
@@ -226,7 +226,7 @@ void X86CompressEVEXTablesEmitter::run(raw_ostream &OS) {
226226
Name == "HasAVXIFMA";
227227
});
228228
if (It != Predicates.end())
229-
PredicateInsts[*It].push_back(NewInst);
229+
PredicateInsts[(*It)->getValueAsString("CondString")].push_back(NewInst);
230230
}
231231

232232
printTable(Table, OS);

0 commit comments

Comments
 (0)