diff mbox

var-tracking vs. pseudo registers (was: Option overriding in the offloading code path)

Message ID 87vbipge85.fsf@schwinge.name
State New
Headers show

Commit Message

Thomas Schwinge Feb. 26, 2015, 10:27 a.m. UTC
Hi!

On Wed, 25 Feb 2015 18:00:54 +0100, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Feb 25, 2015 at 11:28:12AM +0100, Thomas Schwinge wrote:
> > Am I on the right track with my assumption that it is correct that
> > nvptx.c:nvptx_option_override is not invoked in the offloading code path,
> > so we'd need a new target hook (?) to consolidate/override the options in
> > this scenario?
> > 
> > 
> > Using this to forcefully disable -fvar-tracking (as done in
> > nvptx_option_override), should then allow me to drop the following
> > beautiful specimen of a patch (which I didn't commit anywhere, so far):
> 
> Supposedly you could just disable var-tracking for
> targetm.no_register_allocation case, or change that assert to
> allow pseudos for targetm.no_register_allocation?

Just changing the assert, or handling this configuration differently:



> Anyway, if var-tracking is never useful for NVPTX, if you want to override
> it early, flag_var_tracking* options are Optimization options, thus you'd
> need a target hook similar to the one I've added today, but instead of
> TARGET_OPTION_NODE do something similar for OPTIMIZATION_NODE streaming.


Grüße,
 Thomas

Comments

Jakub Jelinek Feb. 26, 2015, 10:46 a.m. UTC | #1
On Thu, Feb 26, 2015 at 11:27:06AM +0100, Thomas Schwinge wrote:
> Is this not the right way to skip it, or, Bernd, is this because we're
> not yet handling some debug stuff in nvptx?  (I tested that
> <http://news.gmane.org/find-root.php?message_id=%3C5466473A.1090809%40codesourcery.com%3E>
> does not help with that.)  The following does make it work (that is,
> resolve the ICEs), but that feels a bit too much ;-) of a hack:
> 
> --- gcc/var-tracking.c
> +++ gcc/var-tracking.c
> @@ -10305,7 +10322,8 @@ variable_tracking_main_1 (void)
>  {
>    bool success;
>  
> -  if (flag_var_tracking_assignments < 0)
> +  if (flag_var_tracking_assignments < 0
> +      || targetm.no_register_allocation)
>      {
>        delete_debug_insns ();
>        return 0;

No, IMHO that is the right fix, not a hack.  But of course would deserve
a comment.  Plus of course you can also just override
flag_var_tracking_assignments in the nvptx override option hook, and
perhaps in tree-streamer-in.c clear flag_var_tracking_assignments in the
OPTIMIZATION_NODE too (or just add a hook for that, as I said before).

	Jakub
diff mbox

Patch

diff --git gcc/var-tracking.c gcc/var-tracking.c
index 9ec5d8b..e37dc19 100644
--- gcc/var-tracking.c
+++ gcc/var-tracking.c
@@ -1854,6 +1854,7 @@  var_reg_decl_set (dataflow_set *set, rtx loc, enum var_init_status initialized,
   if (decl_p)
     dv = dv_from_decl (var_debug_decl (dv_as_decl (dv)));
 
+  gcc_assert (REGNO (loc) < FIRST_PSEUDO_REGISTER);
   for (node = set->regs[REGNO (loc)]; node; node = node->next)
     if (dv_as_opaque (node->dv) == dv_as_opaque (dv)
 	&& node->offset == offset)
@@ -1925,6 +1926,7 @@  var_reg_delete_and_set (dataflow_set *set, rtx loc, bool modify,
   if (initialized == VAR_INIT_STATUS_UNKNOWN)
     initialized = get_init_value (set, loc, dv_from_decl (decl));
 
+  gcc_assert (REGNO (loc) < FIRST_PSEUDO_REGISTER);
   nextp = &set->regs[REGNO (loc)];
   for (node = *nextp; node; node = next)
     {
@@ -1954,6 +1956,7 @@  var_reg_delete_and_set (dataflow_set *set, rtx loc, bool modify,
 static void
 var_reg_delete (dataflow_set *set, rtx loc, bool clobber)
 {
+  gcc_assert (REGNO (loc) < FIRST_PSEUDO_REGISTER);
   attrs *nextp = &set->regs[REGNO (loc)];
   attrs node, next;
 
@@ -1986,6 +1989,7 @@  var_reg_delete (dataflow_set *set, rtx loc, bool clobber)
 static void
 var_regno_delete (dataflow_set *set, int regno)
 {
+  gcc_assert (regno < FIRST_PSEUDO_REGISTER);
   attrs *reg = &set->regs[regno];
   attrs node, next;
 
@@ -2630,6 +2634,7 @@  val_resolve (dataflow_set *set, rtx val, rtx loc, rtx_insn *insn)
     {
       attrs node, found = NULL;
 
+      gcc_assert (REGNO (loc) < FIRST_PSEUDO_REGISTER);
       for (node = set->regs[REGNO (loc)]; node; node = node->next)
 	if (dv_is_value_p (node->dv)
 	    && GET_MODE (dv_as_value (node->dv)) == GET_MODE (loc))
@@ -3784,6 +3789,7 @@  canonicalize_values_star (variable_def **slot, dataflow_set *set)
 	  }
 	else if (GET_CODE (node->loc) == REG)
 	  {
+	    gcc_assert (REGNO (node->loc) < FIRST_PSEUDO_REGISTER);
 	    attrs list = set->regs[REGNO (node->loc)], *listp;
 
 	    /* Change an existing attribute referring to dv so that it
@@ -4045,6 +4051,7 @@  variable_merge_over_cur (variable s1var, struct dfset_merge *dsm)
 	{
 	  attrs list;
 
+	  gcc_assert (REGNO (node->loc) < FIRST_PSEUDO_REGISTER);
 	  for (list = dst->regs[REGNO (node->loc)]; list; list = list->next)
 	    if (GET_MODE (node->loc) == GET_MODE (list->loc)
 		&& dv_is_value_p (list->dv))
@@ -4426,6 +4433,7 @@  variable_post_merge_new_vals (variable_def **slot, dfset_post_merge *dfpm)
 		  goto restart;
 		}
 
+	      gcc_assert (REGNO (node->loc) < FIRST_PSEUDO_REGISTER);
 	      for (attp = &set->regs[REGNO (node->loc)]; (att = *attp);
 		   attp = &att->next)
 		if (att->offset == 0
@@ -4466,6 +4474,7 @@  variable_post_merge_new_vals (variable_def **slot, dfset_post_merge *dfpm)
 		      dataflow_set_init (*dfpm->permp);
 		    }
 
+		  gcc_assert (REGNO (node->loc) < FIRST_PSEUDO_REGISTER);
 		  for (att = (*dfpm->permp)->regs[REGNO (node->loc)];
 		       att; att = att->next)
 		    if (GET_MODE (att->loc) == GET_MODE (node->loc))
@@ -4561,6 +4570,7 @@  variable_post_merge_perm_vals (variable_def **pslot, dfset_post_merge *dfpm)
       val_reset (set, dv);
     }
 
+  gcc_assert (REGNO (pnode->loc) < FIRST_PSEUDO_REGISTER);
   for (att = set->regs[REGNO (pnode->loc)]; att; att = att->next)
     if (att->offset == 0
 	&& GET_MODE (att->loc) == GET_MODE (pnode->loc)
@@ -7837,6 +7853,7 @@  clobber_slot_part (dataflow_set *set, rtx loc, variable_def **slot,
 		     list, but preserve any other variable parts
 		     that might be regarded as live in that same
 		     register.  */
+		  gcc_assert (REGNO (node->loc) < FIRST_PSEUDO_REGISTER);
 		  anextp = &set->regs[REGNO (node->loc)];
 		  for (anode = *anextp; anode; anode = anext)
 		    {