From 4b5726fda653d11f882fb9a112e4cffa12f7ed61 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 27 Nov 2020 11:54:50 +0100 Subject: [PATCH] In 'gcc/omp-oacc-kernels-decompose.cc:flatten_binds', don't choke on empty GIMPLE sequence Also, instead of just examining the first statement of inner 'GIMPLE_BIND' (via 'inner_sequence' being a 'typedef gimple *gimple_seq'), in fact examine all statements contained therein, which I suppose must've been the intention here. This "fixes" the testcase 'c-c++-common/goacc/kernels-decompose-ice-2.c' (which now runs into the same ICE as 'c-c++-common/goacc/kernels-decompose-ice-1.c', etc.). gcc/ * omp-oacc-kernels-decompose.cc (flatten_binds): Don't choke on empty GIMPLE sequence, and examine all statements contained in inner 'GIMPLE_BIND'. gcc/testsuite/ * c-c++-common/goacc/kernels-decompose-ice-1.c: Adjust. * c-c++-common/goacc/kernels-decompose-ice-2.c: Likewise. --- gcc/omp-oacc-kernels-decompose.cc | 13 +++++++++++-- .../c-c++-common/goacc/kernels-decompose-ice-1.c | 1 + .../c-c++-common/goacc/kernels-decompose-ice-2.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gcc/omp-oacc-kernels-decompose.cc b/gcc/omp-oacc-kernels-decompose.cc index baad1b9a348..c46168e063a 100644 --- a/gcc/omp-oacc-kernels-decompose.cc +++ b/gcc/omp-oacc-kernels-decompose.cc @@ -740,8 +740,17 @@ flatten_binds (gbind *bind, bool include_toplevel_vars = false) /* Flatten recursively, and collect all variables. */ tree inner_vars = flatten_binds (inner_bind, true); gimple_seq inner_sequence = gimple_bind_body (inner_bind); - gcc_assert (gimple_code (inner_sequence) != GIMPLE_BIND - || top_level_omp_for_in_stmt (inner_sequence)); + if (flag_checking) + { + for (gimple_stmt_iterator inner_gsi = gsi_start (inner_sequence); + !gsi_end_p (inner_gsi); + gsi_next (&inner_gsi)) + { + gimple *inner_stmt = gsi_stmt (inner_gsi); + gcc_assert (gimple_code (inner_stmt) != GIMPLE_BIND + || top_level_omp_for_in_stmt (inner_stmt)); + } + } gimple_seq_add_seq (&new_body, inner_sequence); /* Find the last variable; we will append others to it. */ while (last_var != NULL && TREE_CHAIN (last_var) != NULL) diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c index 9e27d1fb9b5..82e7bd1495b 100644 --- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c +++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c @@ -7,6 +7,7 @@ /* Reduced from 'kernels-decompose-2.c'. (Hopefully) similar instances: + - 'kernels-decompose-ice-2.c' - 'libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c' - 'libgomp.oacc-c-c++-common/kernels-decompose-1.c' */ diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-2.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-2.c index 839e6803851..569f87a59c9 100644 --- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-2.c +++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-2.c @@ -2,7 +2,7 @@ /* { dg-additional-options "-fopenacc-kernels=decompose" } */ /* { dg-ice "TODO" } - { dg-prune-output "during GIMPLE pass: omp_oacc_kernels_decompose" } */ + { dg-prune-output "during GIMPLE pass: omplower" } */ /* Reduced from 'kernels-decompose-ice-1.c'. */ -- 2.30.2