[Bug c/63307] [4.9/5 Regression] Cilk+ breaks -fcompare-debug bootstrap
izamyatin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Sep 29 09:28:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63307
--- Comment #1 from Igor Zamyatin <izamyatin at gmail dot com> ---
Would like to ask here first - will something like following be ok:
diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
index bf549ad..f453bc5 100644
--- a/gcc/c-family/cilk.c
+++ b/gcc/c-family/cilk.c
@@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see
#include "toplev.h"
#include "cgraph.h"
#include "diagnostic.h"
+#include "vec.h"
#include "cilk.h"
enum add_variable_type {
@@ -332,15 +333,23 @@ create_cilk_helper_decl (struct wrapper_data *wd)
return fndecl;
}
+typedef struct
+{
+ tree parm;
+ tree arg;
+} decl_pair;
+
+static vec<decl_pair> vec_arglist;
+
/* A function used by walk tree to find wrapper parms. */
static bool
wrapper_parm_cb (const void *key0, void **val0, void *data)
{
- struct wrapper_data *wd = (struct wrapper_data *) data;
tree arg = * (tree *)&key0;
tree val = (tree)*val0;
tree parm;
+ decl_pair dp;
if (val == error_mark_node || val == arg)
return true;
@@ -370,25 +379,48 @@ wrapper_parm_cb (const void *key0, void **val0, void
*data)
}
else
parm = val;
- TREE_CHAIN (parm) = wd->parms;
- wd->parms = parm;
- wd->argtypes = tree_cons (NULL_TREE, TREE_TYPE (parm), wd->argtypes);
- wd->arglist = tree_cons (NULL_TREE, arg, wd->arglist);
+
+ dp.parm = parm;
+ dp.arg = arg;
+ vec_arglist.safe_push(dp);
return true;
}
/* This function is used to build a wrapper of a certain type. */
+static int
+compare_decls (const void *a, const void *b)
+{
+ const decl_pair* t1 = (const decl_pair*) a;
+ const decl_pair* t2 = (const decl_pair*) b;
+
+ return DECL_UID(t1->arg) > DECL_UID(t2->arg);
+}
+
static void
build_wrapper_type (struct wrapper_data *wd)
{
+ unsigned int j;
+ decl_pair * c;
wd->arglist = NULL_TREE;
wd->parms = NULL_TREE;
wd->argtypes = void_list_node;
- pointer_map_traverse (wd->decl_map, wrapper_parm_cb, wd);
+ vec_arglist.create (0);
+ pointer_map_traverse (wd->decl_map, wrapper_parm_cb, NULL);
gcc_assert (wd->type != CILK_BLOCK_FOR);
+ vec_arglist.qsort(compare_decls);
+
+ FOR_EACH_VEC_ELT (vec_arglist, j, c)
+ {
+ TREE_CHAIN (c->parm) = wd->parms;
+ wd->parms = c->parm;
+ wd->argtypes = tree_cons (NULL_TREE, TREE_TYPE (c->parm), wd->argtypes);
+ wd->arglist = tree_cons (NULL_TREE, c->arg, wd->arglist);
+ }
+ vec_arglist.release();
+
/* Now build a function.
Its return type is void (all side effects are via explicit parameters).
Its parameters are WRAPPER_PARMS with type WRAPPER_TYPES.
Bootstrapped successfully with GCC_COMPARE_DEBUG=1
More information about the Gcc-bugs
mailing list