This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 7/9] ira-color
- From: Gerald Pfeifer <gerald at pfeifer dot com>
- To: Andrew Jenner <andrew at codesourcery dot com>, Vladimir Makarov <vmakarov at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 1 Apr 2017 19:21:05 +0200 (CEST)
- Subject: Re: [PATCH 7/9] ira-color
- Authentication-results: sourceware.org; auth=none
- References: <e7b13ed0-f0eb-416a-6535-75b12612fe26@codesourcery.com>
On Sat, 1 Apr 2017, Andrew Jenner wrote:
In the course of working with ia16, I found a case where the sorted_allocnos
array in ira-color.c requires more than ira_allocnos_num entries. The
following patch allows this array to expand when this happens.
2017-04-01 Andrew Jenner <andrew@codesourcery.com>
* ira-color.c (n_sorted_allocnos): New variable.
(improve_allocation): Use it.
(ira_initiate_assign): Initialize it.
(fast_allocation): Likewise.
General improvements/fixes like this you may want to submit independently
of your port and copy the respective maintainers (such as Vladimir for
register allocation who I'm adding now).
Gerald
Index: gcc/ira-color.c
===================================================================
--- gcc/ira-color.c (revision 475331)
+++ gcc/ira-color.c (revision 475455)
@@ -178,6 +178,7 @@ static bitmap consideration_allocno_bitm
/* All allocnos sorted according their priorities. */
static ira_allocno_t *sorted_allocnos;
+static int n_sorted_allocnos;
/* Vec representing the stack of allocnos used during coloring. */
static vec<ira_allocno_t> allocno_stack_vec;
@@ -2937,6 +2938,17 @@ improve_allocation (void)
/* No intersection. */
continue;
ALLOCNO_HARD_REGNO (conflict_a) = -1;
+ if (n == n_sorted_allocnos)
+ {
+ ira_allocno_t *sorted_allocnos_expanded
+ = (ira_allocno_t *) ira_allocate (sizeof (ira_allocno_t)
+ * n_sorted_allocnos * 2);
+ memcpy (sorted_allocnos_expanded, sorted_allocnos,
+ sizeof (ira_allocno_t) * n_sorted_allocnos);
+ ira_free (sorted_allocnos);
+ sorted_allocnos = sorted_allocnos_expanded;
+ n_sorted_allocnos *= 2;
+ }
sorted_allocnos[n++] = conflict_a;
if (internal_flag_ira_verbose > 2 && ira_dump_file != NULL)
fprintf (ira_dump_file, "Spilling a%dr%d for a%dr%d\n",
@@ -4740,6 +4752,7 @@ ira_initiate_assign (void)
sorted_allocnos
= (ira_allocno_t *) ira_allocate (sizeof (ira_allocno_t)
* ira_allocnos_num);
+ n_sorted_allocnos = ira_allocnos_num;
consideration_allocno_bitmap = ira_allocate_bitmap ();
initiate_cost_update ();
allocno_priorities = (int *) ira_allocate (sizeof (int) * ira_allocnos_num);
@@ -4797,6 +4810,7 @@ fast_allocation (void)
sorted_allocnos = (ira_allocno_t *) ira_allocate (sizeof (ira_allocno_t)
* ira_allocnos_num);
+ n_sorted_allocnos = ira_allocnos_num;
num = 0;
FOR_EACH_ALLOCNO (a, ai)
sorted_allocnos[num++] = a;