Hello Jakub, hi Honza, On 8/31/20 5:53 PM, Jakub Jelinek wrote: > On Mon, Aug 03, 2020 at 05:37:40PM +0200, Tobias Burnus wrote: >> It turned out that the omp_discover_declare_target_tgt_fn_r >> discovered all nodes – but as it tagged the C++ alias nodes >> and not the streamed-out nodes, no device function was created ... >> if (node != NULL) >> { >> + if (node->cpp_implicit_alias) >> + { >> + node = node->get_alias_target (); >> + if (!omp_declare_target_fn_p (node->decl)) >> + ((vec *) data)->safe_push (node->decl); >> + DECL_ATTRIBUTES (node->decl) >> + = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (node->decl)); >> + } >> node->offloadable = 1; > I don't see what is special on cpp_implicit_alias here, compared to any > other aliases. > So, I wonder if the code shouldn't do: > ... Granted that cpp_implicit_alias is not special; however, for the alias attribute, the name is different and, thus, the decl is in a different sym node. Updated version attached. Does it seem to make sense? Tobias > tree decl = *tp; > symtab_node *node = symtab_node::get (decl); > if (node != NULL) > { > symtab_node *anode = node->ultimate_alias_target (); > if (anode && anode != node) > { > decl = anode->decl; > gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); > if (omp_declare_target_fn_p (*tp) > || lookup_attribute ("omp declare target host", > DECL_ATTRIBUTES (decl))) > return NULL_TREE; > node = anode; > } > } > tree id = get_identifier ("omp declare target"); > if (!DECL_EXTERNAL (decl) && DECL_SAVED_TREE (decl)) > ((vec *) data)->safe_push (decl); > DECL_ATTRIBUTES (decl) = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (decl)); > if (node != NULL) > { > node->offloadable = 1; > if (ENABLE_OFFLOADING) > g->have_offload = true; > } > > Otherwise, if we have say: > void foo () { } > void bar () __attribute__((alias ("foo"))); > void baz () __attribute__((alias ("bar"))); > int > main () > { > #pragma omp target > baz (); > } > we won't mark foo as being declare target. > Though, maybe that is not enough and we need to mark all the aliases from > node to the ultimate alias that way (so perhaps instead iterate one > get_alias_target (if node->alias) by one and mark all the decls the way the > code marks right now (i.e. pushes those non-DECL_EXTERNAL with > DECL_SAVED_TREE for further processing and add attributes to all of them? > > Jakub ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter