Bug 87649 - ICE in OpenMP doacross (ordered) loop
Summary: ICE in OpenMP doacross (ordered) loop
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 8.2.0
: P3 normal
Target Milestone: 7.5
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-invalid-code, openmp
: 85488 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-10-18 21:34 UTC by omrimor2
Modified: 2019-08-30 13:42 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 8.2.1, 9.0
Known to fail:
Last reconfirmed: 2018-10-19 00:00:00


Attachments
Minimal Working Example (C) (152 bytes, text/x-csrc)
2018-10-18 21:34 UTC, omrimor2
Details
gcc9-pr87649.patch (1.11 KB, patch)
2018-10-19 10:51 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description omrimor2 2018-10-18 21:34:33 UTC
Created attachment 44855 [details]
Minimal Working Example (C)

An OpenMP loop construct with an ordered clause with a parameter and a nested ordered construct with no depend clause causes an internal compiler error during the 'ompexp' GIMPLE pass. This is invalid OpenMP*, but should not cause an ICE segfault. Clang returns with an error, while ICC compiles (!) the invalid code but imposes no ordering constraint. Occurs on both macOS (Homebrew, GCC 8.2.0) and a Linux cluster (GCC 7.2.0).

I haven't confirmed if this is C/C++ frontend-specific or errors with Fortran as well.

*The loop or loop SIMD region to which an ordered region arising from an ordered construct without a depend clause binds must have an ordered clause without the parameter specified on the corresponding loop or loop SIMD directive. (OpenMP 4.5 Specification, §2.13.8, pp. 168)

#pragma omp parallel for ordered(1)
for (int i = 0; i < 100; i++) {
	#pragma omp ordered
	array[i] = i;
}

macOS:
Using built-in specs.
COLLECT_GCC=gcc-8
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/8.2.0/libexec/gcc/x86_64-apple-darwin18.0.0/8.2.0/lto-wrapper
Target: x86_64-apple-darwin18.0.0
Configured with: ../configure --build=x86_64-apple-darwin18.0.0 --prefix=/usr/local/Cellar/gcc/8.2.0 --libdir=/usr/local/Cellar/gcc/8.2.0/lib/gcc/8 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-8 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-checking=release --with-pkgversion='Homebrew GCC 8.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-nls --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Thread model: posix
gcc version 8.2.0 (Homebrew GCC 8.2.0) 

Linux:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc/7.2.0/libexec/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-7.2.0/configure --with-gmp=/usr/local/gmp/6.1.0 --with-mpfr=/usr/local/mpfr/3.1.4 --with-mpc=/usr/local/mpc/1.0.3 --with-cloog=/usr/local/cloog/ --with-isl=/usr/local/isl/0.16.1 --enable-cloog-backend=isl --prefix=/usr/local/gcc/7.2.0
Thread model: posix
gcc version 7.2.0 (GCC) 

Command line:
gcc -o test1 -fopenmp test1.c

Compiler output:
test1.c: In function 'main':
test1.c:7:10: internal compiler error: Segmentation fault: 11
  #pragma omp parallel for ordered(1)
          ^~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://github.com/Homebrew/homebrew-core/issues> for instructions.
Comment 1 omrimor2 2018-10-18 21:38:20 UTC
Duplicate of #85488, but has more information.
Comment 2 Jakub Jelinek 2018-10-19 09:37:37 UTC
*** Bug 85488 has been marked as a duplicate of this bug. ***
Comment 3 Jakub Jelinek 2018-10-19 10:51:15 UTC
Created attachment 44857 [details]
gcc9-pr87649.patch

Untested fix.
Comment 4 Jakub Jelinek 2018-10-19 22:52:38 UTC
Author: jakub
Date: Fri Oct 19 22:52:06 2018
New Revision: 265335

URL: https://gcc.gnu.org/viewcvs?rev=265335&root=gcc&view=rev
Log:
	PR middle-end/85488
	PR middle-end/87649
	* omp-low.c (check_omp_nesting_restrictions): Diagnose ordered without
	depend closely nested inside of loop with ordered clause with
	a parameter.

	* c-c++-common/gomp/doacross-2.c: New test.
	* c-c++-common/gomp/sink-3.c: Expect another error during error
	recovery.

Added:
    trunk/gcc/testsuite/c-c++-common/gomp/doacross-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/c-c++-common/gomp/sink-3.c
Comment 5 Jakub Jelinek 2018-11-05 14:08:19 UTC
Author: jakub
Date: Mon Nov  5 14:07:47 2018
New Revision: 265801

URL: https://gcc.gnu.org/viewcvs?rev=265801&root=gcc&view=rev
Log:
	Backported from mainline
	2018-10-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/85488
	PR middle-end/87649
	* omp-low.c (check_omp_nesting_restrictions): Diagnose ordered without
	depend closely nested inside of loop with ordered clause with
	a parameter.

	* c-c++-common/gomp/doacross-2.c: New test.
	* c-c++-common/gomp/sink-3.c: Expect another error during error
	recovery.

Added:
    branches/gcc-8-branch/gcc/testsuite/c-c++-common/gomp/doacross-2.c
Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/omp-low.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
    branches/gcc-8-branch/gcc/testsuite/c-c++-common/gomp/sink-3.c
Comment 6 Martin Liška 2018-11-20 08:54:07 UTC
Jakub: Can the bug be marked as resolved?
Comment 7 Jakub Jelinek 2018-11-20 08:55:03 UTC
No, it hasn't been fixed on 7.x yet.
Comment 8 Jakub Jelinek 2019-08-30 11:07:54 UTC
Author: jakub
Date: Fri Aug 30 11:07:22 2019
New Revision: 275065

URL: https://gcc.gnu.org/viewcvs?rev=275065&root=gcc&view=rev
Log:
	Backported from mainline
	2018-10-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/85488
	PR middle-end/87649
	* omp-low.c (check_omp_nesting_restrictions): Diagnose ordered without
	depend closely nested inside of loop with ordered clause with
	a parameter.

	* c-c++-common/gomp/doacross-2.c: New test.
	* c-c++-common/gomp/sink-3.c: Expect another error during error
	recovery.

Added:
    branches/gcc-7-branch/gcc/testsuite/c-c++-common/gomp/doacross-2.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/omp-low.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
    branches/gcc-7-branch/gcc/testsuite/c-c++-common/gomp/sink-3.c
Comment 9 Jakub Jelinek 2019-08-30 13:42:46 UTC
Fixed.