This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [lto][patch] Fix handling of DECL_CONTEXT of RESULT_DECLs. Don't write them to disk
> Patch is missing.
>
Sorry :-(
> Diego.
>
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/gcc/lto-function-in.c b/gcc/lto-function-in.c
index 8e86464..b9d1610 100644
--- a/gcc/lto-function-in.c
+++ b/gcc/lto-function-in.c
@@ -55,10 +55,13 @@ Boston, MA 02110-1301, USA. */
#include "cpplib.h"
tree input_tree (struct lto_input_block *, struct data_in *);
+static tree input_tree_with_context (struct lto_input_block *ib,
+ struct data_in *data_in, tree fn);
+
static tree input_type_tree (struct data_in *, struct lto_input_block *);
static tree input_tree_operand (struct lto_input_block *,
struct data_in *,
- struct function *, enum LTO_tags);
+ tree, enum LTO_tags);
/* Vector of tree-pointer locations for backpatching. */
@@ -2581,7 +2584,7 @@ input_function_decl (struct lto_input_block *ib, struct data_in *data_in)
/* saved_tree -- this is a function body, so omit it here */
decl->decl_non_common.arguments = input_tree (ib, data_in);
- decl->decl_non_common.result = input_tree (ib, data_in);
+ decl->decl_non_common.result = input_tree_with_context (ib, data_in, decl);
decl->decl_non_common.vindex = input_tree (ib, data_in);
/* lang_specific */
@@ -2808,7 +2811,8 @@ input_parm_decl (struct lto_input_block *ib, struct data_in *data_in)
}
static tree
-input_result_decl (struct lto_input_block *ib, struct data_in *data_in)
+input_result_decl (struct lto_input_block *ib, struct data_in *data_in,
+ tree fn)
{
tree decl = make_node (RESULT_DECL);
@@ -2821,7 +2825,7 @@ input_result_decl (struct lto_input_block *ib, struct data_in *data_in)
/* omit locus, uid */
decl->decl_minimal.name = input_tree (ib, data_in);
- decl->decl_minimal.context = input_tree (ib, data_in);
+ decl->decl_minimal.context = fn;
decl->common.type = input_tree (ib, data_in);
@@ -3136,7 +3140,7 @@ input_type (struct lto_input_block *ib, struct data_in *data_in, enum tree_code
static tree
input_tree_operand (struct lto_input_block *ib, struct data_in *data_in,
- struct function *fn, enum LTO_tags tag)
+ tree fn, enum LTO_tags tag)
{
enum tree_code code;
tree type = NULL_TREE;
@@ -3367,7 +3371,7 @@ input_tree_operand (struct lto_input_block *ib, struct data_in *data_in,
but these are apparently treated similarly to parameters, for
which dummy instances are created for extern declarations, etc.
Actual references should occur only within a function body. */
- result = input_result_decl (ib, data_in);
+ result = input_result_decl (ib, data_in, fn);
break;
case TYPE_DECL:
@@ -3646,12 +3650,9 @@ input_tree_operand (struct lto_input_block *ib, struct data_in *data_in,
return result;
}
-/* Input a generic tree from the LTO IR input stream IB using the per-file
- context in DATA_IN. This context is used, for example, to resolve
- references to previously input nodes. */
-
-tree
-input_tree (struct lto_input_block *ib, struct data_in *data_in)
+static tree
+input_tree_with_context (struct lto_input_block *ib,
+ struct data_in *data_in, tree fn)
{
enum LTO_tags tag = input_record_start (ib);
@@ -3681,7 +3682,17 @@ input_tree (struct lto_input_block *ib, struct data_in *data_in)
return result;
}
else
- return input_tree_operand (ib, data_in, NULL, tag);
+ return input_tree_operand (ib, data_in, fn, tag);
+}
+
+/* Input a generic tree from the LTO IR input stream IB using the per-file
+ context in DATA_IN. This context is used, for example, to resolve
+ references to previously input nodes. */
+
+tree
+input_tree (struct lto_input_block *ib, struct data_in *data_in)
+{
+ return input_tree_with_context (ib, data_in, NULL_TREE);
}
/* FIXME: Note reversed argument order. */
diff --git a/gcc/lto-function-out.c b/gcc/lto-function-out.c
index 41ace08..e3d61dd 100644
--- a/gcc/lto-function-out.c
+++ b/gcc/lto-function-out.c
@@ -2394,7 +2394,7 @@ lto_debug_tree_flags (struct lto_debug_context *context,
/* Serialization of global types and declarations. */
-void output_tree (struct output_block *, tree);
+static void output_tree_with_context (struct output_block *, tree, tree);
void output_type_tree (struct output_block *, tree);
/* Output the start of a record with TAG and possibly flags for EXPR,
@@ -2571,7 +2571,7 @@ output_function_decl (struct output_block *ob, tree decl)
/* saved_tree -- this is a function body, so omit it here */
output_tree (ob, decl->decl_non_common.arguments);
- output_tree (ob, decl->decl_non_common.result);
+ output_tree_with_context (ob, decl->decl_non_common.result, decl);
output_tree (ob, decl->decl_non_common.vindex);
/* omit initial -- should be written with body */
@@ -2703,7 +2703,7 @@ output_parm_decl (struct output_block *ob, tree decl)
}
static void
-output_result_decl (struct output_block *ob, tree decl)
+output_result_decl (struct output_block *ob, tree decl, tree fn)
{
/* tag and flags */
output_global_record_start (ob, NULL, NULL, LTO_result_decl);
@@ -2713,8 +2713,10 @@ output_result_decl (struct output_block *ob, tree decl)
/* uid and locus are handled specially */
output_tree (ob, decl->decl_minimal.name);
- output_tree (ob, decl->decl_minimal.context);
-
+
+ /* FIXME lto: We should probably set this to NULL in reset_lang_specifics. */
+ gcc_assert (decl->decl_minimal.context == fn);
+
output_tree (ob, decl->common.type);
output_tree (ob, decl->decl_common.attributes);
@@ -3042,11 +3044,11 @@ output_global_constructor (struct output_block *ob, tree ctor)
}
}
+/* Emit tree node EXPR to output block OB. If relevant, the DECL_CONTEXT
+ is asserted to be FN. */
-/* Emit tree node EXPR to output block OB. */
-
-void
-output_tree (struct output_block *ob, tree expr)
+static void
+output_tree_with_context (struct output_block *ob, tree expr, tree fn)
{
enum tree_code code;
enum tree_code_class klass;
@@ -3284,7 +3286,7 @@ output_tree (struct output_block *ob, tree expr)
break;
case RESULT_DECL:
- output_result_decl (ob, expr);
+ output_result_decl (ob, expr, fn);
break;
case TYPE_DECL:
@@ -3491,6 +3493,14 @@ output_tree (struct output_block *ob, tree expr)
LTO_DEBUG_UNDENT ();
}
+/* Emit tree node EXPR to output block OB. */
+void
+output_tree (struct output_block *ob, tree expr)
+{
+ output_tree_with_context (ob, expr, NULL_TREE);
+}
+
+
/* Replacement for output_type_ref when serializing globals. */
void
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index b7885e6..cb382c2 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1577,6 +1577,7 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
t = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_IGNORED_P (t) = 1;
+ DECL_CONTEXT (t) = decl;
DECL_RESULT (decl) = t;
t = build_decl (PARM_DECL, get_identifier (".omp_data_i"), ptr_type_node);