public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99322] New: [11 Regression] ICE in change_scope, at final.c:1480
@ 2021-03-01 17:02 gscfq@t-online.de
  2021-03-01 19:10 ` [Bug c/99322] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gscfq@t-online.de @ 2021-03-01 17:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99322
           Summary: [11 Regression] ICE in change_scope, at final.c:1480
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Changed between 20201018 and 20201108 :


$ cat z1.c
void g ();
void f ()
{
  #pragma omp parallel
  for (;;)
    for (int i = 0; i < 8; ++i)
      g ();
  { L1: }
  &&L1;
}


$ gcc-11-20210228 -c z1.c -fopenmp -O2 -g
$ gcc-11-20210228 -c z1.c -fopenmp -O3
$
$ gcc-11-20210228 -c z1.c -fopenmp -O3 -g
during RTL pass: final
z1.c: In function 'f._omp_fn.0':
z1.c:4:11: internal compiler error: Segmentation fault
    4 |   #pragma omp parallel
      |           ^~~
0xb5eeff crash_signal
        ../../gcc/toplev.c:327
0x87295d change_scope
        ../../gcc/final.c:1480
0x8792c1 reemit_insn_block_notes
        ../../gcc/final.c:1581
0x8792c1 final_start_function_1
        ../../gcc/final.c:1785
0x879549 rest_of_handle_final
        ../../gcc/final.c:4675
0x879549 execute
        ../../gcc/final.c:4754

---

z1.c: In function 'f._omp_fn.0':
z1.c:10:1: error: location references block not in block tree
   10 | }
      | ^
L1:
during IPA pass: *free_lang_data
z1.c:10:1: internal compiler error: verify_gimple failed
0xd94884 verify_gimple_in_cfg(function*, bool)
        ../../gcc/tree-cfg.c:5477
0xc45d3e execute_function_todo
        ../../gcc/passes.c:2042
0xc46b7d do_per_function
        ../../gcc/passes.c:1694
0xc46be2 execute_todo
        ../../gcc/passes.c:2096

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

* [Bug c/99322] [11 Regression] ICE in change_scope, at final.c:1480
  2021-03-01 17:02 [Bug c/99322] New: [11 Regression] ICE in change_scope, at final.c:1480 gscfq@t-online.de
@ 2021-03-01 19:10 ` pinskia at gcc dot gnu.org
  2021-03-02  9:42 ` marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-03-01 19:10 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
           Keywords|                            |openmp

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

* [Bug c/99322] [11 Regression] ICE in change_scope, at final.c:1480
  2021-03-01 17:02 [Bug c/99322] New: [11 Regression] ICE in change_scope, at final.c:1480 gscfq@t-online.de
  2021-03-01 19:10 ` [Bug c/99322] " pinskia at gcc dot gnu.org
@ 2021-03-02  9:42 ` marxin at gcc dot gnu.org
  2021-03-05 14:52 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-03-02  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |muecker at gwdg dot de
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-03-02

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r11-4813-g8b7a9a249a63e066.

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

* [Bug c/99322] [11 Regression] ICE in change_scope, at final.c:1480
  2021-03-01 17:02 [Bug c/99322] New: [11 Regression] ICE in change_scope, at final.c:1480 gscfq@t-online.de
  2021-03-01 19:10 ` [Bug c/99322] " pinskia at gcc dot gnu.org
  2021-03-02  9:42 ` marxin at gcc dot gnu.org
@ 2021-03-05 14:52 ` jakub at gcc dot gnu.org
  2021-03-05 16:41 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-05 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Simpler testcase:
void
foo (void)
{
  void *p = &&lab;
  #pragma omp parallel
  for (;;)
    ;
  lab:;
}

The problem seems that the OpenMP parallel body is noreturn, so when building
cfg we build correctly:
<bb 2> :
p = &lab;
#pragma omp parallel [child fn: foo._omp_fn.0 (???)]

<bb 3> :
goto <bb 3>; [INV]

<bb 4> :
#pragma omp return

<bb 5> :
lab:
return;

but during cfg cleanup, we find that #pragma omp return is unreachable (that is
ok) and that also lab: return; is unreachable.  And place it somewhere
randomly, which would be ok if it wouldn't be inside of the OpenMP block body
(bb3).

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

