AsmMatcherEmitter: Use stable_sort when reordering instructions, so that order
authorDaniel Dunbar <daniel@zuster.org>
Tue, 2 Feb 2010 23:46:36 +0000 (23:46 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 2 Feb 2010 23:46:36 +0000 (23:46 +0000)
is still deterministic even amongst ambiguous instructions (eventually ambiguous
match orders will be a hard error, but we aren't there yet).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95157 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/AsmMatcherEmitter.cpp

index dca7929e545844e1ce806dc0122572aeed8a18d3..c80285fa377953efd40a9217ebb9733433104e36 100644 (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