Fix a bug in the TopoOrderRC comparison function.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 1 Feb 2012 22:19:26 +0000 (22:19 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 1 Feb 2012 22:19:26 +0000 (22:19 +0000)
The final tie breaker comparison also needs to return +/-1, or 0.
This is not a less() function.

This could cause otherwise identical super-classes to be ordered
unstably, depending on what the system qsort routine does with a bad
compare function.

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

utils/TableGen/CodeGenRegisters.cpp

index 7c6661742aacc13e90639e2db7d83929b7b15de7..1d06f3e52876a34fa87c0c415943a0c9edaceeb5 100644 (file)
@@ -503,7 +503,7 @@ static int TopoOrderRC(const void *PA, const void *PB) {
     return 1;
 
   // Finally order by name as a tie breaker.
-  return A->getName() < B->getName();
+  return StringRef(A->getName()).compare(B->getName());
 }
 
 std::string CodeGenRegisterClass::getQualifiedName() const {