re PR middle-end/28964 (partition_stack_vars uses unstable sort)
authorRichard Guenther <rguenther@suse.de>
Fri, 22 Sep 2006 15:43:27 +0000 (15:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 22 Sep 2006 15:43:27 +0000 (15:43 +0000)
2006-09-22  Richard Guenther  <rguenther@suse.de>

PR middle-end/28964
* cfgexpand.c (stack_var_size_cmp): Use DECL_UID to make
sort of stack variables stable.

From-SVN: r117146

gcc/ChangeLog
gcc/cfgexpand.c

index 190d3873bd7358f08662f735d8c323cef6c41525..87c39b13f29714c103166103c37b74462b27a745 100644 (file)
@@ -1,3 +1,9 @@
+2006-09-22  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/28964
+       * cfgexpand.c (stack_var_size_cmp): Use DECL_UID to make
+       sort of stack variables stable.
+
 2006-09-22  Peter Bergner <bergner@vnet.ibm.com>
 
        PR middle-end/28690
index 9839d098375536f1b01953027d99ac47bb538567..4cc1047fadfde045d1478ceb4f747c012a9f6c8c 100644 (file)
@@ -350,11 +350,19 @@ stack_var_size_cmp (const void *a, const void *b)
 {
   HOST_WIDE_INT sa = stack_vars[*(const size_t *)a].size;
   HOST_WIDE_INT sb = stack_vars[*(const size_t *)b].size;
+  unsigned int uida = DECL_UID (stack_vars[*(const size_t *)a].decl);
+  unsigned int uidb = DECL_UID (stack_vars[*(const size_t *)b].decl);
 
   if (sa < sb)
     return -1;
   if (sa > sb)
     return 1;
+  /* For stack variables of the same size use the uid of the decl
+     to make the sort stable.  */
+  if (uida < uidb)
+    return -1;
+  if (uida > uidb)
+    return 1;
   return 0;
 }