Patchwork [PR,55238] More careful pass-through handling in find_aggregate_values_for_callers_subset

login
register
mail settings
Submitter Martin Jambor
Date Nov. 8, 2012, 10:59 p.m.
Message ID <20121108225909.GE24044@virgil.arch.suse.de>
Download mbox | patch
Permalink /patch/197903/
State New
Headers show

Comments

Martin Jambor - Nov. 8, 2012, 10:59 p.m.
Hi,

when writing find_aggregate_values_for_callers_subset, I omitted a
test that is present in propagate_aggs_accross_jump_function and that
lead to triggering an assert in the former.

Fixed by moving the test into a separate predicate function in the
following patch.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin


2012-11-08  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/55238
	* ipa-cp.c (agg_pass_through_permissible_p): New function.
	(propagate_aggs_accross_jump_function): Use it.
	(find_aggregate_values_for_callers_subset): Likewise and relax an
	assert.

	* testsuite/gcc.dg/torture/pr55238.c: New test.
Jan Hubicka - Nov. 9, 2012, 11:35 a.m.
> Hi,
> 
> when writing find_aggregate_values_for_callers_subset, I omitted a
> test that is present in propagate_aggs_accross_jump_function and that
> lead to triggering an assert in the former.
> 
> Fixed by moving the test into a separate predicate function in the
> following patch.
> 
> Bootstrapped and tested on x86_64-linux.  OK for trunk?
MThis patch looks OK.  i will re-test and commit it on the afernoon.

Honza

