diff mbox

[PR60469,Cilk+] Fix ICE of using Cilk_spawn and Array Notation together

Message ID 0EFAB2BDD0F67E4FB6CCC8B9F87D7569429DCBE0@IRSMSX103.ger.corp.intel.com
State New
Headers show

Commit Message

Zamyatin, Igor April 10, 2014, 5:19 p.m. UTC
Hi!

This patches fixes the ICE when array notation is used along with Cilk_spawn. We need to expand AN's loop using other routine for creating temporary variables.

Bootstrapped/regtested on x86_64. 
Also it introduces no new failures and fixes couple of ICE for CilkPlus Conformance suite which could be found here (https://www.cilkplus.org/download#open-specification)

Ok for trunk?

Thanks,
Igor

gcc/c/Changelog:

2014-04-10  Igor Zamyatin  <igor.zamyatin@intel.com>
 
	PR middle-end/60469
	* c-array-notation.c (fix_builtin_array_notation_fn): Use
	create_tmp_var instead build_decl for creating temps.
	(build_array_notation_expr): Likewise.
	(fix_conditional_array_notations_1): Likewise.
	(fix_array_notation_expr): Likewise.
	(fix_array_notation_call_expr): Likewise.

gcc/testsuite/ChangeLog:

2014-04-10  Igor Zamyatin  <igor.zamyatin@intel.com>
 
	PR middle-end/60469
	* c-c++-common/cilk-plus/CK/pr60469.c: New test.

Comments

Rainer Orth April 10, 2014, 5:26 p.m. UTC | #1
"Zamyatin, Igor" <igor.zamyatin@intel.com> writes:

> diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c
> new file mode 100644
> index 0000000..61e8014
> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c
> @@ -0,0 +1,15 @@
> +/* middle-end/PR60469 */

Formatting error: PR middle-end/60469

	Rainer
Jakub Jelinek April 10, 2014, 5:28 p.m. UTC | #2
On Thu, Apr 10, 2014 at 05:19:33PM +0000, Zamyatin, Igor wrote:
> @@ -282,8 +283,7 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)
>  
>    for (ii = 0; ii < rank; ii++)
>      {
> -      an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
> -                                 integer_type_node);
> +      an_loop_info[ii].var = create_tmp_var(integer_type_node, NULL);

Please fix up formatting (space before left paren), many times
in the patch.

Ok with those changes.

Looking at it, I'd question if integer_type_node is the right type for the
iterators, I'd say signed_size_type_node or something similar shouldn't be
used instead, otherwise I'm afraid if you have array notations for >= 2GB
arrays on 64-bit targets it might misbehave.
But that is definitely something for stage1, not 4.9 right now.

	Jakub
diff mbox

Patch

diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c
index 6a5631c..e8db6aa 100644
--- a/gcc/c/c-array-notation.c
+++ b/gcc/c/c-array-notation.c
@@ -70,6 +70,7 @@ 
 #include "coretypes.h"
 #include "tree.h"
 #include "c-tree.h"
+#include "gimple-expr.h"
 #include "tree-iterator.h"
 #include "opts.h"
 #include "c-family/c-common.h"
@@ -282,8 +283,7 @@  fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)
 
   for (ii = 0; ii < rank; ii++)
     {
-      an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
-                                 integer_type_node);
+      an_loop_info[ii].var = create_tmp_var(integer_type_node, NULL);
       an_loop_info[ii].ind_init =
        build_modify_expr (location, an_loop_info[ii].var,
                           TREE_TYPE (an_loop_info[ii].var), NOP_EXPR,
@@ -781,8 +781,7 @@  build_array_notation_expr (location_t location, tree lhs, tree lhs_origtype,
   for (ii = 0; ii < lhs_rank; ii++)
     if (lhs_an_info[0][ii].is_vector)
       {
-       lhs_an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
-                                              integer_type_node);
+       lhs_an_loop_info[ii].var = create_tmp_var(integer_type_node, NULL);
        lhs_an_loop_info[ii].ind_init = build_modify_expr
          (location, lhs_an_loop_info[ii].var,
           TREE_TYPE (lhs_an_loop_info[ii].var), NOP_EXPR,
@@ -793,8 +792,7 @@  build_array_notation_expr (location_t location, tree lhs, tree lhs_origtype,
     {
       /* When we have a polynomial, we assume that the indices are of type 
         integer.  */
-      rhs_an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
-                                            integer_type_node);
+      rhs_an_loop_info[ii].var = create_tmp_var(integer_type_node, NULL);
       rhs_an_loop_info[ii].ind_init = build_modify_expr
        (location, rhs_an_loop_info[ii].var,
         TREE_TYPE (rhs_an_loop_info[ii].var), NOP_EXPR,
@@ -970,8 +968,7 @@  fix_conditional_array_notations_1 (tree stmt)
   cilkplus_extract_an_triplets (array_list, list_size, rank, &an_info);
   for (ii = 0; ii < rank; ii++)
     {
-      an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
-                                        integer_type_node);
+      an_loop_info[ii].var = create_tmp_var(integer_type_node, NULL);
       an_loop_info[ii].ind_init =
        build_modify_expr (location, an_loop_info[ii].var,
                           TREE_TYPE (an_loop_info[ii].var), NOP_EXPR,
@@ -1067,8 +1064,7 @@  fix_array_notation_expr (location_t location, enum tree_code code,
   loop_init = push_stmt_list ();
   for (ii = 0; ii < rank; ii++)
     {
-      an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
-                                        integer_type_node);
+      an_loop_info[ii].var = create_tmp_var(integer_type_node, NULL);
       an_loop_info[ii].ind_init =
        build_modify_expr (location, an_loop_info[ii].var,
                           TREE_TYPE (an_loop_info[ii].var), NOP_EXPR,
@@ -1163,8 +1159,7 @@  fix_array_notation_call_expr (tree arg)
     }
   for (ii = 0; ii < rank; ii++)
     {
-      an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
-                                        integer_type_node);
+      an_loop_info[ii].var = create_tmp_var(integer_type_node, NULL);
       an_loop_info[ii].ind_init =
        build_modify_expr (location, an_loop_info[ii].var,
                           TREE_TYPE (an_loop_info[ii].var), NOP_EXPR, location,
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c
new file mode 100644
index 0000000..61e8014
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c
@@ -0,0 +1,15 @@ 
+/* middle-end/PR60469 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+void foo() {}
+
+#define ALEN 1024
+
+int main(int argc, char* argv[])
+{
+  int b[ALEN];
+  b[:] = 100;
+  _Cilk_spawn foo();
+  return 0;
+}