This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix unstable sort, PR28964
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 22 Sep 2006 13:21:46 +0200 (CEST)
- Subject: [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?
Thanks,
Richard.
:ADDPATCH middle-end:
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.
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;
}