In 'gcc/omp-oacc-kernels-decompose.cc:flatten_binds', don't choke on empty GIMPLE...
authorThomas Schwinge <thomas@codesourcery.com>
Fri, 27 Nov 2020 10:54:50 +0000 (11:54 +0100)
committerThomas Schwinge <thomas@codesourcery.com>
Fri, 27 Nov 2020 13:38:15 +0000 (14:38 +0100)
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
gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c
gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-2.c

index baad1b9a3482d3c448056be203ceda6d35bf928f..c46168e063aba14abec7a5ebc994345d9a349d8c 100644 (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)
index 9e27d1fb9b5a496f31c8542a9e474a0438d35733..82e7bd1495b33f18124851d576ab5b36b05b60c8 100644 (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'
 */
index 839e680385151598c097fbb2623bf3335960c2ac..569f87a59c97365ae0493abe8be8eb3bcbbbd427 100644 (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'.  */