http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469
--- Comment #1 from Andi Kleen <andi-gcc at firstfloor dot org> ---
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 = <function_decl 0x7fe4297b7e00 main>, new_local_var_chain = <tree
0x0>, debug_var_chain = <tree 0x0>, frame_type = <tree 0x0>, frame_decl = <tree
0x0>,
chain_field = <tree 0x0>, chain_decl = <tree 0x0>, nl_goto_field = <tree
0x0>, 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 = <tree 0x0>
(gdb) p info->context
$12 = <function_decl 0x7fe4297b7e00 main>
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?