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

--- Comment #3 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> 
---
Author: rsandifo
Date: Tue Aug 13 21:35:10 2019
New Revision: 274403

URL: https://gcc.gnu.org/viewcvs?rev=274403&root=gcc&view=rev
Log:
Protect some checks of DECL_FUNCTION_CODE

This patch protects various uses of DECL_FUNCTION_CODE that didn't
obviously check for BUILT_IN_NORMAL first (either directly or in callers).
They could therefore trigger for functions that either aren't built-ins
or are a different kind of built-in.

Also, the patch removes a redundant GIMPLE_CALL check from
optimize_stdarg_builtin, since it gave the impression that the stmt
was less well checked than it actually is.

2019-08-13  Richard Sandiford  <richard.sandif...@arm.com>

gcc/
        PR middle-end/91421
        * attribs.c (decl_attributes): Check the DECL_BUILT_IN_CLASS
        before the DECL_FUNCTION_CODE.
        * calls.c (maybe_warn_alloc_args_overflow): Use fndecl_built_in_p
        to check for a BUILT_IN_ALLOCA call.
        * ipa-cp.c (ipa_get_indirect_edge_target_1): Likewise for
        BUILT_IN_UNREACHABLE.  Don't check for a FUNCTION_TYPE.
        * ipa-devirt.c (possible_polymorphic_call_target_p): Likewise.
        * ipa-prop.c (try_make_edge_direct_virtual_call): Likewise.
        * gimple-ssa-isolate-paths.c (is_addr_local): Check specifically
        for BUILT_IN_NORMAL functions.
        * trans-mem.c (expand_block_edges): Use gimple_call_builtin_p to
        test for BUILT_IN_TM_ABORT.
        * tree-ssa-ccp.c (optimize_stack_restore): Use fndecl_built_in_p
        to check for a BUILT_IN_STACK_RESTORE call.
        (optimize_stdarg_builtin): Remove redundant check for GIMPLE_CALL.
        * tree-ssa-threadedge.c
        (record_temporary_equivalences_from_stmts_at_dest): Check for a
        BUILT_IN_NORMAL decl before checking its DECL_FUNCTION_CODE.
        * tree-vect-patterns.c (vect_recog_pow_pattern): Use a positive
        test for a BUILT_IN_NORMAL call instead of a negative test for
        an internal function call.

gcc/c/
        PR middle-end/91421
        * c-decl.c (header_for_builtin_fn): Take a FUNCTION_DECL instead
        of a built_in_function.
        (diagnose_mismatched_decls, implicitly_declare): Update accordingly.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/attribs.c
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/calls.c
    trunk/gcc/gimple-ssa-isolate-paths.c
    trunk/gcc/ipa-cp.c
    trunk/gcc/ipa-devirt.c
    trunk/gcc/ipa-prop.c
    trunk/gcc/trans-mem.c
    trunk/gcc/tree-ssa-ccp.c
    trunk/gcc/tree-ssa-threadedge.c
    trunk/gcc/tree-vect-patterns.c

Reply via email to