https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91287

--- Comment #30 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 2 Aug 2019, luoxhu at cn dot ibm.com wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91287
> 
> --- Comment #28 from Xiong Hu XS Luo <luoxhu at cn dot ibm.com> ---
> (In reply to Richard Biener from comment #24)
> > Btw, this is controlled by symtab_node::output_to_lto_symbol_table_p which
> > has
> > 
> >   /* FIXME: Builtins corresponding to real functions probably should have
> >      symbol table entries.  */
> >   if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl))
> >     return false;
> > 
> > we could try to do sth like
> > 
> >   if (TREE_CODE (decl) == FUNCTION_DECL
> >       && (fndecl_built_in_p (decl, BUILT_IN_MD)
> >           || (fndecl_built_in_p (decl, BUILT_IN_NORMAL)
> >               && !associated_internal_fn (decl))))
> >     return false;
> > 
> > but that would still leave us with too many undefineds I guess
> > (gcc_unreachable for one).
> > 
> > We do not currently track builtins that do have a library implementation
> > (whether that it is used in the end is another thing, but less important).
> > 
> > What we definitely can do is put a whitelist above like via the following
> > which also catches the case of definitions of builtins.
> > 
> > Index: gcc/symtab.c
> > ===================================================================
> > --- gcc/symtab.c        (revision 273968)
> > +++ gcc/symtab.c        (working copy)
> > @@ -2375,10 +2375,24 @@ symtab_node::output_to_lto_symbol_table_
> >       first place.  */
> >    if (VAR_P (decl) && DECL_HARD_REGISTER (decl))
> >      return false;
> > +
> >    /* FIXME: Builtins corresponding to real functions probably should have
> >       symbol table entries.  */
> > -  if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl))
> > -    return false;
> > +  if (TREE_CODE (decl) == FUNCTION_DECL
> > +      && !definition
> > +      && fndecl_built_in_p (decl))
> > +    {
> > +      if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
> > +       switch (DECL_FUNCTION_CODE (decl))
> > +         {
> > +         CASE_FLT_FN (BUILT_IN_ATAN2):
> > +         CASE_FLT_FN (BUILT_IN_SIN):
> > +           return true;
> > +         default:
> > +           break;
> > +         }
> > +      return false;
> > +    }
> >  
> >    /* We have real symbol that should be in symbol table.  However try to
> > trim
> >       down the refernces to libraries bit more because linker will otherwise
> 
> Hi Richard, no undefineds generated with below code, what's your opinion about
> the updated code, please? Thanks.

It will break code calling __builtin_unreachable for example since
we'll emit an UNDEF that cannot be satisfied.

Reply via email to