* [Bug c/99322] [11 Regression] ICE in change_scope, at final.c:1480
  2021-03-01 17:02 [Bug c/99322] New: [11 Regression] ICE in change_scope, at final.c:1480 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-03-05 14:52 ` jakub at gcc dot gnu.org
@ 2021-03-05 16:41 ` jakub at gcc dot gnu.org
  2021-03-05 16:59 ` [Bug middle-end/99322] " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-05 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
void bar (void *);
void
foo (void)
{
  bar (&&lab);
  #pragma omp parallel
  for (;;)
    ;
  lab:;
}
ICEs likely since r0-88143-gb357f682db35f4431e3011e7486a0ac865686e3e
Not really sure what to do if we find unreachable blocks with labels that need
to be preserved, we need to figure out where to place them exactly.
As the problematic pass is only the cfg pass (if flag_openmp || flag_openacc ||
flag_openmp_simd), I wonder if we e.g. shouldn't keep bb_to_omp_idx valid
across the cleanup_tree_cfg and if non-NULL, use that for the forced label from
unreachable blocks placement.

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

* [Bug middle-end/99322] [11 Regression] ICE in change_scope, at final.c:1480
  2021-03-01 17:02 [Bug c/99322] New: [11 Regression] ICE in change_scope, at final.c:1480 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2021-03-05 16:41 ` jakub at gcc dot gnu.org
@ 2021-03-05 16:59 ` jakub at gcc dot gnu.org
  2021-03-05 20:59 ` cvs-commit at gcc dot gnu.org
  2021-03-05 21:01 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-05 16:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

Untested fix.

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

* [Bug middle-end/99322] [11 Regression] ICE in change_scope, at final.c:1480
  2021-03-01 17:02 [Bug c/99322] New: [11 Regression] ICE in change_scope, at final.c:1480 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2021-03-05 16:59 ` [Bug middle-end/99322] " jakub at gcc dot gnu.org
@ 2021-03-05 20:59 ` cvs-commit at gcc dot gnu.org
  2021-03-05 21:01 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-05 20:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:a3ad6489d38982434faef3bc5f33e3c28c5f7c74

commit r11-7533-ga3ad6489d38982434faef3bc5f33e3c28c5f7c74
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 5 21:52:35 2021 +0100

    openmp: Avoid ICEs due to orphaned labels in OpenMP regions [PR99322]

    When performing cfg cleanup at the end of cfg pass, if there are any OpenMP
    regions and some basic blocks are unreachable and contain forced labels,
    remove_bb moves the labels to previous bb, but if the two bb belong to
different
    OpenMP regions, that means it will end up in a different function from
where
    it was assumed to be and checked e.g. during gimplification or OpenMP
region
    SESE checking.

    The following patch will place the labels to some bb from the right OpenMP
    region if the previous bb is not that.  I think it should happen very
rarely,
    normally the bbs from each OpenMP region should be from the before-cfg pass
    adjacent and the problems will usually be only if the OpenMP regions are
    no-return, so I hope it isn't fatal that it searches through all bbs on the
miss.
    If it turns out to be a problem, it can always lazily create some better
data
    structure and maintain it through bb removals when it reaches that case the
    first time.

    2021-03-05  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/99322
            * tree-cfg.c (bb_to_omp_idx): New variable.
            (execute_build_cfg): Release the bb_to_omp_idx vector after
            cleanup_tree_cfg returns.
            (handle_abnormal_edges): Remove bb_to_omp_idx argument, adjust
            for bb_to_omp_idx being a vec<int> instead of pointer to array
            of ints.
            (make_edges): Remove bb_to_omp_idx local variable, don't pass
            it to handle_abnormal_edges, adjust for bb_to_omp_idx being a
            vec<int> instead of pointer to array of ints and don't free/release
            it at the end.
            (remove_bb): When removing a bb and placing forced label somewhere
            else, ensure it is put into the same OpenMP region during cfg
            pass if possible or to entry successor as fallback.  Unregister
            bb from bb_to_omp_idx.

            * c-c++-common/gomp/pr99322.c: New test.

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

* [Bug middle-end/99322] [11 Regression] ICE in change_scope, at final.c:1480
  2021-03-01 17:02 [Bug c/99322] New: [11 Regression] ICE in change_scope, at final.c:1480 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2021-03-05 20:59 ` cvs-commit at gcc dot gnu.org
@ 2021-03-05 21:01 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-05 21:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2021-03-05 21:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 17:02 [Bug c/99322] New: [11 Regression] ICE in change_scope, at final.c:1480 gscfq@t-online.de
2021-03-01 19:10 ` [Bug c/99322] " pinskia at gcc dot gnu.org
2021-03-02  9:42 ` marxin at gcc dot gnu.org
2021-03-05 14:52 ` jakub at gcc dot gnu.org
2021-03-05 16:41 ` jakub at gcc dot gnu.org
2021-03-05 16:59 ` [Bug middle-end/99322] " jakub at gcc dot gnu.org
2021-03-05 20:59 ` cvs-commit at gcc dot gnu.org
2021-03-05 21:01 ` 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).