public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 7/9] ira-color
@ 2017-04-01 16:48 Andrew Jenner
  2017-04-01 17:21 ` Gerald Pfeifer
  2017-04-25 16:47 ` Jeff Law
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Jenner @ 2017-04-01 16:48 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

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.



[-- Attachment #2: gcc_ia16_ira-color.patch --]
[-- Type: text/x-patch, Size: 1829 bytes --]

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;




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 7/9] ira-color
  2017-04-01 16:48 [PATCH 7/9] ira-color Andrew Jenner
@ 2017-04-01 17:21 ` Gerald Pfeifer
  2017-04-03 15:28   ` Jeff Law
  2017-04-25 16:47 ` Jeff Law
  1 sibling, 1 reply; 4+ messages in thread
From: Gerald Pfeifer @ 2017-04-01 17:21 UTC (permalink / raw)
  To: Andrew Jenner, Vladimir Makarov; +Cc: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 670 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch; NAME=gcc_ia16_ira-color.patch, Size: 1829 bytes --]

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;




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 7/9] ira-color
  2017-04-01 17:21 ` Gerald Pfeifer
@ 2017-04-03 15:28   ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2017-04-03 15:28 UTC (permalink / raw)
  To: Gerald Pfeifer, Andrew Jenner, Vladimir Makarov; +Cc: GCC Patches

On 04/01/2017 11:21 AM, Gerald Pfeifer wrote:
> 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).
Right.  ANd it would be helpful to have more information on how this 
happened.  Otherwise Vlad and the rest of the team have to guess what 
might have happened -- we might guess wrong leading to an incorrect 
conclusion about the correctness of the patch.

Testcases help considerably as well.

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 7/9] ira-color
  2017-04-01 16:48 [PATCH 7/9] ira-color Andrew Jenner
  2017-04-01 17:21 ` Gerald Pfeifer
@ 2017-04-25 16:47 ` Jeff Law
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Law @ 2017-04-25 16:47 UTC (permalink / raw)
  To: Andrew Jenner, GCC Patches

On 04/01/2017 10:48 AM, 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.
Again, testcase or more information needed.

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-25 16:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-01 16:48 [PATCH 7/9] ira-color Andrew Jenner
2017-04-01 17:21 ` Gerald Pfeifer
2017-04-03 15:28   ` Jeff Law
2017-04-25 16:47 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).