> 
> Thanks,
> 
> Martin
> 
> 
> 2012-11-08  Martin Jambor  <mjambor@suse.cz>
> 
> 	PR tree-optimization/55238
> 	* ipa-cp.c (agg_pass_through_permissible_p): New function.
> 	(propagate_aggs_accross_jump_function): Use it.
> 	(find_aggregate_values_for_callers_subset): Likewise and relax an
> 	assert.
> 
> 	* testsuite/gcc.dg/torture/pr55238.c: New test.
> 
> Index: src/gcc/ipa-cp.c
> ===================================================================
> --- src.orig/gcc/ipa-cp.c
> +++ src/gcc/ipa-cp.c
> @@ -1312,6 +1312,19 @@ merge_aggregate_lattices (struct cgraph_
>    return ret;
>  }
>  
> +/* Determine whether there is anything to propagate FROM SRC_PLATS through a
> +   pass-through JFUNC and if so, whether it has conform and conforms to the
> +   rules about propagating values passed by reference.  */
> +
> +static bool
> +agg_pass_through_permissible_p (struct ipcp_param_lattices *src_plats,
> +				struct ipa_jump_func *jfunc)
> +{
> +  return src_plats->aggs
> +    && (!src_plats->aggs_by_ref
> +	|| ipa_get_jf_pass_through_agg_preserved (jfunc));
> +}
> +
>  /* Propagate scalar values across jump function JFUNC that is associated with
>     edge CS and put the values into DEST_LAT.  */
>  
> @@ -1333,9 +1346,7 @@ propagate_aggs_accross_jump_function (st
>        struct ipcp_param_lattices *src_plats;
>  
>        src_plats = ipa_get_parm_lattices (caller_info, src_idx);
> -      if (src_plats->aggs
> -	  && (!src_plats->aggs_by_ref
> -	      || ipa_get_jf_pass_through_agg_preserved (jfunc)))
> +      if (agg_pass_through_permissible_p (src_plats, jfunc))
>  	{
>  	  /* Currently we do not produce clobber aggregate jump
>  	     functions, replace with merging when we do.  */
> @@ -2893,23 +2904,33 @@ find_aggregate_values_for_callers_subset
>  
>  	      if (caller_info->ipcp_orig_node)
>  		{
> -		  if (!inter)
> -		    inter = agg_replacements_to_vector (cs->caller, 0);
> -		  else
> -		    intersect_with_agg_replacements (cs->caller, src_idx,
> -						     &inter, 0);
> +		  struct cgraph_node *orig_node = caller_info->ipcp_orig_node;
> +		  struct ipcp_param_lattices *orig_plats;
> +		  orig_plats = ipa_get_parm_lattices (IPA_NODE_REF (orig_node),
> +						      src_idx);
> +		  if (agg_pass_through_permissible_p (orig_plats, jfunc))
> +		    {
> +		      if (!inter)
> +			inter = agg_replacements_to_vector (cs->caller, 0);
> +		      else
> +			intersect_with_agg_replacements (cs->caller, src_idx,
> +							 &inter, 0);
> +		    }
>  		}
>  	      else
>  		{
>  		  struct ipcp_param_lattices *src_plats;
>  		  src_plats = ipa_get_parm_lattices (caller_info, src_idx);
> -		  /* Currently we do not produce clobber aggregate jump
> -		     functions, adjust when we do.  */
> -		  gcc_checking_assert (!jfunc->agg.items);
> -		  if (!inter)
> -		    inter = copy_plats_to_inter (src_plats, 0);
> -		  else
> -		    intersect_with_plats (src_plats, &inter, 0);
> +		  if (agg_pass_through_permissible_p (src_plats, jfunc))
> +		    {
> +		      /* Currently we do not produce clobber aggregate jump
> +			 functions, adjust when we do.  */
> +		      gcc_checking_assert (!jfunc->agg.items);
> +		      if (!inter)
> +			inter = copy_plats_to_inter (src_plats, 0);
> +		      else
> +			intersect_with_plats (src_plats, &inter, 0);
> +		    }
>  		}
>  	    }
>  	  else if (jfunc->type == IPA_JF_ANCESTOR
> @@ -2933,7 +2954,7 @@ find_aggregate_values_for_callers_subset
>  		  src_plats = ipa_get_parm_lattices (caller_info, src_idx);;
>  		  /* Currently we do not produce clobber aggregate jump
>  		     functions, adjust when we do.  */
> -		  gcc_checking_assert (!jfunc->agg.items);
> +		  gcc_checking_assert (!src_plats->aggs || !jfunc->agg.items);
>  		  if (!inter)
>  		    inter = copy_plats_to_inter (src_plats, delta);
>  		  else
> Index: src/gcc/testsuite/gcc.dg/torture/pr55238.c
> ===================================================================
> --- /dev/null
> +++ src/gcc/testsuite/gcc.dg/torture/pr55238.c
> @@ -0,0 +1,44 @@
> +/* { dg-do compile } */
> +
> +typedef void * gzFile;
> +typedef struct
> +{
> +  int mode;
> +  int direct;
> +  int seek;
> +  int err;
> +  char *msg;
> +}
> +gz_state;
> +
> +void gz_error (gz_state *state, int err, char *msg);
> +
> +static void
> +gz_reset (gz_state *state)
> +{
> +  if (state->mode == 7247)
> +    {
> +      state->direct = 1;
> +    }
> +  state->seek = 0;
> +  gz_error (state, 0, 0);
> +}
> +
> +int
> +gzbuffer (void *file, int size)
> +{
> +  gz_state *state;
> +  gz_reset (state);
> +}
> +
> +void __attribute__ ((visibility ("hidden"))) gz_error (gz_state *state, int err, char *msg)
> +{
> +  if (state->msg != 0)
> +    {
> +      if (state->err != -4)
> +	foo (state->msg);
> +    }
> +  if (msg == 0)
> +    return;
> +  bar (state->msg, msg);
> +}
Eric Botcazou - Nov. 11, 2012, 6:21 p.m.
> MThis patch looks OK.  i will re-test and commit it on the afernoon.

Ping.  The ICE shows up when building Python.
Jan Hubicka - Nov. 11, 2012, 11:09 p.m.
> > MThis patch looks OK.  i will re-test and commit it on the afernoon.
> 
> Ping.  The ICE shows up when building Python.

I comitted it this afternoon, hope everything is fine now.

Honza
> 
> -- 
> Eric Botcazou
Eric Botcazou - Nov. 11, 2012, 11:10 p.m.
> I comitted it this afternoon, hope everything is fine now.

Yes, thanks.

Patch

Index: src/gcc/ipa-cp.c
===================================================================
--- src.orig/gcc/ipa-cp.c
+++ src/gcc/ipa-cp.c
@@ -1312,6 +1312,19 @@  merge_aggregate_lattices (struct cgraph_
   return ret;
 }
 
+/* Determine whether there is anything to propagate FROM SRC_PLATS through a
+   pass-through JFUNC and if so, whether it has conform and conforms to the
+   rules about propagating values passed by reference.  */
+
+static bool
+agg_pass_through_permissible_p (struct ipcp_param_lattices *src_plats,
+				struct ipa_jump_func *jfunc)
+{
+  return src_plats->aggs
+    && (!src_plats->aggs_by_ref
+	|| ipa_get_jf_pass_through_agg_preserved (jfunc));
+}
+
 /* Propagate scalar values across jump function JFUNC that is associated with
    edge CS and put the values into DEST_LAT.  */
 
@@ -1333,9 +1346,7 @@  propagate_aggs_accross_jump_function (st
       struct ipcp_param_lattices *src_plats;
 
       src_plats = ipa_get_parm_lattices (caller_info, src_idx);
-      if (src_plats->aggs
-	  && (!src_plats->aggs_by_ref
-	      || ipa_get_jf_pass_through_agg_preserved (jfunc)))
+      if (agg_pass_through_permissible_p (src_plats, jfunc))
 	{
 	  /* Currently we do not produce clobber aggregate jump
 	     functions, replace with merging when we do.  */
@@ -2893,23 +2904,33 @@  find_aggregate_values_for_callers_subset
 
 	      if (caller_info->ipcp_orig_node)
 		{
-		  if (!inter)
-		    inter = agg_replacements_to_vector (cs->caller, 0);
-		  else
-		    intersect_with_agg_replacements (cs->caller, src_idx,
-						     &inter, 0);
+		  struct cgraph_node *orig_node = caller_info->ipcp_orig_node;
+		  struct ipcp_param_lattices *orig_plats;
+		  orig_plats = ipa_get_parm_lattices (IPA_NODE_REF (orig_node),
+						      src_idx);
+		  if (agg_pass_through_permissible_p (orig_plats, jfunc))
+		    {
+		      if (!inter)
+			inter = agg_replacements_to_vector (cs->caller, 0);
+		      else
+			intersect_with_agg_replacements (cs->caller, src_idx,
+							 &inter, 0);
+		    }
 		}
 	      else
 		{
 		  struct ipcp_param_lattices *src_plats;
 		  src_plats = ipa_get_parm_lattices (caller_info, src_idx);
-		  /* Currently we do not produce clobber aggregate jump
-		     functions, adjust when we do.  */
-		  gcc_checking_assert (!jfunc->agg.items);
-		  if (!inter)
-		    inter = copy_plats_to_inter (src_plats, 0);
-		  else
-		    intersect_with_plats (src_plats, &inter, 0);
+		  if (agg_pass_through_permissible_p (src_plats, jfunc))
+		    {
+		      /* Currently we do not produce clobber aggregate jump
+			 functions, adjust when we do.  */
+		      gcc_checking_assert (!jfunc->agg.items);
+		      if (!inter)
+			inter = copy_plats_to_inter (src_plats, 0);
+		      else
+			intersect_with_plats (src_plats, &inter, 0);
+		    }
 		}
 	    }
 	  else if (jfunc->type == IPA_JF_ANCESTOR
@@ -2933,7 +2954,7 @@  find_aggregate_values_for_callers_subset
 		  src_plats = ipa_get_parm_lattices (caller_info, src_idx);;
 		  /* Currently we do not produce clobber aggregate jump
 		     functions, adjust when we do.  */
-		  gcc_checking_assert (!jfunc->agg.items);
+		  gcc_checking_assert (!src_plats->aggs || !jfunc->agg.items);
 		  if (!inter)
 		    inter = copy_plats_to_inter (src_plats, delta);
 		  else
Index: src/gcc/testsuite/gcc.dg/torture/pr55238.c
===================================================================
--- /dev/null
+++ src/gcc/testsuite/gcc.dg/torture/pr55238.c
@@ -0,0 +1,44 @@ 
+/* { dg-do compile } */
+
+typedef void * gzFile;
+typedef struct
+{
+  int mode;
+  int direct;
+  int seek;
+  int err;
+  char *msg;
+}
+gz_state;
+
+void gz_error (gz_state *state, int err, char *msg);
+
+static void
+gz_reset (gz_state *state)
+{
+  if (state->mode == 7247)
+    {
+      state->direct = 1;
+    }
+  state->seek = 0;
+  gz_error (state, 0, 0);
+}
+
+int
+gzbuffer (void *file, int size)
+{
+  gz_state *state;
+  gz_reset (state);
+}
+
+void __attribute__ ((visibility ("hidden"))) gz_error (gz_state *state, int err, char *msg)
+{
+  if (state->msg != 0)
+    {
+      if (state->err != -4)
+	foo (state->msg);
+    }
+  if (msg == 0)
+    return;
+  bar (state->msg, msg);
+}