public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
@ 2021-10-11 10:50 marxin at gcc dot gnu.org
  2021-10-11 10:50 ` [Bug target/102683] " marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-11 10:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102683
           Summary: [12 Regression] ICE in
                    set_min_and_max_values_for_integral_type, at
                    stor-layout.c:2851
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: qing.zhao at oracle dot com
  Target Milestone: ---
              Host: x86_64-linux-gnu
            Target: riscv64-unknown-linux-gnu

The following fails:

$ riscv64-linux-gnu-gcc
/home/marxin/Programming/gcc/gcc/testsuite/g++.dg/other/complex1.C -Og
-ftrivial-auto-var-init=pattern
during RTL pass: expand
/home/marxin/Programming/gcc/gcc/testsuite/g++.dg/other/complex1.C: In function
‘void foo()’:
/home/marxin/Programming/gcc/gcc/testsuite/g++.dg/other/complex1.C:19:5:
internal compiler error: in set_min_and_max_values_for_integral_type, at
stor-layout.c:2851
   19 |   C y = (n==1) ? x : (C){3+3i};
      |     ^
0x6185b6 set_min_and_max_values_for_integral_type(tree_node*, int, signop)
       
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-riscv64/build/gcc/stor-layout.c:2851
0xcb2e2b fixup_unsigned_type(tree_node*)
       
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-riscv64/build/gcc/stor-layout.c:2885
0xf32cd8 build_nonstandard_integer_type(unsigned long, int)
       
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-riscv64/build/gcc/tree.c:6976
0xa822c9 expand_DEFERRED_INIT
       
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-riscv64/build/gcc/internal-fn.c:3058
0x8b6bc7 expand_call_stmt
       
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-riscv64/build/gcc/cfgexpand.c:2749
0x8b6bc7 expand_gimple_stmt_1
       
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-riscv64/build/gcc/cfgexpand.c:3876
0x8b6bc7 expand_gimple_stmt
       
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-riscv64/build/gcc/cfgexpand.c:4040
0x8bb3d2 expand_gimple_basic_block
       
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-riscv64/build/gcc/cfgexpand.c:6082
0x8bd216 execute
       
/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-riscv64/build/gcc/cfgexpand.c:6808
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/102683] [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-10-11 10:50 [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 marxin at gcc dot gnu.org
@ 2021-10-11 10:50 ` marxin at gcc dot gnu.org
  2021-10-11 10:55 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-11 10:50 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |rguenth at gcc dot gnu.org
   Target Milestone|---                         |12.0
   Last reconfirmed|                            |2021-10-11

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/102683] [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-10-11 10:50 [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 marxin at gcc dot gnu.org
  2021-10-11 10:50 ` [Bug target/102683] " marxin at gcc dot gnu.org
@ 2021-10-11 10:55 ` rguenth at gcc dot gnu.org
  2021-10-11 12:29 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-11 10:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
That likely means the target lacks an integer mode covering the mode of the
type to be initialized ... :/  I see the target only defines TFmode so
eventually
it has CTFmode but not OImode.  We have

struct C {
  __complex__ long double c;
};

void foo()
{
  C x = {2+2i};

  int n = 1;
  C y = (n==1) ? x : (C){3+3i};
  if (__imag__ y.c != 2)
    abort ();
}

(not sure why we get .DEFERRED_INIT here)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/102683] [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-10-11 10:50 [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 marxin at gcc dot gnu.org
  2021-10-11 10:50 ` [Bug target/102683] " marxin at gcc dot gnu.org
  2021-10-11 10:55 ` rguenth at gcc dot gnu.org
@ 2021-10-11 12:29 ` rguenth at gcc dot gnu.org
  2021-10-11 12:31 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-11 12:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, a riscv-linux cc1 ICEs with

> ./cc1 -quiet t.i -I include -O
<built-in>: internal compiler error: Segmentation fault
0x132b5fa crash_signal
        /home/rguenther/src/trunk/gcc/toplev.c:326
0x18e4864 riscv_subset_list::begin() const
        /home/rguenther/src/trunk/gcc/config/riscv/riscv-subset.h:89
0x18e46e1 riscv_cpu_cpp_builtins(cpp_reader*)
        /home/rguenther/src/trunk/gcc/config/riscv/riscv-c.c:114
0xb694bc c_cpp_builtins(cpp_reader*)
        /home/rguenther/src/trunk/gcc/c-family/c-cppbuiltin.c:1578
0xb9634d c_finish_options
        /home/rguenther/src/trunk/gcc/c-family/c-opts.c:1486
0xb95b7c c_common_parse_file()
        /home/rguenther/src/trunk/gcc/c-family/c-opts.c:1231
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Program received signal SIGSEGV, Segmentation fault.
0x00000000018e4864 in riscv_subset_list::begin (this=0x0)
    at /home/rguenther/src/trunk/gcc/config/riscv/riscv-subset.h:89
89        const riscv_subset_t *begin () const {return m_head;};

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/102683] [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-10-11 10:50 [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 marxin at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-10-11 12:29 ` rguenth at gcc dot gnu.org
@ 2021-10-11 12:31 ` rguenth at gcc dot gnu.org
  2021-10-11 12:49 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-11 12:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Otherwise the following would likely fix it:

diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index 6bc256832f7..b3638192fb9 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -3074,7 +3074,9 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt)
       tree init;
       if (tree_fits_uhwi_p (var_size)
          && (init_type == AUTO_INIT_PATTERN
-             || !is_gimple_reg_type (var_type)))
+             || !is_gimple_reg_type (var_type))
+         && int_mode_for_size (tree_to_uhwi (var_size) * BITS_PER_UNIT,
+                               0).exists ())
        {
          unsigned HOST_WIDE_INT total_bytes = tree_to_uhwi (var_size);
          unsigned char *buf = (unsigned char *) xmalloc (total_bytes);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/102683] [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-10-11 10:50 [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 marxin at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-10-11 12:31 ` rguenth at gcc dot gnu.org
@ 2021-10-11 12:49 ` rguenth at gcc dot gnu.org
  2021-10-11 14:41 ` qing.zhao at oracle dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-11 12:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Now, for some reason we initialize 'y' which is clearly not necessary:

      y = .DEFERRED_INIT (32, 2, 0);
      if (n == 1) goto <D.1920>; else goto <D.1921>;
      <D.1920>:
      y = x;
      goto <D.1922>;
      <D.1921>:
      y = *.LC1;
      <D.1922>:

and the suggested patch fixes the ICE during expansion.  But we should avoid
the .DEFERRED_INIT here.  The GENERIC is

    struct C y;
  <<cleanup_point <<< Unknown tree: expr_stmt
  (void) (y = n == 1 ? TARGET_EXPR <D.1917, x> : TARGET_EXPR <D.1916,
{.c=__complex__ (3.0e+0, 3.0e+0)}>) >>>>>;

so we have first

        stmt <decl_expr 0x7ffff6666da0 type <void_type 0x7ffff6558f18 void>
            side-effects arg:0 <var_decl 0x7ffff7ff52d0 y>
            t.i:10:5 start: t.i:10:5 finish: t.i:10:5>

and then

        stmt <cleanup_point_expr 0x7ffff6666e00 type <void_type 0x7ffff6558f18
void>
            side-effects
            arg:0 <expr_stmt 0x7ffff6666de0 type <void_type 0x7ffff6558f18
void>
                side-effects
                arg:0 <convert_expr 0x7ffff6666dc0 type <void_type
0x7ffff6558f18 void>
                    side-effects
                    arg:0 <init_expr 0x7ffff66810a0 type <record_type
0x7ffff6663d20 C>
                        side-effects arg:0 <var_decl 0x7ffff7ff52d0 y>
                        arg:1 <cond_expr 0x7ffff66772d0 type <record_type
0x7ffff6663d20 C>
...

so this is an INIT_EXPR which never(?) requires .DEFERRED_INIT?  Of course
we're instrumenting the DECL_EXPR, not the INIT_EXPR and at that point
we didn't see the INIT_EXPR.

I wonder if we want a bit on DECL_EXPR denoting whether the decl is
fully initialized?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/102683] [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-10-11 10:50 [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 marxin at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-10-11 12:49 ` rguenth at gcc dot gnu.org
@ 2021-10-11 14:41 ` qing.zhao at oracle dot com
  2021-10-11 14:42 ` cvs-commit at gcc dot gnu.org
  2021-10-11 14:42 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: qing.zhao at oracle dot com @ 2021-10-11 14:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Qing Zhao <qing.zhao at oracle dot com> ---
> --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
> But we should avoid
> the .DEFERRED_INIT here.  The GENERIC is
> 
>    struct C y;
>  <<cleanup_point <<< Unknown tree: expr_stmt
>  (void) (y = n == 1 ? TARGET_EXPR <D.1917, x> : TARGET_EXPR <D.1916,
> {.c=__complex__ (3.0e+0, 3.0e+0)}>) >>>>>;
> 
> so we have first
> 
>        stmt <decl_expr 0x7ffff6666da0 type <void_type 0x7ffff6558f18 void>
>            side-effects arg:0 <var_decl 0x7ffff7ff52d0 y>
>            t.i:10:5 start: t.i:10:5 finish: t.i:10:5>
> 
> and then
> 
>        stmt <cleanup_point_expr 0x7ffff6666e00 type <void_type 0x7ffff6558f18
> void>
>            side-effects
>            arg:0 <expr_stmt 0x7ffff6666de0 type <void_type 0x7ffff6558f18
> void>
>                side-effects
>                arg:0 <convert_expr 0x7ffff6666dc0 type <void_type
> 0x7ffff6558f18 void>
>                    side-effects
>                    arg:0 <init_expr 0x7ffff66810a0 type <record_type
> 0x7ffff6663d20 C>
>                        side-effects arg:0 <var_decl 0x7ffff7ff52d0 y>
>                        arg:1 <cond_expr 0x7ffff66772d0 type <record_type
> 0x7ffff6663d20 C>
> ...
> 
> so this is an INIT_EXPR which never(?) requires .DEFERRED_INIT?  Of course
> we're instrumenting the DECL_EXPR, not the INIT_EXPR and at that point
> we didn't see the INIT_EXPR.

Currently, in simplification phase, for each DECL_EXPR, we check:

  if (VAR_P (decl) && !DECL_EXTERNAL (decl))
    {
      tree init = DECL_INITIAL (decl);

      If (!init. && is_var_need_auto_init (decl))
        gimple_add_init_for_auto_var (decl…)


We assume that FE will put the explicit initializer of a DECL to its
DECL_INITIAL. 
Clearly for this testing case, this is not the case.

I am wondering why FE does not put the initializer of this DECL to its
DECL_INITIAL for this case?

> 
> I wonder if we want a bit on DECL_EXPR denoting whether the decl is
> fully initialized?

Yes, if FE can mark this bit, it will be easier and simpler for the
implementation.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/102683] [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-10-11 10:50 [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 marxin at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-10-11 14:41 ` qing.zhao at oracle dot com
@ 2021-10-11 14:42 ` cvs-commit at gcc dot gnu.org
  2021-10-11 14:42 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-11 14:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:338725652f84793805c55f08a7607c2f45d5512b

commit r12-4320-g338725652f84793805c55f08a7607c2f45d5512b
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Oct 11 14:31:59 2021 +0200

    middle-end/102683 - fix .DEFERRED_INIT expansion

    This avoids using an integer type for which we don't have an
    approprate mode when expanding .DEFERRED_INIT to a non-memory
    entity.

    2021-10-11  Richard Biener  <rguenther@suse.de>

            PR middle-end/102683
            * internal-fn.c (expand_DEFERRED_INIT): Check for mode
            availability before building an integer type for storage
            purposes.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/102683] [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851
  2021-10-11 10:50 [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 marxin at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-10-11 14:42 ` cvs-commit at gcc dot gnu.org
@ 2021-10-11 14:42 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-11 14:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
The ICE should be fixed (the unnnecessary .DEFERRED_INIT is not, but that
should eventually get a different bug).

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-10-11 14:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 10:50 [Bug target/102683] New: [12 Regression] ICE in set_min_and_max_values_for_integral_type, at stor-layout.c:2851 marxin at gcc dot gnu.org
2021-10-11 10:50 ` [Bug target/102683] " marxin at gcc dot gnu.org
2021-10-11 10:55 ` rguenth at gcc dot gnu.org
2021-10-11 12:29 ` rguenth at gcc dot gnu.org
2021-10-11 12:31 ` rguenth at gcc dot gnu.org
2021-10-11 12:49 ` rguenth at gcc dot gnu.org
2021-10-11 14:41 ` qing.zhao at oracle dot com
2021-10-11 14:42 ` cvs-commit at gcc dot gnu.org
2021-10-11 14:42 ` rguenth at gcc dot gnu.org

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).