This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix unstable sort, PR28964

This fixes PR28964 by using DECL_UID to disambiguate stack vars with
the same size.

Bootstrapped and tested on i686-pc-linux-gnu.

Ok for mainline and 4.1 and 4.0?


:ADDPATCH middle-end:

2006-09-22  Richard Guenther  <>

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

Index: cfgexpand.c
*** cfgexpand.c	(revision 117056)
--- cfgexpand.c	(working copy)
*************** stack_var_size_cmp (const void *a, const
*** 350,360 ****
--- 350,369 ----
    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;
+   gcc_unreachable ();
    return 0;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]