This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR44667


On Mon, 28 Jun 2010, Richard Guenther wrote:

> 
> In this PR we end up doing early inlining before local optimizations
> (due to -fprofile-generate).  This makes the following issue more
> likely to appear.
> 
> The issue is that when inlining
> 
> bar (character(kind=1)[2][1:_s] * s, integer(kind=4) _s)
> {
>   character(kind=1)[2][1:_s] * s.0;
>   s.0 = s;  // no conversion needed
> }
> 
> at the call site
> 
>   D.1597 = atmp.4.data;
>   D.1598 = (character(kind=1)[2][1:10] * restrict) D.1597;
>   bar (D.1598, 10);
> 
> we end up replacing the parameter s with
> 
>   character(kind=1)[2][1:_s] * s;
> 
> but the local var with
> 
>   character(kind=1)[2][1:10] * s.0;
> 
> as we map _s to 10 and remap its uses in the types.  But we fail to
> do so for the parameter replacements we added (and we can't do so
> in setup_one_parameter as that's too early).  So the following makes
> sure to remap parameter replacement types by a 2nd loop over all
> parameters.  This results in the expected
> 
>   character(kind=1)[2][1:10] * s;
> 
> and retains the fact that s.0 = s does not need a conversion.
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.

And the following is what actually passed bootstrap & regtest.
We also have to care for already re-mapped SSA names.

Committed as rev. 161527.

Richard.

2010-06-29  Richard Guenther  <rguenther@suse.de>

	PR middle-end/44667
	* tree-inline.c (initialize_inlined_parameters): Make sure
	to remap the inlined parameter variable substitutions types.

Index: gcc/tree-inline.c
===================================================================
*** gcc/tree-inline.c	(revision 161522)
--- gcc/tree-inline.c	(working copy)
*************** initialize_inlined_parameters (copy_body
*** 2642,2647 ****
--- 2642,2673 ----
        val = i < gimple_call_num_args (stmt) ? gimple_call_arg (stmt, i) : NULL;
        setup_one_parameter (id, p, val, fn, bb, &vars);
      }
+   /* After remapping parameters remap their types.  This has to be done
+      in a second loop over all parameters to appropriately remap
+      variable sized arrays when the size is specified in a
+      parameter following the array.  */
+   for (p = parms, i = 0; p; p = TREE_CHAIN (p), i++)
+     {
+       tree *varp = (tree *) pointer_map_contains (id->decl_map, p);
+       if (varp
+ 	  && TREE_CODE (*varp) == VAR_DECL)
+ 	{
+ 	  tree def = (gimple_in_ssa_p (cfun)
+ 		      ? gimple_default_def (id->src_cfun, p) : NULL);
+ 	  TREE_TYPE (*varp) = remap_type (TREE_TYPE (*varp), id);
+ 	  /* Also remap the default definition if it was remapped
+ 	     to the default definition of the parameter replacement
+ 	     by the parameter setup.  */
+ 	  if (def && gimple_in_ssa_p (cfun) && is_gimple_reg (p))
+ 	    {
+ 	      tree *defp = (tree *) pointer_map_contains (id->decl_map, def);
+ 	      if (defp
+ 		  && TREE_CODE (*defp) == SSA_NAME
+ 		  && SSA_NAME_VAR (*defp) == *varp)
+ 		TREE_TYPE (*defp) = TREE_TYPE (*varp);
+ 	    }
+ 	}
+     }
  
    /* Initialize the static chain.  */
    p = DECL_STRUCT_FUNCTION (fn)->static_chain_decl;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]