On Wed, Mar 10, 2021 at 03:20:42PM +0100, Tobias Burnus wrote:
> The C/C++ FE sets for an 'omp declare target' ... 'omp end declare target'
> the attribute 'omp declare target implicit'.
> 
> That's later processed (for C++) in decl.c - which remove that attribute
> and either keeps and explicit 'omp declare target' or 'omp declare target 
> link'
> attribute.
> 
> Unfortunately, adding 'omp declare target' comes too late as the varpool
> has been generated.

Looking attributes on every get rather than just once is IMHO too expensive.
For explicit declare target, we use:
          symtab_node *node = symtab_node::get (t);
          if (node != NULL)
            {
              node->offloadable = 1;
              if (ENABLE_OFFLOADING)
                {
                  g->have_offload = true;
                  if (is_a <varpool_node *> (node))
                    vec_safe_push (offload_vars, t);
                }
            }
(e.g. from cp/parser.c).
So, I think it would be better to do the same thing when we turn
an "omp declare target implicit" into "omp declare target", i.e. in
cp/decl.c (cp_finish_decl) and in c/c-decl.c (finish_decl) - right
after adding the "omp declare target" attribute in there.

        Jakub

Reply via email to