https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81817
Bug ID: 81817 Summary: ICE in lto1 with -fopenmp offloading and nested #pragma omp target Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: ice-on-invalid-code, lto, openmp Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: igor.venevtsev at intel dot com CC: marxin at gcc dot gnu.org Target Milestone: --- Nested #pragma omp target regions cause gcc crash with ICE at lto phase. Yes, this program is ill-formed according OpenMP specification, but ICE is not a good behavior;) Simple reproducer: bash-4.3$ cat target-in-target.c int main(void) { #pragma omp target { int x = 1; #pragma omp target { int y = x; } } return 0; } To reproduce using Intel Xeon Phi emulation: 1. Build offload and host compilers as described in https://gcc.gnu.org/wiki/Offloading#How_to_try_offloading_enabled_GCC 2. Execute bash-4.3$ ./gcc -fopenmp target-in-target.c target-in-target.c: In function ‘main’: target-in-target.c:6:15: warning: ‘target’ construct inside of ‘target’ region #pragma omp target ^~~ lto1: internal compiler error: in input_varpool_node, at lto-cgraph.c:1425 0x965fd0 input_varpool_node ../../trunk/gcc/lto-cgraph.c:1423 0x965fd0 input_cgraph_1 ../../trunk/gcc/lto-cgraph.c:1547 0x965fd0 input_symtab() ../../trunk/gcc/lto-cgraph.c:1856 0x6151b3 read_cgraph_and_symbols ../../trunk/gcc/lto/lto.c:2857 0x6151b3 lto_main() ../../trunk/gcc/lto/lto.c:3310 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. mkoffload-intelmic: fatal error: ./x86_64-pc-linux-gnu-accel-x86_64-intelmicemul-linux-gnu-gcc returned 1 exit status compilation terminated. lto-wrapper: fatal error: /tmp/LTO-ICE/install/libexec/gcc/x86_64-pc-linux-gnu/8.0.0//accel/x86_64-intelmicemul-linux-gnu/mkoffload returned 1 exit status compilation terminated. /usr/bin/ld: lto-wrapper failed collect2: error: ld returned 1 exit status 3. gcc version: bash-4.3$ ./gcc -v Using built-in specs. COLLECT_GCC=./gcc COLLECT_LTO_WRAPPER=/tmp/LTO-ICE/install/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper OFFLOAD_TARGET_NAMES=x86_64-intelmicemul-linux-gnu Target: x86_64-pc-linux-gnu Configured with: ../trunk/configure --prefix=/tmp/LTO-ICE/install --disable-bootstrap --disable-multilib --disable-libsanitizer --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --enable-offload-targets=x86_64-intelmicemul-linux-gnu=/tmp/LTO-ICE/install --enable-languages=c,c++,fortran,lto Thread model: posix gcc version 8.0.0 20170809 (experimental) (GCC) bash-4.3$