public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279
@ 2021-02-23 18:30 gscfq@t-online.de
  2021-02-23 18:48 ` [Bug fortran/99226] " jakub at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2021-02-23 18:30 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99226
           Summary: [11 Regression] ICE in expand_expr_real_1, at
                    expr.c:10279
           Product: gcc
           Version: 11.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 20200531 and 20200607, at -O1+ :
(compiles with single loop)


$ cat z1.f90
subroutine sub (n)
   integer :: n, i
   !$omp target
   !$omp teams distribute dist_schedule (static,n+4)
   do i = 1, 8
   end do
   !$omp teams distribute dist_schedule (static,n+4)
   do i = 1, 8
   end do
   !$omp end target
end


$ gfortran-11-20200531 -c z1.f90 -fopenmp -O2
$ gfortran-11-20210221 -c z1.f90 -fopenmp -O0
$
$ gfortran-11-20210221 -c z1.f90 -fopenmp -O2
during RTL pass: expand
z1.f90:3:15:

    3 |    !$omp target
      |               ^
internal compiler error: in expand_expr_real_1, at expr.c:10279
0x90a988 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:10273
0x907ca7 expand_expr
        ../../gcc/expr.h:282
0x907ca7 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:10600
0x907528 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:10848
0x909312 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:10208
0x907ca7 expand_expr
        ../../gcc/expr.h:282
0x907ca7 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:10600
0x909312 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:10208
0x912dd3 store_expr(tree_node*, rtx_def*, int, bool, bool)
        ../../gcc/expr.c:5886
0x914265 expand_assignment(tree_node*, tree_node*, bool)
        ../../gcc/expr.c:5622
0x809060 expand_gimple_stmt_1
        ../../gcc/cfgexpand.c:3910
0x809060 expand_gimple_stmt
        ../../gcc/cfgexpand.c:4008
0x80e257 expand_gimple_basic_block
        ../../gcc/cfgexpand.c:6045
0x81098e execute
        ../../gcc/cfgexpand.c:6729

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

* [Bug fortran/99226] [11 Regression] ICE in expand_expr_real_1, at expr.c:10279
  2021-02-23 18:30 [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279 gscfq@t-online.de
@ 2021-02-23 18:48 ` jakub at gcc dot gnu.org
  2021-02-24  8:20 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-23 18:48 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This is invalid and should have been rejected, when teams is nested in target,
it must be the only thing nested in it, you can't have two teams directives
nested in one target construct.

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

