public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/111914] ICE with function pointer array as argument with non-constant size
Date: Mon, 23 Oct 2023 11:08:18 +0000	[thread overview]
Message-ID: <bug-111914-4-pMFz4MHL92@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111914-4@http.gcc.gnu.org/bugzilla/>

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.

  parent reply	other threads:[~2023-10-23 11:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-22  2:23 [Bug c/111914] New: GCC: 14: ICE when function pointer array as arguments 141242068 at smail dot nju.edu.cn
2023-10-22  2:31 ` [Bug c/111914] ICE with function pointer array as argument with non-constant size pinskia at gcc dot gnu.org
2023-10-23  9:17 ` [Bug ipa/111914] " rguenth at gcc dot gnu.org
2023-10-23 11:08 ` rguenth at gcc dot gnu.org [this message]
2023-10-23 11:29 ` rguenth at gcc dot gnu.org
2023-10-23 13:33 ` cvs-commit at gcc dot gnu.org
2023-10-23 13:33 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111914-4-pMFz4MHL92@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).