On 11/13/2014 05:06 AM, Jan Hubicka wrote:
this patch adds infrastructure for proper streaming and merging of
TREE_TARGET_OPTION.
This breaks the offloading path via LTO since it introduces an
incompatibility in LTO format between host and offload machine.
A very quick patch to fix it is below - the OpenACC testcase I was using
seems to be working again with this. Thoughts, suggestions?
Bernd
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index be041e9..3c4b8c9 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -65,7 +65,7 @@ along with GCC; see the file COPYING3. If not see
#include "streamer-hooks.h"
#include "cfgloop.h"
#include "builtins.h"
-
+#include "lto-section-names.h"
static void lto_write_tree (struct output_block*, tree, bool);
@@ -944,7 +944,9 @@ hash_tree (struct streamer_tree_cache_d *cache, hash_map<tree, hashval_t> *map,
hstate.add (TRANSLATION_UNIT_LANGUAGE (t),
strlen (TRANSLATION_UNIT_LANGUAGE (t)));
- if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
+ if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)
+ /* We don't stream these when passing things to a different target. */
+ && strcmp (section_name_prefix, LTO_SECTION_NAME_PREFIX) == 0)
hstate.add_wide_int (cl_target_option_hash (TREE_TARGET_OPTION (t)));
if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index a2a2382..88d36d3 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -514,8 +514,10 @@ unpack_value_fields (struct data_in *data_in, struct bitpack_d *bp, tree expr)
vec_safe_grow (CONSTRUCTOR_ELTS (expr), length);
}
+#ifndef ACCEL_COMPILER
if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
cl_target_option_stream_in (data_in, bp, TREE_TARGET_OPTION (expr));
+#endif
if (code == OMP_CLAUSE)
unpack_ts_omp_clause_value_fields (data_in, bp, expr);
@@ -779,7 +781,9 @@ lto_input_ts_function_decl_tree_pointers (struct lto_input_block *ib,
DECL_VINDEX (expr) = stream_read_tree (ib, data_in);
/* DECL_STRUCT_FUNCTION is loaded on demand by cgraph_get_body. */
DECL_FUNCTION_PERSONALITY (expr) = stream_read_tree (ib, data_in);
+#ifndef ACCEL_COMPILER
DECL_FUNCTION_SPECIFIC_TARGET (expr) = stream_read_tree (ib, data_in);
+#endif
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = stream_read_tree (ib, data_in);
/* If the file contains a function with an EH personality set,
diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c
index b959454..fca101e 100644
--- a/gcc/tree-streamer-out.c
+++ b/gcc/tree-streamer-out.c
@@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-streamer.h"
#include "data-streamer.h"
#include "streamer-hooks.h"
+#include "lto-section-names.h"
/* Output the STRING constant to the string
table in OB. Then put the index onto the INDEX_STREAM. */
@@ -463,7 +464,9 @@ streamer_pack_tree_bitfields (struct output_block *ob,
if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
bp_pack_var_len_unsigned (bp, CONSTRUCTOR_NELTS (expr));
- if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
+ if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)
+ /* Don't stream these when passing things to a different target. */
+ && strcmp (section_name_prefix, LTO_SECTION_NAME_PREFIX) == 0)
cl_target_option_stream_out (ob, bp, TREE_TARGET_OPTION (expr));
if (code == OMP_CLAUSE)
@@ -678,7 +681,9 @@ write_ts_function_decl_tree_pointers (struct output_block *ob, tree expr,
stream_write_tree (ob, DECL_VINDEX (expr), ref_p);
/* DECL_STRUCT_FUNCTION is handled by lto_output_function. */
stream_write_tree (ob, DECL_FUNCTION_PERSONALITY (expr), ref_p);
- stream_write_tree (ob, DECL_FUNCTION_SPECIFIC_TARGET (expr), ref_p);
+ /* Don't stream these when passing things to a different target. */
+ if (strcmp (section_name_prefix, LTO_SECTION_NAME_PREFIX) == 0)
+ stream_write_tree (ob, DECL_FUNCTION_SPECIFIC_TARGET (expr), ref_p);
stream_write_tree (ob, DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr), ref_p);
}