https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95622
--- Comment #9 from rguenther at suse dot de <rguenther at suse dot de> --- On Thu, 25 Mar 2021, burnus at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95622 > > --- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> --- > I am not sure whether this is a sensible solution, but it fixes > the issue for c-c++-common/goacc/kernels-alias-ipa-pta-2.c ... > > > diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c > index 529ec3a5b80..c93e9b46d8d 100644 > --- a/gcc/tree-ssa-structalias.c > +++ b/gcc/tree-ssa-structalias.c > @@ -8132,7 +8132,7 @@ refered_from_nonlocal_fn (struct cgraph_node *node, void > *data) > *nonlocal_p |= (node->used_from_other_partition > || DECL_EXTERNAL (node->decl) > || TREE_PUBLIC (node->decl) > - || node->force_output > + || (node->force_output && !node->offloadable) > || lookup_attribute ("noipa", DECL_ATTRIBUTES > (node->decl))); > return false; > } > @@ -8195,7 +8195,7 @@ ipa_pta_execute (void) > bool nonlocal_p = (node->used_from_other_partition > || DECL_EXTERNAL (node->decl) > || TREE_PUBLIC (node->decl) > - || node->force_output > + || (node->force_output && !node->offloadable) > || lookup_attribute ("noipa", > DECL_ATTRIBUTES (node->decl))); > node->call_for_symbol_thunks_and_aliases (refered_from_nonlocal_fn, It's for sure incorrect since node->force_output could be set for other reasons. But of course the reason for the node->force_output check is that it is set by __attribute__((used)) which means a function/variable can be invoked/accessed by means not visible to the compiler. As said elsewhere the "fix" is to make the offload reference visible to IPA early enough.