[test-suite] r178810 - Improving lemon sort criteria makes test pass

Renato Golin renato.golin at linaro.org
Thu Apr 4 16:33:47 PDT 2013


Author: rengolin
Date: Thu Apr  4 18:33:46 2013
New Revision: 178810

URL: http://llvm.org/viewvc/llvm-project?rev=178810&view=rev
Log:
Improving lemon sort criteria makes test pass

As with other tests, the output of lemon was scrambled due to
its sorting criteria. Changing the comparison functions made it
more stable and now it's similar on Linux x86_64, ARM and Darwin.

The reference output is an MD5 of the real output because the
latter is 40M and diff has some trouble parsing it on resource
limited machines, not to mention skimming through a multi-MB
diff on the logs.

Modified:
    test-suite/trunk/MultiSource/Applications/lemon/lemon.c
    test-suite/trunk/MultiSource/Applications/lemon/lemon.reference_output

Modified: test-suite/trunk/MultiSource/Applications/lemon/lemon.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/lemon/lemon.c?rev=178810&r1=178809&r2=178810&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Applications/lemon/lemon.c (original)
+++ test-suite/trunk/MultiSource/Applications/lemon/lemon.c Thu Apr  4 18:33:46 2013
@@ -3491,7 +3491,13 @@ struct axset {
 static int axset_compare(const void *a, const void *b){
   struct axset *p1 = (struct axset*)a;
   struct axset *p2 = (struct axset*)b;
-  return p2->nAction - p1->nAction;
+  if (p1->nAction < p2->nAction) return -1;
+  if (p1->nAction > p2->nAction) return 1;
+  if (p1->isTkn < p2->isTkn) return -1;
+  if (p1->isTkn > p2->isTkn) return 1;
+  if (p1->stp->statenum < p2->stp->statenum) return -1;
+  if (p1->stp->statenum > p2->stp->statenum) return 1;
+  return 0;
 }
 
 /*
@@ -4040,13 +4046,13 @@ struct lemon *lemp;
 static int stateResortCompare(const void *a, const void *b){
   const struct state *pA = *(const struct state**)a;
   const struct state *pB = *(const struct state**)b;
-  int n;
-
-  n = pB->nNtAct - pA->nNtAct;
-  if( n==0 ){
-    n = pB->nTknAct - pA->nTknAct;
-  }
-  return n;
+  if (pA->nNtAct < pB->nNtAct) return -1;
+  if (pA->nNtAct > pB->nNtAct) return 1;
+  if (pA->nTknAct < pB->nTknAct) return -1;
+  if (pA->nTknAct > pB->nTknAct) return 1;
+  if (pA->statenum < pB->statenum) return -1;
+  if (pA->statenum > pB->statenum) return 1;
+  return 0;
 }
 
 
@@ -4346,9 +4352,15 @@ char *x;
 ** smallest parser tables in SQLite.
 */
 int Symbolcmpp(struct symbol **a, struct symbol **b){
-  int i1 = (**a).index + 10000000*((**a).name[0]>'Z');
-  int i2 = (**b).index + 10000000*((**b).name[0]>'Z');
-  return i1-i2;
+  int indexA = (**a).index;
+  int indexB = (**b).index;
+  int i1 = indexA + 10000000*((**a).name[0]>'Z');
+  int i2 = indexB + 10000000*((**b).name[0]>'Z');
+  if (i1 < i2) return -1;
+  if (i1 > i2) return 1;
+  if (indexA < indexB) return -1;
+  if (indexA > indexB) return 1;
+  return 0;
 }
 
 /* There is one instance of the following structure for each

Modified: test-suite/trunk/MultiSource/Applications/lemon/lemon.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/lemon/lemon.reference_output?rev=178810&r1=178809&r2=178810&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Applications/lemon/lemon.reference_output (original)
+++ test-suite/trunk/MultiSource/Applications/lemon/lemon.reference_output Thu Apr  4 18:33:46 2013
@@ -1 +1 @@
-b0e45716410d6ea87f60851c46267162
+8c4854398b356b594ac3bbe1f0e3f4dc





More information about the llvm-commits mailing list