aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto-cgraph.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2018-12-14 13:48:56 +0000
committerTom de Vries <vries@gcc.gnu.org>2018-12-14 13:48:56 +0000
commitb0aba46ca6668ef16fa83ff146654a9bf946ff16 (patch)
tree2d768b42e3a31f9210ad81e2e41b2466bd284d01 /gcc/lto-cgraph.c
parent4f472e636f7e99c3bca2fb70bd5adc2bb07dad3d (diff)
downloadgcc-b0aba46ca6668ef16fa83ff146654a9bf946ff16.zip
gcc-b0aba46ca6668ef16fa83ff146654a9bf946ff16.tar.gz
gcc-b0aba46ca6668ef16fa83ff146654a9bf946ff16.tar.bz2
[offloading] Error on missing symbols
When compiling an OpenMP or OpenACC program containing a reference in the offloaded code to a symbol that has not been included in the offloaded code, the offloading compiler may ICE in lto1. Fix this by erroring out instead, mentioning the problematic symbol: ... error: variable 'var' has been referenced in offloaded code but hasn't been marked to be included in the offloaded code lto1: fatal error: errors during merging of translation units compilation terminated. ... Build x86_64 with nvptx accelerator and reg-tested libgomp. Build x86_64 and reg-tested libgomp. 2018-12-14 Tom de Vries <tdevries@suse.de> * lto-cgraph.c (verify_node_partition): New function. (input_overwrite_node, input_varpool_node): Use verify_node_partition. * testsuite/libgomp.c-c++-common/function-not-offloaded-aux.c: New test. * testsuite/libgomp.c-c++-common/function-not-offloaded.c: New test. * testsuite/libgomp.c-c++-common/variable-not-offloaded.c: New test. * testsuite/libgomp.oacc-c-c++-common/function-not-offloaded.c: New test. * testsuite/libgomp.oacc-c-c++-common/variable-not-offloaded.c: New test. From-SVN: r267134
Diffstat (limited to 'gcc/lto-cgraph.c')
-rw-r--r--gcc/lto-cgraph.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 99998cc3..536e73c 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -1091,6 +1091,36 @@ output_offload_tables (void)
}
}
+/* Verify the partitioning of NODE. */
+
+static inline void
+verify_node_partition (symtab_node *node)
+{
+ if (flag_ltrans)
+ return;
+
+#ifdef ACCEL_COMPILER
+ if (node->in_other_partition)
+ {
+ if (TREE_CODE (node->decl) == FUNCTION_DECL)
+ error_at (DECL_SOURCE_LOCATION (node->decl),
+ "function %qs has been referenced in offloaded code but"
+ " hasn%'t been marked to be included in the offloaded code",
+ node->name ());
+ else if (VAR_P (node->decl))
+ error_at (DECL_SOURCE_LOCATION (node->decl),
+ "variable %qs has been referenced in offloaded code but"
+ " hasn%'t been marked to be included in the offloaded code",
+ node->name ());
+ else
+ gcc_unreachable ();
+ }
+#else
+ gcc_assert (!node->in_other_partition
+ && !node->used_from_other_partition);
+#endif
+}
+
/* Overwrite the information in NODE based on FILE_DATA, TAG, FLAGS,
STACK_SIZE, SELF_TIME and SELF_SIZE. This is called either to initialize
NODE or to replace the values in it, for instance because the first
@@ -1153,9 +1183,7 @@ input_overwrite_node (struct lto_file_decl_data *file_data,
node->resolution = bp_unpack_enum (bp, ld_plugin_symbol_resolution,
LDPR_NUM_KNOWN);
node->split_part = bp_unpack_value (bp, 1);
- gcc_assert (flag_ltrans
- || (!node->in_other_partition
- && !node->used_from_other_partition));
+ verify_node_partition (node);
}
/* Return string alias is alias of. */
@@ -1366,10 +1394,7 @@ input_varpool_node (struct lto_file_decl_data *file_data,
node->set_section_for_node (section);
node->resolution = streamer_read_enum (ib, ld_plugin_symbol_resolution,
LDPR_NUM_KNOWN);
- gcc_assert (flag_ltrans
- || (!node->in_other_partition
- && !node->used_from_other_partition));
-
+ verify_node_partition (node);
return node;
}