if (TREE_CODE (*tp) == FUNCTION_DECL)
{
tree decl = *tp;
+ tree id = get_identifier ("omp declare target");
symtab_node *node = symtab_node::get (*tp);
if (node != NULL)
{
- /* First, find final FUNCTION_DECL; find final alias target and there
- ensure alias like cpp_implicit_alias are resolved by calling
- ultimate_alias_target; the latter does not resolve alias_target as
- node->analyzed = 0. */
- symtab_node *orig_node = node;
while (node->alias_target)
- node = symtab_node::get (node->alias_target);
- node = node->ultimate_alias_target ();
- decl = node->decl;
-
- if (omp_declare_target_fn_p (decl)
- || lookup_attribute ("omp declare target host",
- DECL_ATTRIBUTES (decl)))
- return NULL_TREE;
-
- if (ENABLE_OFFLOADING)
- g->have_offload = true;
-
- /* Now mark original node and all alias targets for offloading. */
- node->offloadable = 1;
- if (orig_node != node)
{
- tree id = get_identifier ("omp declare target");
- while (orig_node->alias_target)
+ if (!omp_declare_target_fn_p (node->decl)
+ && !lookup_attribute ("omp declare target host",
+ DECL_ATTRIBUTES (node->decl)))
{
- orig_node = orig_node->ultimate_alias_target ();
- orig_node->offloadable = 1;
- DECL_ATTRIBUTES (orig_node->decl)
- = tree_cons (id, NULL_TREE,
- DECL_ATTRIBUTES (orig_node->decl));
- orig_node = symtab_node::get (orig_node->alias_target);
+ node->offloadable = 1;
+ DECL_ATTRIBUTES (node->decl)
+ = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (node->decl));
}
+ node = symtab_node::get (node->alias_target);
}
+ symtab_node *new_node = node->ultimate_alias_target ();
+ decl = new_node->decl;
+ while (node != new_node)
+ {
+ if (!omp_declare_target_fn_p (node->decl)
+ && !lookup_attribute ("omp declare target host",
+ DECL_ATTRIBUTES (node->decl)))
+ {
+ node->offloadable = 1;
+ DECL_ATTRIBUTES (node->decl)
+ = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (node->decl));
+ }
+ gcc_assert (node->alias && node->analyzed);
+ node = node->get_alias_target ();
+ }
+ node->offloadable = 1;
+ if (ENABLE_OFFLOADING)
+ g->have_offload = true;
}
- else if (omp_declare_target_fn_p (decl)
- || lookup_attribute ("omp declare target host",
+ if (omp_declare_target_fn_p (decl)
+ || lookup_attribute ("omp declare target host",
DECL_ATTRIBUTES (decl)))
return NULL_TREE;
- tree id = get_identifier ("omp declare target");
if (!DECL_EXTERNAL (decl) && DECL_SAVED_TREE (decl))
((vec<tree> *) data)->safe_push (decl);
DECL_ATTRIBUTES (decl) = tree_cons (id, NULL_TREE,