On Wed, Sep 23, 2020 at 03:52:12PM +0200, Tobias Burnus wrote: > + if (TREE_CODE (*tp) == FUNCTION_DECL) > { > + tree decl = *tp; > tree id = get_identifier ("omp declare target"); > - if (!DECL_EXTERNAL (*tp) && DECL_SAVED_TREE (*tp)) > - ((vec<tree> *) data)->safe_push (*tp); > - DECL_ATTRIBUTES (*tp) = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES > (*tp)); > symtab_node *node = symtab_node::get (*tp); > if (node != NULL) > { > + while (node->alias_target) > + { > + if (node->cpp_implicit_alias) > + node = node->get_alias_target (); > + 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)); > + } > + node = symtab_node::get (node->alias_target); > + } > + if (node->cpp_implicit_alias) > + node = node->get_alias_target ();
Almost, the problem is that node with node->cpp_implicit_alias isn't marked then. And, the > + if (node->cpp_implicit_alias) > + node = node->get_alias_target (); in the while loop looks problematic, not sure if it is ever possible to have both alias_target and cpp_implicit_alias set, but if it would be, there is no guarantee that node->get_alias_target ()->alias_target must be non-NULL. What I really meant was: > + while (node->alias_target) > + { > + 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)); > + } > + node = symtab_node::get (node->alias_target); > + } > + cgraph_node *new_node = node->get_ultimate_target (); > + if (new_node != node) > + { > + 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 (); > + } > + } Jakub