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/113520] ICE with mismatched types with LTO (tree check: expected array_type, have integer_type in array_ref_low_bound)
Date: Mon, 22 Jan 2024 09:38:48 +0000	[thread overview]
Message-ID: <bug-113520-4-TIkHbmR045@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113520-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-01-22
          Component|tree-optimization           |ipa
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |jamborm at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
           Keywords|                            |lto

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, we are supposed to "handle" this during in-streaming.  This seems to work
but then for some reason it gets fiddled with again...

Ah, so this is reading of IPA CP summaries where it seems that we do not
apply these "tricks", gimple-streamer-out.cc has

          /* Wrap all uses of non-automatic variables inside MEM_REFs
             so that we do not have to deal with type mismatches on
             merged symbols during IL read in.  The first operand
             of GIMPLE_DEBUG must be a decl, not MEM_REF, though.  */
          if (!flag_wpa && op && (i || !is_gimple_debug (stmt)))
            {
              basep = &op;
              if (TREE_CODE (*basep) == ADDR_EXPR)
                basep = &TREE_OPERAND (*basep, 0);
              while (handled_component_p (*basep))
                basep = &TREE_OPERAND (*basep, 0);
              if (VAR_P (*basep)
                  && !auto_var_in_fn_p (*basep, fn->decl)
                  && !DECL_REGISTER (*basep)) 
                {
                  bool volatilep = TREE_THIS_VOLATILE (*basep);
                  tree ptrtype = build_pointer_type (TREE_TYPE (*basep));
                  *basep = build2 (MEM_REF, TREE_TYPE (*basep),
                                   build1 (ADDR_EXPR, ptrtype, *basep),
                                   build_int_cst (ptrtype, 0));
                  TREE_THIS_VOLATILE (*basep) = volatilep;
...

and gimple-streamer-in.cc undoes this when the prevailing decls are compatible:

          /* At LTO output time we wrap all global decls in MEM_REFs to
             allow seamless replacement with prevailing decls.  Undo this
             here if the prevailing decl allows for this.
             ???  Maybe we should simply fold all stmts.  */
          if (TREE_CODE (*opp) == MEM_REF
              && TREE_CODE (TREE_OPERAND (*opp, 0)) == ADDR_EXPR
              && integer_zerop (TREE_OPERAND (*opp, 1))
              && (TREE_THIS_VOLATILE (*opp)
                  == TREE_THIS_VOLATILE
                       (TREE_OPERAND (TREE_OPERAND (*opp, 0), 0)))
              && !TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (*opp, 1)))
              && (TREE_TYPE (*opp)
                  == TREE_TYPE (TREE_TYPE (TREE_OPERAND (*opp, 1))))
              && (TREE_TYPE (*opp)
                  == TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*opp, 0), 0))))
            *opp = TREE_OPERAND (TREE_OPERAND (*opp, 0), 0);

I suppose we might want to split these out so summary streaming can apply
this to streamed trees as well?

  parent reply	other threads:[~2024-01-22  9:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-20  6:18 [Bug tree-optimization/113520] New: ICE when building swi-prolog-9.1.2 " sjames at gcc dot gnu.org
2024-01-20  6:19 ` [Bug tree-optimization/113520] " sjames at gcc dot gnu.org
2024-01-20  6:21 ` pinskia at gcc dot gnu.org
2024-01-20  6:23 ` pinskia at gcc dot gnu.org
2024-01-20  6:35 ` sjames at gcc dot gnu.org
2024-01-20  6:36 ` pinskia at gcc dot gnu.org
2024-01-22  9:38 ` rguenth at gcc dot gnu.org [this message]
2024-01-22  9:40 ` [Bug ipa/113520] ICE with mismatched types " rguenth at gcc dot gnu.org
2024-01-24 15:51 ` hubicka at gcc dot gnu.org
2024-01-25  7:34 ` 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-113520-4-TIkHbmR045@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).