[Bug middle-end/60469] simple cilk plus program ICEs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 Andi Kleen changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED --- Comment #16 from Andi Kleen --- Fixed since some time
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #15 from Kirill Yukhin --- Author: kyukhin Date: Tue Apr 15 06:27:07 2014 New Revision: 209400 URL: http://gcc.gnu.org/viewcvs?rev=209400&root=gcc&view=rev Log: gcc/c/ 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/ PR middle-end/60469 * c-c++-common/cilk-plus/CK/pr60469.c: New test. Added: branches/gcc-4_9-branch/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c Modified: branches/gcc-4_9-branch/gcc/c/ChangeLog branches/gcc-4_9-branch/gcc/c/c-array-notation.c branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #14 from Jakub Jelinek --- Please don't forget to backport the Cilk+ bugfixes to 4.9 branch after 4.9.0 is released, as long as they are small and non-risky.
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #13 from Kirill Yukhin --- Author: kyukhin Date: Sat Apr 12 17:57:15 2014 New Revision: 209336 URL: http://gcc.gnu.org/viewcvs?rev=209336&root=gcc&view=rev Log: gcc/c/ 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/ PR middle-end/60469 * c-c++-common/cilk-plus/CK/pr60469.c: New test. Added: trunk/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60469.c Modified: trunk/gcc/c/ChangeLog trunk/gcc/c/c-array-notation.c trunk/gcc/testsuite/ChangeLog
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #12 from Igor Zamyatin --- Thanks, will post a patch after the testing
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #11 from Jakub Jelinek --- You need to include gimple-expr.h header for that. But, if you look e.g. at c/c-typeck.c or c-family/cilk.c, it is already used in the FEs.
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #10 from Igor Zamyatin --- (In reply to Jakub Jelinek from comment #9) > (In reply to H.J. Lu from comment #8) > > (In reply to H.J. Lu from comment #7) > > > (In reply to Igor Zamyatin from comment #6) > > > > Yes, I was going to post it after complete testing > > > > > > You should set DECL_SEEN_IN_BIND_EXPR_P when setting > > > DECL_CONTEXT, similar to gimple_add_tmp_var. > > > > Or we can use create_tmp_var. > > That is much better idea, it will handle tons of other things, like setting > DECL_ARTIFICIAL/DECL_IGNORED_P flags etc. In C++ FE, cp-array-notation.c > apparently uses get_temp_regvar, which is also fine (but only defined in C++ > FE). Yes, I tried create_tmp_var but it was undefined so I thought it's not a good idea... Will try further with it then
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #9 from Jakub Jelinek --- (In reply to H.J. Lu from comment #8) > (In reply to H.J. Lu from comment #7) > > (In reply to Igor Zamyatin from comment #6) > > > Yes, I was going to post it after complete testing > > > > You should set DECL_SEEN_IN_BIND_EXPR_P when setting > > DECL_CONTEXT, similar to gimple_add_tmp_var. > > Or we can use create_tmp_var. That is much better idea, it will handle tons of other things, like setting DECL_ARTIFICIAL/DECL_IGNORED_P flags etc. In C++ FE, cp-array-notation.c apparently uses get_temp_regvar, which is also fine (but only defined in C++ FE).
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #8 from H.J. Lu --- (In reply to H.J. Lu from comment #7) > (In reply to Igor Zamyatin from comment #6) > > Yes, I was going to post it after complete testing > > You should set DECL_SEEN_IN_BIND_EXPR_P when setting > DECL_CONTEXT, similar to gimple_add_tmp_var. Or we can use create_tmp_var.
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #7 from H.J. Lu --- (In reply to Igor Zamyatin from comment #6) > Yes, I was going to post it after complete testing You should set DECL_SEEN_IN_BIND_EXPR_P when setting DECL_CONTEXT, similar to gimple_add_tmp_var.
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #6 from Igor Zamyatin --- Yes, I was going to post it after complete testing
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #5 from Andi Kleen --- You're right. It works in C++. That's similar to my earlier patch, but I didn't comment out the other check like you did. If commenting out the check work it would seem right to me. Can you post it as a RFC?
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #4 from Igor Zamyatin --- Following works for me and shows no new errors in regtesting. Not sure it is a good idea though... diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index 6a5631c..d7c6772 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -284,6 +284,7 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var) { an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE, integer_type_node); + DECL_CONTEXT (an_loop_info[ii].var) = current_function_decl; an_loop_info[ii].ind_init = build_modify_expr (location, an_loop_info[ii].var, TREE_TYPE (an_loop_info[ii].var), NOP_EXPR, @@ -783,6 +784,7 @@ build_array_notation_expr (location_t location, tree lhs, tree lhs_origtype, { lhs_an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE, integer_type_node); +DECL_CONTEXT (lhs_an_loop_info[ii].var) = current_function_decl; 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, @@ -795,6 +797,7 @@ build_array_notation_expr (location_t location, tree lhs, tree lhs_origtype, integer. */ rhs_an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE, integer_type_node); + DECL_CONTEXT (rhs_an_loop_info[ii].var) = current_function_decl; 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, @@ -972,6 +975,7 @@ fix_conditional_array_notations_1 (tree stmt) { an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE, integer_type_node); + DECL_CONTEXT (an_loop_info[ii].var) = current_function_decl; an_loop_info[ii].ind_init = build_modify_expr (location, an_loop_info[ii].var, TREE_TYPE (an_loop_info[ii].var), NOP_EXPR, @@ -1069,6 +1073,7 @@ fix_array_notation_expr (location_t location, enum tree_code code, { an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE, integer_type_node); + DECL_CONTEXT (an_loop_info[ii].var) = current_function_decl; an_loop_info[ii].ind_init = build_modify_expr (location, an_loop_info[ii].var, TREE_TYPE (an_loop_info[ii].var), NOP_EXPR, @@ -1165,6 +1170,7 @@ fix_array_notation_call_expr (tree arg) { an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE, integer_type_node); + DECL_CONTEXT (an_loop_info[ii].var) = current_function_decl; 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/gimplify.c b/gcc/gimplify.c index 7441784..b61a995 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1732,6 +1732,7 @@ gimplify_var_or_parm_decl (tree *expr_p) be really nice if the front end wouldn't leak these at all. Currently the only known culprit is C++ destructors, as seen in g++.old-deja/g++.jason/binding.C. */ +#if 0 if (TREE_CODE (decl) == VAR_DECL && !DECL_SEEN_IN_BIND_EXPR_P (decl) && !TREE_STATIC (decl) && !DECL_EXTERNAL (decl) @@ -1740,6 +1741,7 @@ gimplify_var_or_parm_decl (tree *expr_p) gcc_assert (seen_error ()); return GS_ERROR; } +#endif /* When within an OpenMP context, notice uses of variables. */ if (gimplify_omp_ctxp && omp_notice_variable (gimplify_omp_ctxp, decl, true))
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #3 from Andi Kleen --- I've tried a couple of things to fix this: - Fill in DECL_CONTEXT to current_fn_decl in cilk - Fill in DECL_CONTEXT for VAR_DECLs when creating the nested wrapper No banana so far. The first causes other errors and the second still has the same segfault
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 Igor Zamyatin changed: What|Removed |Added CC||izamyatin at gmail dot com --- Comment #2 from Igor Zamyatin --- ICE could be seen even for void foo() { asm("" ::: "memory"); } #define ALEN 1024 int main(int argc, char* argv[]) { int b[ALEN]; b[:] = 100; _Cilk_spawn foo(); return 0; } The "bad" VAR_DECL here is the initial variable for the loop that is created during array annotation expression expanding. The problem seems to be in the way how this var_decl is created. For C++ case create_temp_var is used where DECL_CONTEXT is set up. For C case build_decl is used where no DECL_CONTEXT is filled
[Bug middle-end/60469] simple cilk plus program ICEs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469 --- Comment #1 from Andi Kleen --- I investigated this a bit. The problem is in get_chain_decl() in the nested function lowering because Cilk creates nested functions. info->outer is NULL created_nesting_tree does this for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested) { struct nesting_info *sub = create_nesting_tree (cgn); sub->outer = info; sub->next = info->inner; info->inner = sub; } So it would only set ->outer for any inner functions and it is expected to be NULL on the outer most nesting level $6 = {outer = 0x0, inner = 0x329b590, next = 0x0, field_map = 0x329c780, var_map = 0x329dc70, mem_refs = 0x329e850, suppress_expansion = 0x32f8d20, context = , new_local_var_chain = , debug_var_chain = , frame_type = , frame_decl = , chain_field = , chain_decl = , nl_goto_field = , any_parm_remapped = false, any_tramp_created = false, static_chain_added = 0 '\000'} So this whole code is invoked on the most outer most context, which it cannot deal with This seems to be related to the decl_function_context farther up the callstack: static tree convert_nonlocal_reference_op (tree *tp, int *walk_subtrees, void *data) { struct walk_stmt_info *wi = (struct walk_stmt_info *) data; struct nesting_info *const info = (struct nesting_info *) wi->info; tree t = *tp; *walk_subtrees = 0; switch (TREE_CODE (t)) { case VAR_DECL: /* Non-automatic variables are never processed. */ if (TREE_STATIC (t) || DECL_EXTERNAL (t)) break; /* FALLTHRU */ case PARM_DECL: if (decl_function_context (t) != info->context) (gdb) p t->decl_minimal.context $11 = (gdb) p info->context $12 = This means the VAR_DECL doesn't have the correct context Looking at c-common/cilk.c it seems to copy VAR_DECLs. So it somehow doesn't set up the context correctly?