Skip to content

Commit

Permalink
Merge commit d2353ae00c3b from llvm git (by Argyrios Kyrtzidis):
Browse files Browse the repository at this point in the history
  [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.

This avoids non-determinism in llvm-tblgen output, which could cause
differences in the generated X86GenCompressEVEXTables.inc file. Although
these differences are not influencing the meaning of the generated code,
they still change a few bytes in libllvm. This in turn influences all
the binaries linked with libllvm, such as clang, ld.lld, etc.

Reported by:	cperciva
MFC after:	3 days
  • Loading branch information
DimitryAndric committed Aug 10, 2024
1 parent aea9dba commit 7a8d05b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,7 +89,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";
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7a8d05b

Please sign in to comment.