Hi! While working on this patch, I've noticed the need to do:
On Fri, May 20, 2016 at 06:12:44PM +0200, Jakub Jelinek wrote: > * varpool.c (varpool_node::get_create): Set node->offloading > even for DECL_EXTERNAL decls. ... > --- gcc/varpool.c.jj 2016-05-04 18:43:25.000000000 +0200 > +++ gcc/varpool.c 2016-05-20 12:18:14.636755302 +0200 > @@ -149,11 +149,11 @@ varpool_node::get_create (tree decl) > node = varpool_node::create_empty (); > node->decl = decl; > > - if ((flag_openacc || flag_openmp) && !DECL_EXTERNAL (decl) > + if ((flag_openacc || flag_openmp) > && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl))) > { > node->offloadable = 1; > - if (ENABLE_OFFLOADING) > + if (ENABLE_OFFLOADING && !DECL_EXTERNAL (decl)) > { > g->have_offload = true; > if (!in_lto_p) but that made me think on what handling do we want for the "omp declare target" DECL_EXTERNAL vars. The reason I needed the above is that both gimplify.c and omp-low.c test just the node->offloadable flag, bit the attribute, and so when it is external and the flag wasn't set, we could privatize the vars even when we were supposed to map them etc. In the C/C++ FEs, we set not just node->offloadable, but also for ENABLE_OFFLOADING g->have_offload and offload_vars too. Wonder if that means we register even non-local vars, that would be IMHO a bug. On the other side, we need to watch for an extern declaration of a VAR_DECL marked for offloading and only later on locally defined, in that case if we haven't set g->have_offload and added entry to offload_vars, we'd need to do it when merging the extern decl with the definition. So, your thoughts on that? Jakub