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.
This commit is contained in:
Thomas Schwinge 2020-11-27 11:54:50 +01:00
parent 4a7c799908
commit 4b5726fda6
3 changed files with 13 additions and 3 deletions

View File

@ -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)

View File

@ -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'
*/

View File

@ -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'. */