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 lto/96591] [8/9/10/11 Regression] ICE with -flto=auto and -O1: tree code ‘typename_type’ is not supported in LTO streams
Date: Mon, 08 Feb 2021 08:45:33 +0000	[thread overview]
Message-ID: <bug-96591-4-nPl0MfGqzA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96591-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the type is refered to by constant 8 which is refered to by a VECTOR_CST
{ 8 } which is refered to by

# .MEM_4 = VDEF <.MEM_2>
MEM[(struct Test *)_3].data[0] = { 8 };

and while walk_tree walks CTOR elements for VECTOR_CST it does nothing:

  switch (code)
    {
    case ERROR_MARK:
    case IDENTIFIER_NODE:
    case INTEGER_CST:
    case REAL_CST:
    case FIXED_CST:
    case VECTOR_CST:
    case STRING_CST:
    case BLOCK:
    case PLACEHOLDER_EXPR:
    case SSA_NAME:
    case FIELD_DECL:
    case RESULT_DECL:
      /* None of these have subtrees other than those already walked
         above.  */
      break;

which is eventually true since we expect the element type of a VECTOR_CST
to match that of the vector element type.  _But_ - we're forcing a vector
element type to be the main variant / canonical type:

 <vector_cst 0x7ffff66d9c30
    type <vector_type 0x7ffff66dedc8
        type <integer_type 0x7ffff65885e8 int public type_6 SI
            size <integer_cst 0x7ffff658b108 constant 32>
            unit-size <integer_cst 0x7ffff658b120 constant 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set 2 canonical-type
0x7ffff65885e8 precision:32 min <integer_cst 0x7ffff658b0c0 -2147483648> max
<integer_cst 0x7ffff658b0d8 2147483647>
            pointer_to_this <pointer_type 0x7ffff65909d8>>
        type_6 SI size <integer_cst 0x7ffff658b108 32> unit-size <integer_cst
0x7ffff658b120 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff66dedc8 nunits:1>
    constant npatterns:1 nelts-per-pattern:1
    elt:0:  <integer_cst 0x7ffff66d9be8 type <integer_type 0x7ffff66de3f0
scalar_type> constant 8>>
(gdb) p ((tree)0x7ffff66de3f0)->type_common.canonical 
$134 = <integer_type 0x7ffff65885e8 int>
(gdb) p ((tree)0x7ffff66de3f0)->type_common.main_variant 
$135 = <integer_type 0x7ffff65885e8 int>

where we build this via

#0  0x0000000001cf4437 in tree_vector_builder::build (this=0x7fffffffbfe0)
    at /home/rguenther/src/gcc3/gcc/tree-vector-builder.c:44
#1  0x0000000001d112c9 in build_vector_from_ctor (
    type=<vector_type 0x7ffff66dedc8>, v=0x7ffff66e72d0 = {...})
    at /home/rguenther/src/gcc3/gcc/tree.c:1969
#2  0x00000000012cccda in fold (expr=<constructor 0x7ffff66d9c18>)
    at /home/rguenther/src/gcc3/gcc/fold-const.c:13383
#3  0x0000000000b0b893 in cxx_eval_bare_aggregate (ctx=0x7fffffffc290, 
    t=<constructor 0x7ffff66d9c18>, lval=false, non_constant_p=0x7fffffffd1bf, 
    overflow_p=0x7fffffffd1be)
    at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:4438
#4  0x0000000000b14c6b in cxx_eval_constant_expression (ctx=0x7fffffffc610, 
    t=<constructor 0x7ffff66d9bd0>, lval=false, non_constant_p=0x7fffffffd1bf, 
    overflow_p=0x7fffffffd1be, jump_target=0x0)
    at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:6591

it's tempting to try force the cached integer constants to be always
unqualified so that only the TYPE_MAIN_VARIANT has TYPE_CACHED_VALUES
and we save memory.  The constant is built via

(gdb) bt
#0  0x0000000001d0fcf1 in cache_wide_int_in_type_cache (
    type=<integer_type 0x7ffff66de3f0 scalar_type>, cst=..., slot=9, 
    max_slots=252) at /home/rguenther/src/gcc3/gcc/tree.c:1535
#1  0x0000000001d1020d in wide_int_to_tree_1 (
    type=<integer_type 0x7ffff66de3f0 scalar_type>, pcst=...)
    at /home/rguenther/src/gcc3/gcc/tree.c:1649
#2  0x0000000001d10878 in wide_int_to_tree (
    type=<integer_type 0x7ffff66de3f0 scalar_type>, value=...)
    at /home/rguenther/src/gcc3/gcc/tree.c:1756
