https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111914

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is we do

setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn,
                     basic_block bb, tree *vars)
...
  /* Make an equivalent VAR_DECL.  Note that we must NOT remap the type
     here since the type of this decl must be visible to the calling
     function.  */
  var = copy_decl_to_var (p, id);
...
          else if (!optimize)
            {
              def = make_ssa_name (var);
              init_stmt = gimple_build_assign (def, rhs);

but then

static void
initialize_inlined_parameters (copy_body_data *id, gimple *stmt,
                               tree fn, basic_block bb)
...
  /* 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 = DECL_CHAIN (p), i++)
    {
      tree *varp = id->decl_map->get (p);
      if (varp && VAR_P (*varp))
        {
          tree def = (gimple_in_ssa_p (cfun) && is_gimple_reg (p)
                      ? ssa_default_def (id->src_cfun, p) : NULL);
          tree var = *varp;
          TREE_TYPE (var) = remap_type (TREE_TYPE (var), id);
          /* Also remap the default definition if it was remapped
             to the default definition of the parameter replacement
             by the parameter setup.  */
          if (def)
            {
              tree *defp = id->decl_map->get (def);
              if (defp
                  && TREE_CODE (*defp) == SSA_NAME
                  && SSA_NAME_VAR (*defp) == var)
                TREE_TYPE (*defp) = TREE_TYPE (var);

but we never adjust the type of the SSA names we create during initial
parameter setup.  We have special handling for the default def but
not for the (dead?!) stmt we emit when !optimize.  It says

      /* If we are in SSA form properly remap the default definition
         or assign to a dummy SSA name if the parameter is unused and
         we are not optimizing.  */

so that seems to be on purpose but it's broken.

Reply via email to