public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] openmp: Fix OpenMP expansion of scope with non-fallthrugh body [PR102415] Date: Wed, 22 Sep 2021 08:37:36 +0000 (GMT) [thread overview] Message-ID: <20210922083736.5A6D73858413@sourceware.org> (raw) https://gcc.gnu.org/g:147d6b7dda411f3fcfe585b967ecaf0f5b75551b commit 147d6b7dda411f3fcfe585b967ecaf0f5b75551b Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Sep 22 09:57:46 2021 +0200 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. (cherry picked from commit c4432b2776aeeffee9125bf87ff937e4a8907bbd) Diff: --- gcc/ChangeLog.omp | 9 +++++++++ gcc/omp-expand.c | 10 ++++++++-- gcc/testsuite/ChangeLog.omp | 8 ++++++++ gcc/testsuite/c-c++-common/gomp/scope-3.c | 21 +++++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index a84e0411304..e62ff21c278 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,12 @@ +2021-09-22 Tobias Burnus <tobias@codesourcery.com> + + Backported from master: + 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. + 2021-09-22 Tobias Burnus <tobias@codesourcery.com> Backported from master: diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c index fd86786270f..b87921b166a 100644 --- a/gcc/omp-expand.c +++ b/gcc/omp-expand.c @@ -8483,11 +8483,17 @@ expand_omp_single (struct omp_region *region) exit_bb = region->exit; si = gsi_last_nondebug_bb (entry_bb); - gcc_assert (gimple_code (gsi_stmt (si)) == GIMPLE_OMP_SINGLE - || gimple_code (gsi_stmt (si)) == GIMPLE_OMP_SCOPE); + enum gimple_code code = gimple_code (gsi_stmt (si)); + gcc_assert (code == GIMPLE_OMP_SINGLE || code == GIMPLE_OMP_SCOPE); gsi_remove (&si, true); single_succ_edge (entry_bb)->flags = EDGE_FALLTHRU; + if (exit_bb == NULL) + { + gcc_assert (code == GIMPLE_OMP_SCOPE); + return; + } + si = gsi_last_nondebug_bb (exit_bb); if (!gimple_omp_return_nowait_p (gsi_stmt (si))) { diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 3138d9893a9..48a9f531afe 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,11 @@ +2021-09-22 Tobias Burnus <tobias@codesourcery.com> + + Backported from master: + 2021-09-22 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/102415 + * c-c++-common/gomp/scope-3.c: New test. + 2021-09-22 Tobias Burnus <tobias@codesourcery.com> Backported from master: diff --git a/gcc/testsuite/c-c++-common/gomp/scope-3.c b/gcc/testsuite/c-c++-common/gomp/scope-3.c new file mode 100644 index 00000000000..78bb1a3ccb9 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/scope-3.c @@ -0,0 +1,21 @@ +/* PR middle-end/102415 */ + +extern +#ifdef __cplusplus +"C" +#endif +void abort (); + +void +foo (void) +{ + #pragma omp scope nowait + abort (); +} + +void +bar (void) +{ + #pragma omp scope + abort (); +}
reply other threads:[~2021-09-22 8:37 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210922083736.5A6D73858413@sourceware.org \ --to=burnus@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).