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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:71770a0ea920641c53912f725f5abd4413b38fd5

commit r12-8017-g71770a0ea920641c53912f725f5abd4413b38fd5
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Apr 6 10:07:26 2022 +0200

    gimple.cc: Adjust gimple_call_builtin_p and gimple_call_combined_fn
[PR105150]

    On Tue, Apr 05, 2022 at 11:28:53AM +0200, Richard Biener wrote:
    > > In GIMPLE, we call:
    > >   && gimple_builtin_call_types_compatible_p (stmt, fndecl)
    > > but that is insufficient, that verifies whether the arguments passed to
    > > GIMPLE_CALL match the fndecl argument types.  But that fndecl may very
well
    > > be the user declaration, so doesn't have to match exactly the builtin
    > > as predeclared by builtins.def etc. (though, there is the cotcha that
say
    > > for FILE * we just use void * etc.).  So e.g. in tree-ssa-strlen.cc
    > > we use additional:
    > >   tree callee = gimple_call_fndecl (stmt);
    > >   tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (callee));
    > >   if (decl
    > >       && decl != callee
    > >       && !gimple_builtin_call_types_compatible_p (stmt, decl))
    > >     return false;
    >
    > Yeah, I think we should use that (and only that) function decl
    > in get_call_combined_fn and gimple_call_combined_fn until the
    > frontend stops slapping wrong BUILT_IN_* on random decls.

    So, as a preparation step, this patch adjusts gimple_call_builtin_p
    and gimple_call_combined_fn so that they check argument types against
    the builtin_decl_explicit TYPE_ARG_TYPES rather than against the
    actual used fndecl.

    2022-04-06  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/105150
            * gimple.cc (gimple_call_builtin_p, gimple_call_combined_fn):
            For BUILT_IN_NORMAL calls, call
gimple_builtin_call_types_compatible_p
            preferrably on builtin_decl_explicit decl rather than fndecl.
            * tree-ssa-strlen.cc (valid_builtin_call): Don't call
            gimple_builtin_call_types_compatible_p here.

Reply via email to