Commit 31be63ab by Jakub Jelinek

re PR c/63307 (Cilk+ breaks -fcompare-debug bootstrap)

	PR c/63307
	* cilk.c (fill_decls_vec): Only put decls into vector v.                                                                                   
	(compare_decls): Fix up formatting.

	* c-c++-common/cilk-plus/CK/pr63307.c: New test.

2015-01-21  Igor Zamyatin  <igor.zamyatin@intel.com>

	PR c/63307
	* cilk.c: Include vec.h.
	(struct cilk_decls): New structure.
	(wrapper_parm_cb): Split this function to...
	(fill_decls_vec): ...this...
	(create_parm_list): ...and this.
	(compare_decls): New function.
	(for_local_cb): Remove.
	(wrapper_local_cb): Ditto.
	(build_wrapper_type): For now first traverse and fill vector of
	declarations then sort it and then deal with sorted vector.
	(cilk_outline): Ditto.
	(declare_one_free_variable): Ditto.

From-SVN: r219969
parent 8b08ef25
2015-01-21 Jakub Jelinek <jakub@redhat.com>
PR c/63307
* cilk.c (fill_decls_vec): Only put decls into vector v.
(compare_decls): Fix up formatting.
2015-01-21 Igor Zamyatin <igor.zamyatin@intel.com>
PR c/63307
* cilk.c: Include vec.h.
(struct cilk_decls): New structure.
(wrapper_parm_cb): Split this function to...
(fill_decls_vec): ...this...
(create_parm_list): ...and this.
(compare_decls): New function.
(for_local_cb): Remove.
(wrapper_local_cb): Ditto.
(build_wrapper_type): For now first traverse and fill vector of
declarations then sort it and then deal with sorted vector.
(cilk_outline): Ditto.
(declare_one_free_variable): Ditto.
2015-01-21 Jason Merrill <jason@redhat.com> 2015-01-21 Jason Merrill <jason@redhat.com>
PR c++/64629 PR c++/64629
......
...@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3. If not see
#include "ipa-ref.h" #include "ipa-ref.h"
#include "cgraph.h" #include "cgraph.h"
#include "diagnostic.h" #include "diagnostic.h"
#include "vec.h"
#include "cilk.h" #include "cilk.h"
enum add_variable_type { enum add_variable_type {
...@@ -355,17 +356,39 @@ create_cilk_helper_decl (struct wrapper_data *wd) ...@@ -355,17 +356,39 @@ create_cilk_helper_decl (struct wrapper_data *wd)
return fndecl; return fndecl;
} }
/* A function used by walk tree to find wrapper parms. */ struct cilk_decls
{
tree key;
tree *val;
};
/* A function used by traversal to fill vector of decls for further work. */
bool bool
wrapper_parm_cb (tree const &key0, tree *val0, wrapper_data *wd) fill_decls_vec (tree const &key0, tree *val0, auto_vec<struct cilk_decls> *v)
{
tree t1 = key0;
struct cilk_decls dp;
if (DECL_P (t1))
{
dp.key = t1;
dp.val = val0;
v->safe_push (dp);
}
return true;
}
/* Function that actually creates necessary parm lists. */
static void
create_parm_list (struct wrapper_data *wd, tree *val0, tree arg)
{ {
tree arg = key0;
tree val = *val0; tree val = *val0;
tree parm; tree parm;
if (val == error_mark_node || val == arg) if (val == error_mark_node || val == arg)
return true; return;
if (TREE_CODE (val) == PAREN_EXPR) if (TREE_CODE (val) == PAREN_EXPR)
{ {
...@@ -383,7 +406,7 @@ wrapper_parm_cb (tree const &key0, tree *val0, wrapper_data *wd) ...@@ -383,7 +406,7 @@ wrapper_parm_cb (tree const &key0, tree *val0, wrapper_data *wd)
} }
else else
arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg)), arg); arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg)), arg);
val = TREE_OPERAND (val, 0); val = TREE_OPERAND (val, 0);
*val0 = val; *val0 = val;
gcc_assert (TREE_CODE (val) == INDIRECT_REF); gcc_assert (TREE_CODE (val) == INDIRECT_REF);
...@@ -394,9 +417,24 @@ wrapper_parm_cb (tree const &key0, tree *val0, wrapper_data *wd) ...@@ -394,9 +417,24 @@ wrapper_parm_cb (tree const &key0, tree *val0, wrapper_data *wd)
parm = val; parm = val;
TREE_CHAIN (parm) = wd->parms; TREE_CHAIN (parm) = wd->parms;
wd->parms = parm; wd->parms = parm;
wd->argtypes = tree_cons (NULL_TREE, TREE_TYPE (parm), wd->argtypes); wd->argtypes = tree_cons (NULL_TREE, TREE_TYPE (parm), wd->argtypes);
wd->arglist = tree_cons (NULL_TREE, arg, wd->arglist); wd->arglist = tree_cons (NULL_TREE, arg, wd->arglist);
return true; }
/* Sorting decls in a vector. */
static int
compare_decls (const void *a, const void *b)
{
const struct cilk_decls *t1 = (const struct cilk_decls *) a;
const struct cilk_decls *t2 = (const struct cilk_decls *) b;
if (DECL_UID (t1->key) > DECL_UID (t2->key))
return 1;
else if (DECL_UID (t1->key) < DECL_UID (t2->key))
return -1;
else
return 0;
} }
/* This function is used to build a wrapper of a certain type. */ /* This function is used to build a wrapper of a certain type. */
...@@ -404,12 +442,19 @@ wrapper_parm_cb (tree const &key0, tree *val0, wrapper_data *wd) ...@@ -404,12 +442,19 @@ wrapper_parm_cb (tree const &key0, tree *val0, wrapper_data *wd)
static void static void
build_wrapper_type (struct wrapper_data *wd) build_wrapper_type (struct wrapper_data *wd)
{ {
unsigned int j;
struct cilk_decls * c;
auto_vec<struct cilk_decls> vd;
wd->arglist = NULL_TREE; wd->arglist = NULL_TREE;
wd->parms = NULL_TREE; wd->parms = NULL_TREE;
wd->argtypes = void_list_node; wd->argtypes = void_list_node;
wd->decl_map->traverse<wrapper_data *, wrapper_parm_cb> (wd);
gcc_assert (wd->type != CILK_BLOCK_FOR); gcc_assert (wd->type != CILK_BLOCK_FOR);
wd->decl_map->traverse<auto_vec<struct cilk_decls> *, fill_decls_vec> (&vd);
vd.qsort (compare_decls);
FOR_EACH_VEC_ELT (vd, j, c)
create_parm_list (wd, c->val, c->key);
/* Now build a function. /* Now build a function.
Its return type is void (all side effects are via explicit parameters). Its return type is void (all side effects are via explicit parameters).
...@@ -471,41 +516,19 @@ copy_decl_for_cilk (tree decl, copy_body_data *id) ...@@ -471,41 +516,19 @@ copy_decl_for_cilk (tree decl, copy_body_data *id)
} }
} }
/* Copy all local variables. */
bool
for_local_cb (tree const &k, tree *vp, copy_body_data *id)
{
tree v = *vp;
if (v == error_mark_node)
*vp = copy_decl_no_change (k, id);
return true;
}
/* Copy all local declarations from a _Cilk_spawned function's body. */
bool
wrapper_local_cb (tree const &key, tree *vp, copy_body_data *id)
{
tree val = *vp;
if (val == error_mark_node)
*vp = copy_decl_for_cilk (key, id);
return true;
}
/* Alter a tree STMT from OUTER_FN to form the body of INNER_FN. */ /* Alter a tree STMT from OUTER_FN to form the body of INNER_FN. */
void void
cilk_outline (tree inner_fn, tree *stmt_p, void *w) cilk_outline (tree inner_fn, tree *stmt_p, void *w)
{ {
struct wrapper_data *wd = (struct wrapper_data *) w; struct wrapper_data *wd = (struct wrapper_data *) w;
const tree outer_fn = wd->context; const tree outer_fn = wd->context;
const bool nested = (wd->type == CILK_BLOCK_FOR); const bool nested = (wd->type == CILK_BLOCK_FOR);
copy_body_data id; copy_body_data id;
bool throws; bool throws;
auto_vec<struct cilk_decls> vd;
unsigned int j;
struct cilk_decls * c;
DECL_STATIC_CHAIN (outer_fn) = 1; DECL_STATIC_CHAIN (outer_fn) = 1;
...@@ -531,11 +554,13 @@ cilk_outline (tree inner_fn, tree *stmt_p, void *w) ...@@ -531,11 +554,13 @@ cilk_outline (tree inner_fn, tree *stmt_p, void *w)
insert_decl_map (&id, wd->block, DECL_INITIAL (inner_fn)); insert_decl_map (&id, wd->block, DECL_INITIAL (inner_fn));
wd->decl_map->traverse<auto_vec<struct cilk_decls> *, fill_decls_vec> (&vd);
vd.qsort (compare_decls);
/* We don't want the private variables any more. */ /* We don't want the private variables any more. */
if (nested) FOR_EACH_VEC_ELT (vd, j, c)
wd->decl_map->traverse<copy_body_data *, for_local_cb> (&id); if (*(c->val) == error_mark_node)
else *(c->val) = nested ? copy_decl_no_change (c->key, &id)
wd->decl_map->traverse<copy_body_data *, wrapper_local_cb> (&id); : copy_decl_for_cilk (c->key, &id);
walk_tree (stmt_p, copy_tree_body_r, (void *) &id, NULL); walk_tree (stmt_p, copy_tree_body_r, (void *) &id, NULL);
...@@ -640,7 +665,7 @@ free_wd (struct wrapper_data *wd) ...@@ -640,7 +665,7 @@ free_wd (struct wrapper_data *wd)
*/ */
bool bool
declare_one_free_variable (tree const &var0, tree *map0, wrapper_data &) declare_one_free_variable (tree var0, tree *map0)
{ {
const_tree var = var0; const_tree var = var0;
tree map = *map0; tree map = *map0;
...@@ -713,6 +738,9 @@ create_cilk_wrapper (tree exp, tree *args_out) ...@@ -713,6 +738,9 @@ create_cilk_wrapper (tree exp, tree *args_out)
{ {
struct wrapper_data wd; struct wrapper_data wd;
tree fndecl; tree fndecl;
unsigned int j;
struct cilk_decls * c;
auto_vec<struct cilk_decls> vd;
init_wd (&wd, CILK_BLOCK_SPAWN); init_wd (&wd, CILK_BLOCK_SPAWN);
...@@ -733,7 +761,11 @@ create_cilk_wrapper (tree exp, tree *args_out) ...@@ -733,7 +761,11 @@ create_cilk_wrapper (tree exp, tree *args_out)
} }
else else
extract_free_variables (exp, &wd, ADD_READ); extract_free_variables (exp, &wd, ADD_READ);
wd.decl_map->traverse<wrapper_data &, declare_one_free_variable> (wd); wd.decl_map->traverse<auto_vec<struct cilk_decls> *, fill_decls_vec> (&vd);
vd.qsort (compare_decls);
FOR_EACH_VEC_ELT (vd, j, c)
declare_one_free_variable (c->key, c->val);
wd.block = TREE_BLOCK (exp); wd.block = TREE_BLOCK (exp);
if (!wd.block) if (!wd.block)
wd.block = DECL_INITIAL (current_function_decl); wd.block = DECL_INITIAL (current_function_decl);
......
2015-01-21 Jakub Jelinek <jakub@redhat.com>
PR c/63307
* c-c++-common/cilk-plus/CK/pr63307.c: New test.
2015-01-21 Thomas Koenig <tkoenig@netcologne.de> 2015-01-21 Thomas Koenig <tkoenig@netcologne.de>
PR fortran/57023 PR fortran/57023
......
/* { dg-options "-fcilkplus -fcompare-debug" } */
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
#include "fib_no_return.c"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment