AsmMatcherEmitter: Use stable_sort when reordering instructions, so that order

is still deterministic even amongst ambiguous instructions (eventually ambiguous
match orders will be a hard error, but we aren't there yet).

llvm-svn: 95157
This commit is contained in:
Daniel Dunbar 2010-02-02 23:46:36 +00:00
parent 62ba09bb47
commit 9b2879bd70

View File

@ -1413,9 +1413,11 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
AsmMatcherInfo Info(AsmParser);
Info.BuildInfo(Target);
// Sort the instruction table using the partial order on classes.
std::sort(Info.Instructions.begin(), Info.Instructions.end(),
less_ptr<InstructionInfo>());
// Sort the instruction table using the partial order on classes. We use
// stable_sort to ensure that ambiguous instructions are still
// deterministically ordered.
std::stable_sort(Info.Instructions.begin(), Info.Instructions.end(),
less_ptr<InstructionInfo>());
DEBUG_WITH_TYPE("instruction_info", {
for (std::vector<InstructionInfo*>::iterator