* [Bug fortran/99226] [11 Regression] ICE in expand_expr_real_1, at expr.c:10279
  2021-02-23 18:30 [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279 gscfq@t-online.de
  2021-02-23 18:48 ` [Bug fortran/99226] " jakub at gcc dot gnu.org
@ 2021-02-24  8:20 ` rguenth at gcc dot gnu.org
  2021-02-24 10:27 ` burnus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-24  8:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
   Target Milestone|---                         |11.0
           Keywords|                            |accepts-invalid, openmp

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

* [Bug fortran/99226] [11 Regression] ICE in expand_expr_real_1, at expr.c:10279
  2021-02-23 18:30 [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279 gscfq@t-online.de
  2021-02-23 18:48 ` [Bug fortran/99226] " jakub at gcc dot gnu.org
  2021-02-24  8:20 ` rguenth at gcc dot gnu.org
@ 2021-02-24 10:27 ` burnus at gcc dot gnu.org
  2021-02-24 10:46 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-02-24 10:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #1)
> This is invalid and should have been rejected, when teams is nested in
> target, it must be the only thing nested in it, you can't have two teams
> directives nested in one target construct.

How is this enforceable at compile time for '!$omp target; call f(); call g()"
and then in f() and g() the teams?


The following C program compiles – without ICE and without error:

void
sub (int n)
{
  int i;
#pragma omp target
  {
    #pragma omp teams distribute dist_schedule (static,n+4)
    for (i = 0; i < 8; ++i)
      ;
    #pragma omp teams distribute dist_schedule (static,n+4)
    for (i = 0; i < 8; ++i)
      ;
  }
}


And the resulting omplower dump is:
          #pragma omp teams shared(n)
          __builtin_GOMP_teams (0, 0);
          {
            D.2077 = n + 4;
            {
              int i;

              #pragma omp distribute dist_schedule(static,D.2077) private(i)
              for (i = 0; i < 8; i = i + 1)
              #pragma omp continue (i, i)
              #pragma omp return(nowait)
            }
          }
          #pragma omp return(nowait)

while for Fortran the dump is
            #pragma omp teams shared(n)
            __builtin_GOMP_teams (0, 0);
            {
              {
                integer(kind=4) D.3932;

                D.3936 = *n;
                D.3932 = D.3936 + 4;
                {
                  integer(kind=4) i;

                  #pragma omp distribute dist_schedule(static,D.3932)
private(i)
                  for (i = 1; i <= 8; i = i + 1)
                  <D.3945>:
                  #pragma omp continue (i, i)
                  #pragma omp return(nowait)
                }
              }
            }
            #pragma omp return(nowait)

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

* [Bug fortran/99226] [11 Regression] ICE in expand_expr_real_1, at expr.c:10279
  2021-02-23 18:30 [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-02-24 10:27 ` burnus at gcc dot gnu.org
@ 2021-02-24 10:46 ` jakub at gcc dot gnu.org
  2021-02-24 14:13 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-24 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Tobias Burnus from comment #2)
> (In reply to Jakub Jelinek from comment #1)
> > This is invalid and should have been rejected, when teams is nested in
> > target, it must be the only thing nested in it, you can't have two teams
> > directives nested in one target construct.
> 
> How is this enforceable at compile time for '!$omp target; call f(); call
> g()" and then in f() and g() the teams?

That will just fail or misbehave at runtime.
The spec says that
"A teams region can only be strictly nested within the implicit parallel region
or a target region. If a teams construct is nested within a target construct,
that target construct must contain no statements, declarations or directives
outside of the teams construct."
The compiler considers teams not strictly nested inside of target as "host
teams" which is lowered and expanded differently, and teams strictly nested
inside of target as "target teams".  And the construct nesting diagnostics
then will warn if the "host teams" is nested in some other construct that it is
not allowed to be nested in, but sure, this works only for lexical nesting.

I think clang diagnoses the #c2 testcase, we don't, I think the reason was
that it wasn't as clear what exactly is and is not allowed.  E.g.
#pragma omp target
{{{{{{
#pragma omp teams
;
}}}}}}
should be allowed and some statements outside of the teams but in target might
appear artificially during the parsing of e.g. teams clauses or during their
gimplification etc.

So, either we diagnose it early in the FEs somehow, or we add some less strict
late diagnostics, e.g. allow code outside of the teams in target but require
that that code doesn't contain any OpenMP directives (or just constructs?).
I guess the latter would be far easier and could be done in
check_omp_nesting_restrictions.

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

* [Bug fortran/99226] [11 Regression] ICE in expand_expr_real_1, at expr.c:10279
  2021-02-23 18:30 [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2021-02-24 10:46 ` jakub at gcc dot gnu.org
@ 2021-02-24 14:13 ` jakub at gcc dot gnu.org
  2021-02-24 15:18 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-24 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-02-24

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50247
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50247&action=edit
gcc11-pr99226.patch

Like this.

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

* [Bug fortran/99226] [11 Regression] ICE in expand_expr_real_1, at expr.c:10279
  2021-02-23 18:30 [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2021-02-24 14:13 ` jakub at gcc dot gnu.org
@ 2021-02-24 15:18 ` burnus at gcc dot gnu.org
  2021-02-24 19:16 ` cvs-commit at gcc dot gnu.org
  2021-02-25  8:18 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-02-24 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> So, either we diagnose ...  in check_omp_nesting_restrictions.

See comment 4.

 * * *

Only for completeness,
the ICE is itself is due to: '.omp_data_i' showing up in 'sub' and not only in
'sub_._omp_fn.0'. This only occurs with -O1 (and higher) and
-fdump-tree-omplower shows:
  void sub (integer(kind=4) & restrict n)
  {
    integer(kind=4) i;
    {
      D.3961 = .omp_data_i->D.3941;  // <<< WRONG!!!
Codewise, the '!optimize' occurs via gimplify.c's lookup_tmp_var
if is_formal=true – as called by 'get_formal_tmp_var'.

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

* [Bug fortran/99226] [11 Regression] ICE in expand_expr_real_1, at expr.c:10279
  2021-02-23 18:30 [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2021-02-24 15:18 ` burnus at gcc dot gnu.org
@ 2021-02-24 19:16 ` cvs-commit at gcc dot gnu.org
  2021-02-25  8:18 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-24 19:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:9d2a69106beb346be1c511a9c1a61a256b697868

commit r11-7375-g9d2a69106beb346be1c511a9c1a61a256b697868
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Feb 24 20:11:11 2021 +0100

    openmp: Diagnose invalid teams nested in target construct [PR99226]

    The OpenMP standard says:
    "A teams region can only be strictly nested within the implicit parallel
region
    or a target region. If a teams construct is nested within a target
construct,
    that target construct must contain no statements, declarations or
directives
    outside of the teams construct."
    We weren't diagnosing that restriction, because we need to allow e.g.
     #pragma omp target
     {{{{{{
       #pragma omp teams
       ;
     }}}}}}
    and as target doesn't need to have teams nested in it, using some special
    parser of the target body didn't feel right.  And after the parsing,
    the question is if e.g. already parsing of the clauses doesn't add some
    statements before the teams statement (gimplification certainly will).

    As we now have a bugreport where we ICE on the invalid code, this just
    diagnoses a subset of the invalid programs, in particular those where
    nest to the teams strictly nested in targets the target region contains
    some other OpenMP construct.

    2021-02-24  Jakub Jelinek  <jakub@redhat.com>

            PR fortran/99226
            * omp-low.c (struct omp_context): Add teams_nested_p and
            nonteams_nested_p members.
            (scan_omp_target): Diagnose teams nested inside of target with
other
            directives strictly nested inside of the same target.
            (check_omp_nesting_restrictions): Set ctx->teams_nested_p or
            ctx->nonteams_nested_p as needed.

            * c-c++-common/gomp/pr99226.c: New test.
            * gfortran.dg/gomp/pr99226.f90: New test.

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

* [Bug fortran/99226] [11 Regression] ICE in expand_expr_real_1, at expr.c:10279
  2021-02-23 18:30 [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2021-02-24 19:16 ` cvs-commit at gcc dot gnu.org
@ 2021-02-25  8:18 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-25  8:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
           Keywords|                            |ice-on-invalid-code

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-02-25  8:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23 18:30 [Bug fortran/99226] New: [11 Regression] ICE in expand_expr_real_1, at expr.c:10279 gscfq@t-online.de
2021-02-23 18:48 ` [Bug fortran/99226] " jakub at gcc dot gnu.org
2021-02-24  8:20 ` rguenth at gcc dot gnu.org
2021-02-24 10:27 ` burnus at gcc dot gnu.org
2021-02-24 10:46 ` jakub at gcc dot gnu.org
2021-02-24 14:13 ` jakub at gcc dot gnu.org
2021-02-24 15:18 ` burnus at gcc dot gnu.org
2021-02-24 19:16 ` cvs-commit at gcc dot gnu.org
2021-02-25  8:18 ` jakub 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).