From 46dbeb4085e4a5492579d06641d0aae25b80b465 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 26 Mar 2018 09:45:49 +0000 Subject: Fix switch conversion in offloading functions 2018-03-26 Tom de Vries PR tree-optimization/85063 * omp-general.c (offloading_function_p): New function. Factor out of ... * omp-offload.c (pass_omp_target_link::gate): ... here. * omp-general.h (offloading_function_p): Declare. * tree-switch-conversion.c (build_one_array): Mark CSWTCH.x variable with attribute omp declare target for offloading functions. * testsuite/libgomp.c/switch-conversion-2.c: New test. * testsuite/libgomp.c/switch-conversion.c: New test. * testsuite/libgomp.oacc-c-c++-common/switch-conversion-2.c: New test. * testsuite/libgomp.oacc-c-c++-common/switch-conversion.c: New test. From-SVN: r258852 --- gcc/tree-switch-conversion.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/tree-switch-conversion.c') diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 2da7068345c..b0470ef1b5e 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -49,6 +49,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "alloc-pool.h" #include "target.h" #include "tree-into-ssa.h" +#include "omp-general.h" /* ??? For lang_hooks.types.type_for_mode, but is there a word_mode type in the GIMPLE type system that is language-independent? */ @@ -1162,6 +1163,10 @@ build_one_array (gswitch *swtch, int num, tree arr_index_type, TREE_CONSTANT (decl) = 1; TREE_READONLY (decl) = 1; DECL_IGNORED_P (decl) = 1; + if (offloading_function_p (cfun->decl)) + DECL_ATTRIBUTES (decl) + = tree_cons (get_identifier ("omp declare target"), NULL_TREE, + NULL_TREE); varpool_node::finalize_decl (decl); fetch = build4 (ARRAY_REF, value_type, decl, tidx, NULL_TREE, -- cgit v1.2.3