#3  0x0000000001d0f918 in force_fit_type (
    type=<integer_type 0x7ffff66de3f0 scalar_type>, cst=..., overflowable=1, 
    overflowed=false) at /home/rguenther/src/gcc3/gcc/tree.c:1474
#4  0x00000000012969cb in fold_convert_const_int_from_int (
    type=<integer_type 0x7ffff66de3f0 scalar_type>, 
    arg1=<integer_cst 0x7ffff66d9618>)
    at /home/rguenther/src/gcc3/gcc/fold-const.c:2000
#5  0x00000000012988b6 in fold_convert_const (code=NOP_EXPR, 
    type=<integer_type 0x7ffff66de3f0 scalar_type>, 
    arg1=<integer_cst 0x7ffff66d9618>)
    at /home/rguenther/src/gcc3/gcc/fold-const.c:2276
#6  0x0000000001299214 in fold_convert_loc (loc=0, 
    type=<integer_type 0x7ffff66de3f0 scalar_type>, 
    arg=<integer_cst 0x7ffff66d9618>)
--Type <RET> for more, q to quit, c to continue without paging--
    at /home/rguenther/src/gcc3/gcc/fold-const.c:2418
#7  0x0000000000b714fa in cp_fold_convert (
    type=<integer_type 0x7ffff66de3f0 scalar_type>, 
    expr=<integer_cst 0x7ffff66d9618>)
    at /home/rguenther/src/gcc3/gcc/cp/cvt.c:629
#8  0x0000000000aff0d3 in adjust_temp_type (
    type=<integer_type 0x7ffff66de888 scalar_type>, 
    temp=<integer_cst 0x7ffff66d9618>)
    at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:1501
#9  0x0000000000aff651 in cxx_bind_parameters_in_call (ctx=0x7fffffffd0a0, 
    t=<call_expr 0x7ffff6577150>, new_call=0x7fffffffccc0, 
    non_constant_p=0x7fffffffd1bf, overflow_p=0x7fffffffd1be, 
    non_constant_args=0x7fffffffcc7f)
    at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:1611
#10 0x0000000000b0404c in cxx_eval_call_expression (ctx=0x7fffffffd0a0, 
    t=<call_expr 0x7ffff6577150>, lval=false, non_constant_p=0x7fffffffd1bf, 
    overflow_p=0x7fffffffd1be)
    at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:2536
#11 0x0000000000b13215 in cxx_eval_constant_expression (ctx=0x7fffffffd0a0, 
    t=<call_expr 0x7ffff6577150>, lval=false, non_constant_p=0x7fffffffd1bf, 
    overflow_p=0x7fffffffd1be, jump_target=0x0)
    at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:6134

where the constant is first built in the "correct" type and then
converted via adjust_temp_type which does

1499      /* Now we know we're dealing with a scalar, and a prvalue of
non-class
1500         type is cv-unqualified.  */
1501      return cp_fold_convert (cv_unqualified (type), temp);

but that cv_unqualified doesn't produce the main variant.

Now, as a fact walk_tree _does_ walk COMPLEX_CST components so the "obvious"
fix here would be to change it to also walk VECTOR_CST components.  So that's
what I'm going to try first.

  parent reply	other threads:[~2021-02-08  8:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 15:58 [Bug lto/96591] New: " gcc-bugs at marehr dot dialup.fu-berlin.de
2020-08-12 17:05 ` [Bug lto/96591] " marxin at gcc dot gnu.org
2020-08-25  9:27 ` [Bug c++/96591] [8/9/10/11 Regression] " rguenth at gcc dot gnu.org
2020-08-25 12:12 ` jakub at gcc dot gnu.org
2020-08-26  5:20 ` asolokha at gmx dot com
2020-10-12 12:34 ` rguenth at gcc dot gnu.org
2021-02-04 21:03 ` jason at gcc dot gnu.org
2021-02-06  6:20 ` [Bug lto/96591] " jason at gcc dot gnu.org
2021-02-08  7:47 ` rguenth at gcc dot gnu.org
2021-02-08  8:45 ` rguenth at gcc dot gnu.org [this message]
2021-02-08 12:05 ` cvs-commit at gcc dot gnu.org
2021-02-08 12:06 ` [Bug lto/96591] [8/9/10 " rguenth at gcc dot gnu.org
2021-03-24 14:26 ` cvs-commit at gcc dot gnu.org
2021-04-12 11:23 ` [Bug lto/96591] [8/9 " cvs-commit at gcc dot gnu.org
2021-04-26 10:46 ` [Bug lto/96591] [8 " cvs-commit at gcc dot gnu.org
2021-04-26 10:48 ` 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-96591-4-nPl0MfGqzA@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).