public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed
@ 2021-11-23 18:57 gscfq@t-online.de
  2021-11-24  8:38 ` [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327 marxin at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: gscfq@t-online.de @ 2021-11-23 18:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103390
           Summary: [12 Regression] ICE: gimplification failed
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Changed between 20211017 and 20211024 :
(ok without bind(c))


$ cat z1.f90
program p
   integer, pointer :: z(:)
   integer, target :: x(3) = [1, 2, 3]
   z => x
   call s(shape(z))
contains
   subroutine s(x) bind(c)
      integer, contiguous :: x(:)
   end
end


$ gfortran-12-20211017 -c z1.f90
$
$ gfortran-12-20211121 -c z1.f90
gimplification failed:
(integer(kind=4)) _33 <nop_expr 0x7f16948401a0
    type <integer_type 0x7f169465a5e8 integer(kind=4) sizes-gimplified public
SI
        size <integer_cst 0x7f1694643e40 constant 32>
        unit-size <integer_cst 0x7f1694643e58 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set 3 canonical-type
0x7f169465a5e8 precision:32 min <integer_cst 0x7f1694643df8 -2147483648> max
<integer_cst 0x7f1694643e10 2147483647>
        pointer_to_this <pointer_type 0x7f1694662a80>>

    arg:0 <ssa_name 0x7f169444c1b0
        type <integer_type 0x7f169483ce70 public unsigned SI size <integer_cst
0x7f1694643e40 32> unit-size <integer_cst 0x7f1694643e58 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7f169483ce70 precision:32 min <integer_cst 0x7f1694828bd0 0> max <integer_cst
0x7f1694828558 4294967295>>

        def_stmt _33 = _32 + 1;
        version:33>
    z1.f90:5:19 start: z1.f90:5:19 finish: z1.f90:5:19>
z1.f90:5:19:

    5 |    call s(shape(z))
      |                   ^
internal compiler error: gimplification failed
0xbdad08 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:15679
0xbe91bb gimplify_modify_expr
        ../../gcc/gimplify.c:5973
0xbd9aa7 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:14666
0xbddd78 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:7024
0xbd93db gimplify_statement_list
        ../../gcc/gimplify.c:2012
0xbd93db gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:15111
0xbddd78 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:7024
0xbd974c gimplify_and_add(tree_node*, gimple**)
        ../../gcc/gimplify.c:494
0xbd974c gimplify_loop_expr
        ../../gcc/gimplify.c:1986
0xbd974c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:14871
0xbddd78 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:7024
0xbd93db gimplify_statement_list
        ../../gcc/gimplify.c:2012
0xbd93db gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:15111
0xbddd78 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:7024
0xbde713 gimplify_bind_expr
        ../../gcc/gimplify.c:1426
0xbda08a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:14867
0xbddd78 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:7024
0xbe4780 gimplify_cond_expr
        ../../gcc/gimplify.c:4393
0xbda65f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.c:14623
0xbddd78 gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.c:7024

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
@ 2021-11-24  8:38 ` marxin at gcc dot gnu.org
  2021-11-24  8:53 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-24  8:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12 Regression] ICE:        |[12 Regression] ICE:
                   |gimplification failed       |gimplification failed since
                   |                            |r12-4591-g1af78e731feb9327
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-11-24
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |sandra at codesourcery dot com
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-4591-g1af78e731feb9327.

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
  2021-11-24  8:38 ` [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327 marxin at gcc dot gnu.org
@ 2021-11-24  8:53 ` rguenth at gcc dot gnu.org
  2021-12-14  1:44 ` sandra at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-24  8:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
           Priority|P3                          |P4

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
  2021-11-24  8:38 ` [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327 marxin at gcc dot gnu.org
  2021-11-24  8:53 ` rguenth at gcc dot gnu.org
@ 2021-12-14  1:44 ` sandra at gcc dot gnu.org
  2021-12-14  1:47 ` sandra at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-12-14  1:44 UTC (permalink / raw)
  To: gcc-bugs

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

sandra at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |sandra at gcc dot gnu.org

--- Comment #2 from sandra at gcc dot gnu.org ---
It looks to me like this is due to a collision between my patch to re-do the
SHAPE intrinsic (commit 1af78e731feb9327a17c99ebaa19a4cca1125caf) and Tobias's
big patch to completely reimplement CFI descriptor conversion (commit
64f9623765da3306b0ab6a47997dc5d62c2ea261) and the copy-in/copy-out for array
parameters with the CONTIGUOUS attribute.  

I think the thing the gimplifier is crashing on is this assignment that appears
in the copy-out loop after the call to s:

              (integer(kind=4)) (((unsigned int) z.dim[S.3].ubound - (unsigned
int) z.dim[S.3].lbound) + 1) = (*(integer(kind=4)[1] * restrict)
atmp.0.data)[S.3 + D.4263];

The left-hand side of the assignment is not an lvalue because of the nop_expr.

Besides fixing the bug, it would be good if we could make it smart enough not
to generate the copy-in/copy-out loops at all because it knows perfectly well
that the temporary holding the result of the SHAPE intrinsic is already
contiguous!

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-12-14  1:44 ` sandra at gcc dot gnu.org
@ 2021-12-14  1:47 ` sandra at gcc dot gnu.org
  2021-12-30 19:30 ` sandra at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-12-14  1:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from sandra at gcc dot gnu.org ---
Created attachment 51994
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51994&action=edit
-fdump-tree-original output from test case

Here's the full output from -fdump-tree-original for the test case.

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2021-12-14  1:47 ` sandra at gcc dot gnu.org
@ 2021-12-30 19:30 ` sandra at gcc dot gnu.org
  2022-01-01 23:10 ` sandra at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-12-30 19:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from sandra at gcc dot gnu.org ---
I thought I had a fix for this that involved making gfc_is_simply_contiguous
smarter about intrinsics and other function calls, but after writing more test
cases I found that this one still ICEs.

program p
   integer, pointer :: z(:)
   integer :: a(3) = [1, 2, 3];
   integer :: b(3) = [4, 5, 6];
   call s(a + b);
contains
   subroutine s(x) bind(c)
      integer, contiguous :: x(:)
   end
end

Tobias's other suggestion to me was gating the copy-out code with
gfc_expr_is_variable() so I'll try that next.

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2021-12-30 19:30 ` sandra at gcc dot gnu.org
@ 2022-01-01 23:10 ` sandra at gcc dot gnu.org
  2022-01-02 18:37 ` sandra at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sandra at gcc dot gnu.org @ 2022-01-01 23:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from sandra at gcc dot gnu.org ---
Created attachment 52107
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52107&action=edit
-fdump-tree-original output from second test case

Well, this is nuts.  Unmodified code is generating 3 copies of the loop to
compute "a + b" in the previous example, as well as the invalid copy-out code.

I've got a patch to fix this now, just doing a few more experiments with it.

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-01-01 23:10 ` sandra at gcc dot gnu.org
@ 2022-01-02 18:37 ` sandra at gcc dot gnu.org
  2022-01-03 11:58 ` antony at cosmologist dot info
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sandra at gcc dot gnu.org @ 2022-01-02 18:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from sandra at gcc dot gnu.org ---
Patch posted:

https://gcc.gnu.org/pipermail/fortran/2022-January/057249.html

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2022-01-02 18:37 ` sandra at gcc dot gnu.org
@ 2022-01-03 11:58 ` antony at cosmologist dot info
  2022-01-03 16:48 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: antony at cosmologist dot info @ 2022-01-03 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Antony Lewis <antony at cosmologist dot info> ---
I see similar error in another fortran code, full trace in
https://app.travis-ci.com/github/cmbant/CosmoMC/jobs/552809686

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2022-01-03 11:58 ` antony at cosmologist dot info
@ 2022-01-03 16:48 ` cvs-commit at gcc dot gnu.org
  2022-01-03 17:01 ` sandra at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-03 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sandra Loosemore <sandra@gcc.gnu.org>:

https://gcc.gnu.org/g:6447f6f983ffeaecb8753ef685d702bf2594968b

commit r12-6191-g6447f6f983ffeaecb8753ef685d702bf2594968b
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Mon Jan 3 08:47:38 2022 -0800

    Fortran: Fix array copy-in/copy-out for BIND(C) functions [PR103390]

    The Fortran front end was generating invalid code for the array
    copy-out after a call to a BIND(C) function for a dummy with the
    CONTIGUOUS attribute when the actual argument was a call to the SHAPE
    intrinsic or other array expressions that are not lvalues.  It was
    also generating code to evaluate the argument expression multiple
    times on copy-in.  This patch teaches it to recognize that a copy is
    not needed in these cases.

    2022-01-03  Sandra Loosemore  <sandra@codesourcery.com>

            PR fortran/103390

            gcc/fortran/
            * expr.c (gfc_is_simply_contiguous): Make it smarter about
            function calls.
            * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Do not generate
            copy loops for array expressions that are not "variables"
(lvalues).

            gcc/testsuite/
            * gfortran.dg/c-interop/pr103390-1.f90: New.
            * gfortran.dg/c-interop/pr103390-2.f90: New.
            * gfortran.dg/c-interop/pr103390-3.f90: New.
            * gfortran.dg/c-interop/pr103390-4.f90: New.
            * gfortran.dg/c-interop/pr103390-6.f90: New.
            * gfortran.dg/c-interop/pr103390-7.f90: New.
            * gfortran.dg/c-interop/pr103390-8.f90: New.
            * gfortran.dg/c-interop/pr103390-9.f90: New.

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
                   ` (8 preceding siblings ...)
  2022-01-03 16:48 ` cvs-commit at gcc dot gnu.org
@ 2022-01-03 17:01 ` sandra at gcc dot gnu.org
  2022-01-03 18:43 ` antony at cosmologist dot info
  2022-01-05 17:05 ` sandra at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: sandra at gcc dot gnu.org @ 2022-01-03 17:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from sandra at gcc dot gnu.org ---
Without a test case, I can't tell if the error in comment 7 was due to this bug
or a different one.  It doesn't really look the same as the other failures I
looked at in this issue, as the source code it's pointing at does not involve a
call to a BIND(C) procedure.  I've pushed the patch now; Antony, can you retry
your build, and work up a test case for a new issue if it still fails in the
same way?

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
                   ` (9 preceding siblings ...)
  2022-01-03 17:01 ` sandra at gcc dot gnu.org
@ 2022-01-03 18:43 ` antony at cosmologist dot info
  2022-01-05 17:05 ` sandra at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: antony at cosmologist dot info @ 2022-01-03 18:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Antony Lewis <antony at cosmologist dot info> ---
I think you are right, it does not seem to fix it.

I made
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103898

(may also be duplicate of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103391)

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

* [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327
  2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
                   ` (10 preceding siblings ...)
  2022-01-03 18:43 ` antony at cosmologist dot info
@ 2022-01-05 17:05 ` sandra at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: sandra at gcc dot gnu.org @ 2022-01-05 17:05 UTC (permalink / raw)
  To: gcc-bugs

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

sandra at gcc dot gnu.org changed:

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

--- Comment #11 from sandra at gcc dot gnu.org ---
Marking this as fixed since we have a new issue for the other bug.

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

end of thread, other threads:[~2022-01-05 17:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 18:57 [Bug fortran/103390] New: [12 Regression] ICE: gimplification failed gscfq@t-online.de
2021-11-24  8:38 ` [Bug fortran/103390] [12 Regression] ICE: gimplification failed since r12-4591-g1af78e731feb9327 marxin at gcc dot gnu.org
2021-11-24  8:53 ` rguenth at gcc dot gnu.org
2021-12-14  1:44 ` sandra at gcc dot gnu.org
2021-12-14  1:47 ` sandra at gcc dot gnu.org
2021-12-30 19:30 ` sandra at gcc dot gnu.org
2022-01-01 23:10 ` sandra at gcc dot gnu.org
2022-01-02 18:37 ` sandra at gcc dot gnu.org
2022-01-03 11:58 ` antony at cosmologist dot info
2022-01-03 16:48 ` cvs-commit at gcc dot gnu.org
2022-01-03 17:01 ` sandra at gcc dot gnu.org
2022-01-03 18:43 ` antony at cosmologist dot info
2022-01-05 17:05 ` sandra 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).