openmp: Fix OpenMP expansion of scope with non-fallthrugh body [PR102415]
authorJakub Jelinek <jakub@redhat.com>
Wed, 22 Sep 2021 07:32:32 +0000 (09:32 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 22 Sep 2021 07:32:32 +0000 (09:32 +0200)
commitc4432b2776aeeffee9125bf87ff937e4a8907bbd
treeb5aadb84e76115684c3e1694a64d3541413a6555
parent059b819e3c94aae3dd0be55bd512ee6ee4e28798
openmp: Fix OpenMP expansion of scope with non-fallthrugh body [PR102415]

I've used function for omp single expansion also for omp scope.  That is
mostly ok, but as the testcase shows, there is one important difference.
The omp single expansion always has a fallthru body, because it during
omp lowering expands the body as if wrapped in an if to simulate that
one thread runs the body and others wait (unless nowait) until it completes
and continue.  omp scope is invoked by all threads and so if the body
is non-fallthru, the barrier (unless nowait) at the end will not be reached
by any of the threads.

The following patch fixes that by handling the case where cfg pass optimizes
away the exit bb of it gracefully.

2021-09-22  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/102415
* omp-expand.c (expand_omp_single): If region->exit is NULL,
assert region->entry is GIMPLE_OMP_SCOPE region and return.

* c-c++-common/gomp/scope-3.c: New test.
gcc/omp-expand.c
gcc/testsuite/c-c++-common/gomp/scope-3.c [new file with mode: 0644]