Come up with fndecl_built_in_p.
authorMartin Liska <mliska@suse.cz>
Mon, 27 Aug 2018 12:34:52 +0000 (14:34 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 27 Aug 2018 12:34:52 +0000 (12:34 +0000)
2018-08-27  Martin Liska  <mliska@suse.cz>

* builtins.h (is_builtin_fn): Remove and fndecl_built_in_p.
* builtins.c (is_builtin_fn): Likewise.
* attribs.c (diag_attr_exclusions): Use new function
        fndecl_built_in_p and remove check for FUNCTION_DECL if
        possible.
(builtin_mathfn_code): Likewise.
(fold_builtin_expect): Likewise.
(fold_call_expr): Likewise.
(fold_builtin_call_array): Likewise.
(fold_call_stmt): Likewise.
(set_builtin_user_assembler_name): Likewise.
(is_simple_builtin): Likewise.
* calls.c (gimple_alloca_call_p): Likewise.
(maybe_warn_nonstring_arg): Likewise.
* cfgexpand.c (expand_call_stmt): Likewise.
* cgraph.c (cgraph_update_edges_for_call_stmt_node): Likewise.
(cgraph_edge::verify_corresponds_to_fndecl): Likewise.
(cgraph_node::verify_node): Likewise.
* cgraphclones.c (build_function_decl_skip_args): Likewise.
(cgraph_node::create_clone): Likewise.
* config/arm/arm.c (arm_insert_attributes): Likewise.
* config/i386/i386.c (ix86_gimple_fold_builtin): Likewise.
* dse.c (scan_insn): Likewise.
* expr.c (expand_expr_real_1): Likewise.
* fold-const.c (operand_equal_p): Likewise.
(fold_binary_loc): Likewise.
* gimple-fold.c (gimple_fold_stmt_to_constant_1): Likewise.
* gimple-low.c (lower_stmt): Likewise.
* gimple-pretty-print.c (dump_gimple_call): Likewise.
* gimple-ssa-warn-restrict.c (wrestrict_dom_walker::check_call): Likewise.
* gimple.c (gimple_build_call_from_tree): Likewise.
(gimple_call_builtin_p): Likewise.
(gimple_call_combined_fn): Likewise.
* gimplify.c (gimplify_call_expr): Likewise.
(gimple_boolify): Likewise.
(gimplify_modify_expr): Likewise.
(gimplify_addr_expr): Likewise.
* hsa-gen.c (gen_hsa_insns_for_call): Likewise.
* ipa-cp.c (determine_versionability): Likewise.
* ipa-fnsummary.c (compute_fn_summary): Likewise.
* ipa-param-manipulation.c (ipa_modify_formal_parameters): Likewise.
* ipa-split.c (visit_bb): Likewise.
(split_function): Likewise.
* ipa-visibility.c (cgraph_externally_visible_p): Likewise.
* lto-cgraph.c (input_node): Likewise.
* lto-streamer-out.c (write_symbol): Likewise.
* omp-low.c (setjmp_or_longjmp_p): Likewise.
(lower_omp_1): Likewise.
* predict.c (strip_predict_hints): Likewise.
* print-tree.c (print_node): Likewise.
* symtab.c (symtab_node::output_to_lto_symbol_table_p): Likewise.
* trans-mem.c (is_tm_irrevocable): Likewise.
(is_tm_load): Likewise.
(is_tm_simple_load): Likewise.
(is_tm_store): Likewise.
(is_tm_simple_store): Likewise.
(is_tm_abort): Likewise.
(tm_region_init_1): Likewise.
* tree-call-cdce.c (gen_shrink_wrap_conditions): Likewise.
* tree-cfg.c (verify_gimple_call): Likewise.
(move_stmt_r): Likewise.
(stmt_can_terminate_bb_p): Likewise.
* tree-eh.c (lower_eh_constructs_2): Likewise.
* tree-if-conv.c (if_convertible_stmt_p): Likewise.
* tree-inline.c (remap_gimple_stmt): Likewise.
(copy_bb): Likewise.
(estimate_num_insns): Likewise.
(fold_marked_statements): Likewise.
* tree-sra.c (scan_function): Likewise.
* tree-ssa-ccp.c (surely_varying_stmt_p): Likewise.
(optimize_stack_restore): Likewise.
(pass_fold_builtins::execute): Likewise.
* tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Likewise.
(mark_all_reaching_defs_necessary_1): Likewise.
* tree-ssa-dom.c (dom_opt_dom_walker::optimize_stmt): Likewise.
* tree-ssa-forwprop.c (simplify_builtin_call): Likewise.
(pass_forwprop::execute): Likewise.
* tree-ssa-loop-im.c (stmt_cost): Likewise.
* tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Likewise.
* tree-ssa-sccvn.c (fully_constant_vn_reference_p): Likewise.
* tree-ssa-strlen.c (get_string_length): Likewise.
* tree-ssa-structalias.c (handle_lhs_call): Likewise.
(find_func_aliases_for_call): Likewise.
* tree-ssa-ter.c (find_replaceable_in_bb): Likewise.
* tree-stdarg.c (optimize_va_list_gpr_fpr_size): Likewise.
* tree-tailcall.c (find_tail_calls): Likewise.
* tree.c (need_assembler_name_p): Likewise.
(free_lang_data_in_decl): Likewise.
(get_call_combined_fn): Likewise.
* ubsan.c (is_ubsan_builtin_p): Likewise.
* varasm.c (incorporeal_function_p): Likewise.
* tree.h (DECL_BUILT_IN): Remove and replace with
        fndecl_built_in_p.
(DECL_BUILT_IN_P): Transfort to fndecl_built_in_p.
(fndecl_built_in_p): New.
2018-08-27  Martin Liska  <mliska@suse.cz>

* gcc-interface/decl.c (update_profile): Use new function
        fndecl_built_in_p and remove check for FUNCTION_DECL if
        possible.
* gcc-interface/gigi.h (call_is_atomic_load): Likewise.
* gcc-interface/utils.c (gnat_pushdecl): Likewise.
2018-08-27  Martin Liska  <mliska@suse.cz>

* c-common.c (check_function_restrict): Use new function
        fndecl_built_in_p and remove check for FUNCTION_DECL if
        possible.
(check_builtin_function_arguments): Likewise.
(reject_gcc_builtin): Likewise.
* c-warn.c (sizeof_pointer_memaccess_warning): Likewise.
2018-08-27  Martin Liska  <mliska@suse.cz>

* c-decl.c (locate_old_decl): Use new function
        fndecl_built_in_p and remove check for FUNCTION_DECL if
        possible.
(diagnose_mismatched_decls): Likewise.
(merge_decls): Likewise.
(warn_if_shadowing): Likewise.
(pushdecl): Likewise.
(implicitly_declare): Likewise.
* c-parser.c (c_parser_postfix_expression_after_primary): Likewise.
* c-tree.h (C_DECL_ISNT_PROTOTYPE): Likewise.
* c-typeck.c (build_function_call_vec): Likewise.
(convert_arguments): Likewise.
2018-08-27  Martin Liska  <mliska@suse.cz>

* call.c (build_call_a): Use new function
        fndecl_built_in_p and remove check for FUNCTION_DECL if
        possible.
(build_cxx_call): Likewise.
* constexpr.c (constexpr_fn_retval): Likewise.
(cxx_eval_builtin_function_call): Likewise.
(cxx_eval_call_expression): Likewise.
(potential_constant_expression_1): Likewise.
* cp-gimplify.c (cp_gimplify_expr): Likewise.
(cp_fold): Likewise.
* decl.c (decls_match): Likewise.
(validate_constexpr_redeclaration): Likewise.
(duplicate_decls): Likewise.
(make_rtl_for_nonlocal_decl): Likewise.
* name-lookup.c (consider_binding_level): Likewise.
(cp_emit_debug_info_for_using): Likewise.
* semantics.c (finish_call_expr): Likewise.
* tree.c (builtin_valid_in_constant_expr_p): Likewise.
2018-08-27  Martin Liska  <mliska@suse.cz>

* go-gcc.cc (Gcc_backend::call_expression): Use new function
        fndecl_built_in_p and remove check for FUNCTION_DECL if
        possible.
2018-08-27  Martin Liska  <mliska@suse.cz>

* lto-lang.c (handle_const_attribute): Use new function
        fndecl_built_in_p and remove check for FUNCTION_DECL if
        possible.
* lto-symtab.c (lto_symtab_merge_p): Likewise.
(lto_symtab_merge_decls_1): Likewise.
(lto_symtab_merge_symbols): Likewise.
* lto.c (lto_maybe_register_decl): Likewise.
(read_cgraph_and_symbols): Likewise.

From-SVN: r263880

80 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/ada/gcc-interface/gigi.h
gcc/ada/gcc-interface/utils.c
gcc/attribs.c
gcc/builtins.c
gcc/builtins.h
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-warn.c
gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/c/c-parser.c
gcc/c/c-tree.h
gcc/c/c-typeck.c
gcc/calls.c
gcc/cfgexpand.c
gcc/cgraph.c
gcc/cgraphclones.c
gcc/config/arm/arm.c
gcc/config/i386/i386.c
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/constexpr.c
gcc/cp/cp-gimplify.c
gcc/cp/decl.c
gcc/cp/name-lookup.c
gcc/cp/semantics.c
gcc/cp/tree.c
gcc/dse.c
gcc/expr.c
gcc/fold-const.c
gcc/gimple-fold.c
gcc/gimple-low.c
gcc/gimple-pretty-print.c
gcc/gimple-ssa-warn-restrict.c
gcc/gimple.c
gcc/gimplify.c
gcc/go/ChangeLog
gcc/go/go-gcc.cc
gcc/hsa-gen.c
gcc/ipa-cp.c
gcc/ipa-fnsummary.c
gcc/ipa-param-manipulation.c
gcc/ipa-split.c
gcc/ipa-visibility.c
gcc/lto-cgraph.c
gcc/lto-streamer-out.c
gcc/lto/ChangeLog
gcc/lto/lto-lang.c
gcc/lto/lto-symtab.c
gcc/lto/lto.c
gcc/omp-low.c
gcc/predict.c
gcc/print-tree.c
gcc/symtab.c
gcc/trans-mem.c
gcc/tree-call-cdce.c
gcc/tree-cfg.c
gcc/tree-eh.c
gcc/tree-if-conv.c
gcc/tree-inline.c
gcc/tree-sra.c
gcc/tree-ssa-ccp.c
gcc/tree-ssa-dce.c
gcc/tree-ssa-dom.c
gcc/tree-ssa-forwprop.c
gcc/tree-ssa-loop-im.c
gcc/tree-ssa-math-opts.c
gcc/tree-ssa-sccvn.c
gcc/tree-ssa-strlen.c
gcc/tree-ssa-structalias.c
gcc/tree-ssa-ter.c
gcc/tree-stdarg.c
gcc/tree-tailcall.c
gcc/tree.c
gcc/tree.h
gcc/ubsan.c
gcc/varasm.c

index 47844ef46783088590b40f9f4be78a48a61d52ff..459bcaddc079245cff4f99a1af9f2f66580eef47 100644 (file)
@@ -1,3 +1,101 @@
+2018-08-27  Martin Liska  <mliska@suse.cz>
+
+       * builtins.h (is_builtin_fn): Remove and fndecl_built_in_p.
+       * builtins.c (is_builtin_fn): Likewise.
+       * attribs.c (diag_attr_exclusions): Use new function
+        fndecl_built_in_p and remove check for FUNCTION_DECL if
+        possible.
+       (builtin_mathfn_code): Likewise.
+       (fold_builtin_expect): Likewise.
+       (fold_call_expr): Likewise.
+       (fold_builtin_call_array): Likewise.
+       (fold_call_stmt): Likewise.
+       (set_builtin_user_assembler_name): Likewise.
+       (is_simple_builtin): Likewise.
+       * calls.c (gimple_alloca_call_p): Likewise.
+       (maybe_warn_nonstring_arg): Likewise.
+       * cfgexpand.c (expand_call_stmt): Likewise.
+       * cgraph.c (cgraph_update_edges_for_call_stmt_node): Likewise.
+       (cgraph_edge::verify_corresponds_to_fndecl): Likewise.
+       (cgraph_node::verify_node): Likewise.
+       * cgraphclones.c (build_function_decl_skip_args): Likewise.
+       (cgraph_node::create_clone): Likewise.
+       * config/arm/arm.c (arm_insert_attributes): Likewise.
+       * config/i386/i386.c (ix86_gimple_fold_builtin): Likewise.
+       * dse.c (scan_insn): Likewise.
+       * expr.c (expand_expr_real_1): Likewise.
+       * fold-const.c (operand_equal_p): Likewise.
+       (fold_binary_loc): Likewise.
+       * gimple-fold.c (gimple_fold_stmt_to_constant_1): Likewise.
+       * gimple-low.c (lower_stmt): Likewise.
+       * gimple-pretty-print.c (dump_gimple_call): Likewise.
+       * gimple-ssa-warn-restrict.c (wrestrict_dom_walker::check_call): Likewise.
+       * gimple.c (gimple_build_call_from_tree): Likewise.
+       (gimple_call_builtin_p): Likewise.
+       (gimple_call_combined_fn): Likewise.
+       * gimplify.c (gimplify_call_expr): Likewise.
+       (gimple_boolify): Likewise.
+       (gimplify_modify_expr): Likewise.
+       (gimplify_addr_expr): Likewise.
+       * hsa-gen.c (gen_hsa_insns_for_call): Likewise.
+       * ipa-cp.c (determine_versionability): Likewise.
+       * ipa-fnsummary.c (compute_fn_summary): Likewise.
+       * ipa-param-manipulation.c (ipa_modify_formal_parameters): Likewise.
+       * ipa-split.c (visit_bb): Likewise.
+       (split_function): Likewise.
+       * ipa-visibility.c (cgraph_externally_visible_p): Likewise.
+       * lto-cgraph.c (input_node): Likewise.
+       * lto-streamer-out.c (write_symbol): Likewise.
+       * omp-low.c (setjmp_or_longjmp_p): Likewise.
+       (lower_omp_1): Likewise.
+       * predict.c (strip_predict_hints): Likewise.
+       * print-tree.c (print_node): Likewise.
+       * symtab.c (symtab_node::output_to_lto_symbol_table_p): Likewise.
+       * trans-mem.c (is_tm_irrevocable): Likewise.
+       (is_tm_load): Likewise.
+       (is_tm_simple_load): Likewise.
+       (is_tm_store): Likewise.
+       (is_tm_simple_store): Likewise.
+       (is_tm_abort): Likewise.
+       (tm_region_init_1): Likewise.
+       * tree-call-cdce.c (gen_shrink_wrap_conditions): Likewise.
+       * tree-cfg.c (verify_gimple_call): Likewise.
+       (move_stmt_r): Likewise.
+       (stmt_can_terminate_bb_p): Likewise.
+       * tree-eh.c (lower_eh_constructs_2): Likewise.
+       * tree-if-conv.c (if_convertible_stmt_p): Likewise.
+       * tree-inline.c (remap_gimple_stmt): Likewise.
+       (copy_bb): Likewise.
+       (estimate_num_insns): Likewise.
+       (fold_marked_statements): Likewise.
+       * tree-sra.c (scan_function): Likewise.
+       * tree-ssa-ccp.c (surely_varying_stmt_p): Likewise.
+       (optimize_stack_restore): Likewise.
+       (pass_fold_builtins::execute): Likewise.
+       * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Likewise.
+       (mark_all_reaching_defs_necessary_1): Likewise.
+       * tree-ssa-dom.c (dom_opt_dom_walker::optimize_stmt): Likewise.
+       * tree-ssa-forwprop.c (simplify_builtin_call): Likewise.
+       (pass_forwprop::execute): Likewise.
+       * tree-ssa-loop-im.c (stmt_cost): Likewise.
+       * tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Likewise.
+       * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Likewise.
+       * tree-ssa-strlen.c (get_string_length): Likewise.
+       * tree-ssa-structalias.c (handle_lhs_call): Likewise.
+       (find_func_aliases_for_call): Likewise.
+       * tree-ssa-ter.c (find_replaceable_in_bb): Likewise.
+       * tree-stdarg.c (optimize_va_list_gpr_fpr_size): Likewise.
+       * tree-tailcall.c (find_tail_calls): Likewise.
+       * tree.c (need_assembler_name_p): Likewise.
+       (free_lang_data_in_decl): Likewise.
+       (get_call_combined_fn): Likewise.
+       * ubsan.c (is_ubsan_builtin_p): Likewise.
+       * varasm.c (incorporeal_function_p): Likewise.
+       * tree.h (DECL_BUILT_IN): Remove and replace with
+        fndecl_built_in_p.
+       (DECL_BUILT_IN_P): Transfort to fndecl_built_in_p.
+       (fndecl_built_in_p): New.
+
 2018-08-27  Martin Liska  <mliska@suse.cz>
 
         PR tree-optimization/86847
index 06b11066549cbb588977115b857b1e65dc3971b6..58f336b65f25243ec27a3f00ed2a0594ca0c6921 100644 (file)
@@ -1,3 +1,11 @@
+2018-08-27  Martin Liska  <mliska@suse.cz>
+
+       * gcc-interface/decl.c (update_profile): Use new function
+        fndecl_built_in_p and remove check for FUNCTION_DECL if
+        possible.
+       * gcc-interface/gigi.h (call_is_atomic_load): Likewise.
+       * gcc-interface/utils.c (gnat_pushdecl): Likewise.
+
 2018-08-23  Giuliano Belinassi  <giuliano.belinassi@usp.br>
 
        * exp_unst.ads: Fix typo 'exapnded' to 'expanded'.
index b1dc379c24771ad796d143c0e839434baf03f8b8..6f605bd64ecdedd1b6edad8436dd5ffefed30eb4 100644 (file)
@@ -5421,7 +5421,7 @@ update_profile (Entity_Id gnat_subprog)
   if (DECL_P (gnu_type))
     {
       /* Builtins cannot have their address taken so we can reset them.  */
-      gcc_assert (DECL_BUILT_IN (gnu_type));
+      gcc_assert (fndecl_built_in_p (gnu_type));
       save_gnu_tree (gnat_subprog, NULL_TREE, false);
       save_gnu_tree (gnat_subprog, gnu_type, false);
       return;
index b890195cefc3ae031772b9524b02ec3bd06e2d1a..eb64a8bbdbde07586905c372bc4ee02d1c74c3aa 100644 (file)
@@ -1081,7 +1081,7 @@ call_is_atomic_load (tree exp)
 {
   tree fndecl = get_callee_fndecl (exp);
 
-  if (!(fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL))
+  if (!(fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)))
     return false;
 
   enum built_in_function code = DECL_FUNCTION_CODE (fndecl);
index cc1fe770f2c023715cd2a4dddc923e91c1c23be1..313d984b83dda82b62a9426049b5db3f853e1189 100644 (file)
@@ -773,7 +773,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
         debugger at the proper time.  */
       if (DECL_EXTERNAL (decl)
          && TREE_CODE (decl) == FUNCTION_DECL
-         && DECL_BUILT_IN (decl))
+         && fndecl_built_in_p (decl))
        vec_safe_push (builtin_decls, decl);
       else if (global_bindings_p ())
        vec_safe_push (global_decls, decl);
index 64700b6c8ce332d38c1dbbec744e14e4467c8d77..8b721274d3b4a7630d90c3551c7051d1a6a20cbe 100644 (file)
@@ -432,7 +432,7 @@ diag_attr_exclusions (tree last_decl, tree node, tree attrname,
          bool note = last_decl != NULL_TREE;
          auto_diagnostic_group d;
          if (TREE_CODE (node) == FUNCTION_DECL
-             && DECL_BUILT_IN (node))
+             && fndecl_built_in_p (node))
            note &= warning (OPT_Wattributes,
                             "ignoring attribute %qE in declaration of "
                             "a built-in function %qD because it conflicts "
index 6a992bd939b87dcc5f576fc06a4a3d26df035319..c4b52b9c62755a671c585c13ed08f59dab6991ef 100644 (file)
@@ -208,15 +208,6 @@ is_builtin_name (const char *name)
   return false;
 }
 
-
-/* Return true if DECL is a function symbol representing a built-in.  */
-
-bool
-is_builtin_fn (tree decl)
-{
-  return TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl);
-}
-
 /* Return true if NODE should be considered for inline expansion regardless
    of the optimization level.  This means whenever a function is invoked with
    its "internal" name, which normally contains the prefix "__builtin".  */
@@ -8154,11 +8145,8 @@ builtin_mathfn_code (const_tree t)
     return END_BUILTINS;
 
   fndecl = get_callee_fndecl (t);
-  if (fndecl == NULL_TREE
-      || TREE_CODE (fndecl) != FUNCTION_DECL
-      || ! DECL_BUILT_IN (fndecl)
-      || DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
-    return END_BUILTINS;
+  if (fndecl == NULL_TREE || !fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
+      return END_BUILTINS;
 
   parmlist = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
   init_const_call_expr_arg_iterator (t, &iter);
@@ -8313,9 +8301,8 @@ fold_builtin_expect (location_t loc, tree arg0, tree arg1, tree arg2,
 
   if (TREE_CODE (inner) == CALL_EXPR
       && (fndecl = get_callee_fndecl (inner))
-      && (DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_EXPECT)
-         || DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL,
-                             BUILT_IN_EXPECT_WITH_PROBABILITY)))
+      && (fndecl_built_in_p (fndecl, BUILT_IN_EXPECT)
+         || fndecl_built_in_p (fndecl, BUILT_IN_EXPECT_WITH_PROBABILITY)))
     return arg0;
 
   inner = inner_arg0;
@@ -9628,9 +9615,7 @@ fold_call_expr (location_t loc, tree exp, bool ignore)
 {
   tree ret = NULL_TREE;
   tree fndecl = get_callee_fndecl (exp);
-  if (fndecl
-      && TREE_CODE (fndecl) == FUNCTION_DECL
-      && DECL_BUILT_IN (fndecl)
+  if (fndecl && fndecl_built_in_p (fndecl)
       /* If CALL_EXPR_VA_ARG_PACK is set, the arguments aren't finalized
         yet.  Defer folding until we see all the arguments
         (after inlining).  */
@@ -9644,10 +9629,7 @@ fold_call_expr (location_t loc, tree exp, bool ignore)
       if (nargs && TREE_CODE (CALL_EXPR_ARG (exp, nargs - 1)) == CALL_EXPR)
        {
          tree fndecl2 = get_callee_fndecl (CALL_EXPR_ARG (exp, nargs - 1));
-         if (fndecl2
-             && TREE_CODE (fndecl2) == FUNCTION_DECL
-             && DECL_BUILT_IN_CLASS (fndecl2) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (fndecl2) == BUILT_IN_VA_ARG_PACK)
+         if (fndecl2 && fndecl_built_in_p (fndecl2, BUILT_IN_VA_ARG_PACK))
            return NULL_TREE;
        }
 
@@ -9683,17 +9665,14 @@ fold_builtin_call_array (location_t loc, tree,
 
   tree fndecl = TREE_OPERAND (fn, 0);
   if (TREE_CODE (fndecl) == FUNCTION_DECL
-      && DECL_BUILT_IN (fndecl))
+      && fndecl_built_in_p (fndecl))
     {
       /* If last argument is __builtin_va_arg_pack (), arguments to this
         function are not finalized yet.  Defer folding until they are.  */
       if (n && TREE_CODE (argarray[n - 1]) == CALL_EXPR)
        {
          tree fndecl2 = get_callee_fndecl (argarray[n - 1]);
-         if (fndecl2
-             && TREE_CODE (fndecl2) == FUNCTION_DECL
-             && DECL_BUILT_IN_CLASS (fndecl2) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (fndecl2) == BUILT_IN_VA_ARG_PACK)
+         if (fndecl2 && fndecl_built_in_p (fndecl2, BUILT_IN_VA_ARG_PACK))
            return NULL_TREE;
        }
       if (avoid_folding_inline_builtin (fndecl))
@@ -10812,9 +10791,7 @@ fold_call_stmt (gcall *stmt, bool ignore)
   tree ret = NULL_TREE;
   tree fndecl = gimple_call_fndecl (stmt);
   location_t loc = gimple_location (stmt);
-  if (fndecl
-      && TREE_CODE (fndecl) == FUNCTION_DECL
-      && DECL_BUILT_IN (fndecl)
+  if (fndecl && fndecl_built_in_p (fndecl)
       && !gimple_call_va_arg_pack_p (stmt))
     {
       int nargs = gimple_call_num_args (stmt);
@@ -10861,8 +10838,7 @@ fold_call_stmt (gcall *stmt, bool ignore)
 void
 set_builtin_user_assembler_name (tree decl, const char *asmspec)
 {
-  gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
-             && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
+  gcc_assert (fndecl_built_in_p (decl, BUILT_IN_NORMAL)
              && asmspec != 0);
 
   tree builtin = builtin_decl_explicit (DECL_FUNCTION_CODE (decl));
@@ -10882,7 +10858,7 @@ set_builtin_user_assembler_name (tree decl, const char *asmspec)
 bool
 is_simple_builtin (tree decl)
 {
-  if (decl && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+  if (decl && fndecl_built_in_p (decl, BUILT_IN_NORMAL))
     switch (DECL_FUNCTION_CODE (decl))
       {
        /* Builtins that expand to constants.  */
index 805f1801604ac25bcb93a158e96a06d7188eb3a0..c3d5ccbb6b6e61a8162de880772e94fba46ace51 100644 (file)
@@ -49,7 +49,6 @@ extern struct target_builtins *this_target_builtins;
 /* Non-zero if __builtin_constant_p should be folded right away.  */
 extern bool force_folding_builtin_constant_p;
 
-extern bool is_builtin_fn (tree);
 extern bool called_as_built_in (tree);
 extern bool get_object_alignment_1 (tree, unsigned int *,
                                    unsigned HOST_WIDE_INT *);
index f833d0a17221d2b0c054c5653e65f5b7590b3502..2ca6662c3c5fcf92dfb94dd46a7cdcef0cc83b0d 100644 (file)
@@ -1,3 +1,12 @@
+2018-08-27  Martin Liska  <mliska@suse.cz>
+
+       * c-common.c (check_function_restrict): Use new function
+        fndecl_built_in_p and remove check for FUNCTION_DECL if
+        possible.
+       (check_builtin_function_arguments): Likewise.
+       (reject_gcc_builtin): Likewise.
+       * c-warn.c (sizeof_pointer_memaccess_warning): Likewise.
+
 2018-08-26  Marek Polacek  <polacek@redhat.com>
 
        PR c++/87029, Implement -Wredundant-move.
index 95cff215d608e3b83d79f105d1ac69828ed5c72c..0b0969b5216ed4c2132b5be02024249c16a65b0f 100644 (file)
@@ -5326,8 +5326,7 @@ check_function_restrict (const_tree fndecl, const_tree fntype,
     {
       /* Avoid diagnosing calls built-ins with a zero size/bound
         here.  They are checked in more detail elsewhere.  */
-      if (DECL_BUILT_IN (fndecl)
-         && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
+      if (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
          && nargs == 3
          && TREE_CODE (argarray[2]) == INTEGER_CST
          && integer_zerop (argarray[2]))
@@ -5755,8 +5754,7 @@ bool
 check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
                                  tree fndecl, int nargs, tree *args)
 {
-  if (!DECL_BUILT_IN (fndecl)
-      || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
+  if (!fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     return true;
 
   switch (DECL_FUNCTION_CODE (fndecl))
@@ -8011,7 +8009,7 @@ reject_gcc_builtin (const_tree expr, location_t loc /* = UNKNOWN_LOCATION */)
         strlen, and for C++ operators new and delete.
         The c_decl_implicit() test avoids false positives for implicitly
         declared built-ins with library fallbacks (such as abs).  */
-      && DECL_BUILT_IN (expr)
+      && fndecl_built_in_p (expr)
       && DECL_IS_BUILTIN (expr)
       && !c_decl_implicit (expr)
       && !DECL_ASSEMBLER_NAME_SET_P (expr))
index ca259aa7bd0ca59e83d29eeae3d41d76bde221e0..95b66c1eabb41130884e2f6ab884347f58deb706 100644 (file)
@@ -702,7 +702,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee,
   location_t loc;
 
   if (TREE_CODE (callee) != FUNCTION_DECL
-      || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL
+      || !fndecl_built_in_p (callee, BUILT_IN_NORMAL)
       || vec_safe_length (params) <= 1)
     return;
 
index e943f0aac4a93a3158bf483c73ed0c9675098fcf..b3e499e58997d308d5e76d0addb80087df3e926a 100644 (file)
@@ -1,3 +1,18 @@
+2018-08-27  Martin Liska  <mliska@suse.cz>
+
+       * c-decl.c (locate_old_decl): Use new function
+        fndecl_built_in_p and remove check for FUNCTION_DECL if
+        possible.
+       (diagnose_mismatched_decls): Likewise.
+       (merge_decls): Likewise.
+       (warn_if_shadowing): Likewise.
+       (pushdecl): Likewise.
+       (implicitly_declare): Likewise.
+       * c-parser.c (c_parser_postfix_expression_after_primary): Likewise.
+       * c-tree.h (C_DECL_ISNT_PROTOTYPE): Likewise.
+       * c-typeck.c (build_function_call_vec): Likewise.
+       (convert_arguments): Likewise.
+
 2018-08-20  David Malcolm  <dmalcolm@redhat.com>
 
        PR other/84889
index 95249779e3c8350c2286f0ead1858d20f2b374ef..80647ee0207ba2e4c43a2fb490a8782ce7f6d38a 100644 (file)
@@ -1800,7 +1800,7 @@ validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype)
 static void
 locate_old_decl (tree decl)
 {
-  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl)
+  if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl)
       && !C_DECL_DECLARED_BUILTIN (decl))
     ;
   else if (DECL_INITIAL (decl))
@@ -1843,7 +1843,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
   if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
     {
       if (!(TREE_CODE (olddecl) == FUNCTION_DECL
-           && DECL_BUILT_IN (olddecl)
+           && fndecl_built_in_p (olddecl)
            && !C_DECL_DECLARED_BUILTIN (olddecl)))
        {
          auto_diagnostic_group d;
@@ -1877,7 +1877,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
   if (!comptypes (oldtype, newtype))
     {
       if (TREE_CODE (olddecl) == FUNCTION_DECL
-         && DECL_BUILT_IN (olddecl) && !C_DECL_DECLARED_BUILTIN (olddecl))
+         && fndecl_built_in_p (olddecl) && !C_DECL_DECLARED_BUILTIN (olddecl))
        {
          /* Accept harmless mismatch in function types.
             This is for the ffs and fprintf builtins.  */
@@ -2025,7 +2025,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
         define the built-in with an old-style definition (so we
         can't validate the argument list) the built-in definition is
         overridden, but optionally warn this was a bad choice of name.  */
-      if (DECL_BUILT_IN (olddecl)
+      if (fndecl_built_in_p (olddecl)
          && !C_DECL_DECLARED_BUILTIN (olddecl)
          && (!TREE_PUBLIC (newdecl)
              || (DECL_INITIAL (newdecl)
@@ -2297,8 +2297,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
           && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))
       /* Don't warn about redundant redeclarations of builtins.  */
       && !(TREE_CODE (newdecl) == FUNCTION_DECL
-          && !DECL_BUILT_IN (newdecl)
-          && DECL_BUILT_IN (olddecl)
+          && !fndecl_built_in_p (newdecl)
+          && fndecl_built_in_p (olddecl)
           && !C_DECL_DECLARED_BUILTIN (olddecl))
       /* Don't warn about an extern followed by a definition.  */
       && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))
@@ -2576,7 +2576,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
               || DECL_DISREGARD_INLINE_LIMITS (olddecl));
        }
 
-      if (DECL_BUILT_IN (olddecl))
+      if (fndecl_built_in_p (olddecl))
        {
          /* If redeclaring a builtin function, it stays built in.
             But it gets tagged as having been declared.  */
@@ -2840,7 +2840,7 @@ warn_if_shadowing (tree new_decl)
                                 new_decl);
          }
        else if (TREE_CODE (old_decl) == FUNCTION_DECL
-                && DECL_BUILT_IN (old_decl))
+                && fndecl_built_in_p (old_decl))
          {
            warning (OPT_Wshadow, "declaration of %q+D shadows "
                     "a built-in function", new_decl);
@@ -2953,7 +2953,7 @@ pushdecl (tree x)
                thistype = TREE_TYPE (b_use->decl);
              b_use->u.type = TREE_TYPE (b_use->decl);
              if (TREE_CODE (b_use->decl) == FUNCTION_DECL
-                 && DECL_BUILT_IN (b_use->decl))
+                 && fndecl_built_in_p (b_use->decl))
                thistype
                  = build_type_attribute_variant (thistype,
                                                  TYPE_ATTRIBUTES
@@ -3057,7 +3057,8 @@ pushdecl (tree x)
          else
            thistype = type;
          b->u.type = TREE_TYPE (b->decl);
-         if (TREE_CODE (b->decl) == FUNCTION_DECL && DECL_BUILT_IN (b->decl))
+         if (TREE_CODE (b->decl) == FUNCTION_DECL
+             && fndecl_built_in_p (b->decl))
            thistype
              = build_type_attribute_variant (thistype,
                                              TYPE_ATTRIBUTES (b->u.type));
@@ -3408,7 +3409,7 @@ implicitly_declare (location_t loc, tree functionid)
         in the external scope because they're pushed before the file
         scope gets created.  Catch this here and rebind them into the
         file scope.  */
-      if (!DECL_BUILT_IN (decl) && DECL_IS_BUILTIN (decl))
+      if (!fndecl_built_in_p (decl) && DECL_IS_BUILTIN (decl))
        {
          bind (functionid, decl, file_scope,
                /*invisible=*/false, /*nested=*/true,
@@ -3429,7 +3430,7 @@ implicitly_declare (location_t loc, tree functionid)
              implicit_decl_warning (loc, functionid, decl);
              C_DECL_IMPLICIT (decl) = 1;
            }
-         if (DECL_BUILT_IN (decl))
+         if (fndecl_built_in_p (decl))
            {
              newtype = build_type_attribute_variant (newtype,
                                                      TYPE_ATTRIBUTES
index 0d5dbea8f6770120e4c2360f11eed290e81b69bd..28384dfe913d4870bb7563a6291f0764e5969120 100644 (file)
@@ -9175,8 +9175,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
                                              sizeof_arg,
                                              sizeof_ptr_memacc_comptypes);
          if (TREE_CODE (expr.value) == FUNCTION_DECL
-             && DECL_BUILT_IN_CLASS (expr.value) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (expr.value) == BUILT_IN_MEMSET
+             && fndecl_built_in_p (expr.value, BUILT_IN_MEMSET)
              && vec_safe_length (exprlist) == 3)
            {
              tree arg0 = (*exprlist)[0];
@@ -9194,8 +9193,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
          expr.original_code = ERROR_MARK;
          if (TREE_CODE (expr.value) == INTEGER_CST
              && TREE_CODE (orig_expr.value) == FUNCTION_DECL
-             && DECL_BUILT_IN_CLASS (orig_expr.value) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (orig_expr.value) == BUILT_IN_CONSTANT_P)
+             && fndecl_built_in_p (orig_expr.value, BUILT_IN_CONSTANT_P))
            expr.original_code = C_MAYBE_CONST_EXPR;
          expr.original_type = NULL;
          if (exprlist)
index ae1a1e60d4bf4626accf2235dff8213b3502cc5f..017c01c592ce6825ec211b2b16bc63eecf51258a 100644 (file)
@@ -102,7 +102,7 @@ along with GCC; see the file COPYING3.  If not see
 #define C_DECL_ISNT_PROTOTYPE(EXP)                     \
        (EXP == 0                                       \
        || (!prototype_p (TREE_TYPE (EXP))      \
-           && !DECL_BUILT_IN (EXP)))
+           && !fndecl_built_in_p (EXP)))
 
 /* For FUNCTION_TYPE, a hidden list of types of arguments.  The same as
    TYPE_ARG_TYPES for functions with prototypes, but created for functions
index 54c7967a06b84bc185d2601f25154506b1866147..5f8df12564d00b39e99ef7e4976b50da3a578a35 100644 (file)
@@ -3108,9 +3108,7 @@ build_function_call_vec (location_t loc, vec<location_t> arg_loc,
   argarray = vec_safe_address (params);
 
   /* Check that arguments to builtin functions match the expectations.  */
-  if (fundecl
-      && DECL_BUILT_IN (fundecl)
-      && DECL_BUILT_IN_CLASS (fundecl) == BUILT_IN_NORMAL
+  if (fundecl && fndecl_built_in_p (fundecl, BUILT_IN_NORMAL)
       && !check_builtin_function_arguments (loc, arg_loc, fundecl, nargs,
                                            argarray))
     return error_mark_node;
@@ -3233,8 +3231,7 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
      precision should be removed (classification) or not
      (comparison).  */
   if (type_generic
-      && DECL_BUILT_IN (fundecl)
-      && DECL_BUILT_IN_CLASS (fundecl) == BUILT_IN_NORMAL)
+      && fndecl_built_in_p (fundecl, BUILT_IN_NORMAL))
     {
       switch (DECL_FUNCTION_CODE (fundecl))
        {
index 0fb10b182b1a34c4e9c4f786e592397a646f7eef..f57ecf916365f3b7958e391b05474319c178b01d 100644 (file)
@@ -715,7 +715,7 @@ gimple_alloca_call_p (const gimple *stmt)
     return false;
 
   fndecl = gimple_call_fndecl (stmt);
-  if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+  if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     switch (DECL_FUNCTION_CODE (fndecl))
       {
       CASE_BUILT_IN_ALLOCA:
@@ -1542,7 +1542,7 @@ get_attr_nonstring_decl (tree expr, tree *ref)
 void
 maybe_warn_nonstring_arg (tree fndecl, tree exp)
 {
-  if (!fndecl || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
+  if (!fndecl || !fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     return;
 
   if (TREE_NO_WARNING (exp))
index 647764b0e94ec3476a38f7d07d2845eb8820798e..2d3111da25d917256f21a66736cbdbb38a6f79ea 100644 (file)
@@ -2616,7 +2616,7 @@ expand_call_stmt (gcall *stmt)
   exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
 
   CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
-  builtin_p = decl && DECL_BUILT_IN (decl);
+  builtin_p = decl && fndecl_built_in_p (decl);
 
   /* If this is not a builtin function, the function type through which the
      call is made may be different from the type of the function.  */
@@ -2655,7 +2655,7 @@ expand_call_stmt (gcall *stmt)
   CALL_EXPR_MUST_TAIL_CALL (exp) = gimple_call_must_tail_p (stmt);
   CALL_EXPR_RETURN_SLOT_OPT (exp) = gimple_call_return_slot_opt_p (stmt);
   if (decl
-      && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
+      && fndecl_built_in_p (decl, BUILT_IN_NORMAL)
       && ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (decl)))
     CALL_ALLOCA_FOR_VAR_P (exp) = gimple_call_alloca_for_var_p (stmt);
   else
index d19f1aacab86e9610e103d9d28af6c6b8bfd9b96..148f29ea749daef482a6b094a0510beaded8d49e 100644 (file)
@@ -1559,8 +1559,7 @@ cgraph_update_edges_for_call_stmt_node (cgraph_node *node,
        {
          /* Keep calls marked as dead dead.  */
          if (new_stmt && is_gimple_call (new_stmt) && e->callee
-             && DECL_BUILT_IN_CLASS (e->callee->decl) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (e->callee->decl) == BUILT_IN_UNREACHABLE)
+             && fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
            {
               node->get_edge (old_stmt)->set_call_stmt
                 (as_a <gcall *> (new_stmt));
@@ -3060,8 +3059,8 @@ cgraph_edge::verify_corresponds_to_fndecl (tree decl)
 
   /* Optimizers can redirect unreachable calls or calls triggering undefined
      behavior to builtin_unreachable.  */
-  if (DECL_BUILT_IN_CLASS (callee->decl) == BUILT_IN_NORMAL
-      && DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_UNREACHABLE)
+
+  if (fndecl_built_in_p (callee->decl, BUILT_IN_UNREACHABLE))
     return false;
 
   if (callee->former_clone_of != node->decl
@@ -3187,8 +3186,7 @@ cgraph_node::verify_node (void)
          /* Optimized out calls are redirected to __builtin_unreachable.  */
          && (e->count.nonzero_p ()
              || ! e->callee->decl
-             || DECL_BUILT_IN_CLASS (e->callee->decl) != BUILT_IN_NORMAL
-             || DECL_FUNCTION_CODE (e->callee->decl) != BUILT_IN_UNREACHABLE)
+             || !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
          && count
              == ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (decl))->count
          && (!e->count.ipa_p ()
index 6e84a31c1a52b448691a37adf6d2ed6d4f5a013a..0c0a94b04a3f0ede4c55a2dfd65fa6da35378ee6 100644 (file)
@@ -222,7 +222,7 @@ build_function_decl_skip_args (tree orig_decl, bitmap args_to_skip,
     DECL_VINDEX (new_decl) = NULL_TREE;
 
   /* When signature changes, we need to clear builtin info.  */
-  if (DECL_BUILT_IN (new_decl)
+  if (fndecl_built_in_p (new_decl)
       && args_to_skip
       && !bitmap_empty_p (args_to_skip))
     {
@@ -482,8 +482,7 @@ cgraph_node::create_clone (tree new_decl, profile_count prof_count,
         version.  The only exception is when the edge was proved to
         be unreachable during the clonning procedure.  */
       if (!e->callee
-         || DECL_BUILT_IN_CLASS (e->callee->decl) != BUILT_IN_NORMAL
-         || DECL_FUNCTION_CODE (e->callee->decl) != BUILT_IN_UNREACHABLE)
+         || !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE))
         e->redirect_callee_duplicating_thunks (new_node);
     }
   new_node->expand_all_artificial_thunks ();
index c081216decd04e94069940f096b8c70b001f4beb..6332e68df0506bb980cf55e05e7293b4a44d1e91 100644 (file)
@@ -30841,7 +30841,7 @@ arm_insert_attributes (tree fndecl, tree * attributes)
     return;
 
   if (TREE_CODE (fndecl) != FUNCTION_DECL || DECL_EXTERNAL(fndecl)
-      || DECL_BUILT_IN (fndecl) || DECL_ARTIFICIAL (fndecl))
+      || fndecl_built_in_p (fndecl) || DECL_ARTIFICIAL (fndecl))
    return;
 
   /* Nested definitions must inherit mode.  */
index 98677386a2b96fc13c108f9bba5097a5a17569a3..eab482c4c841ee4864526c8ce872c3a89643ef1d 100644 (file)
@@ -33329,7 +33329,7 @@ ix86_gimple_fold_builtin (gimple_stmt_iterator *gsi)
 {
   gimple *stmt = gsi_stmt (*gsi);
   tree fndecl = gimple_call_fndecl (stmt);
-  gcc_checking_assert (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD);
+  gcc_checking_assert (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_MD));
   int n_args = gimple_call_num_args (stmt);
   enum ix86_builtins fn_code = (enum ix86_builtins) DECL_FUNCTION_CODE (fndecl);
   tree decl = NULL_TREE;
@@ -37919,7 +37919,7 @@ rdseed_step:
                {
                  tree fndecl = gimple_call_fndecl (def_stmt);
                  if (fndecl
-                     && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
+                     && fndecl_built_in_p (fndecl, BUILT_IN_MD))
                    switch ((unsigned int) DECL_FUNCTION_CODE (fndecl))
                      {
                      case IX86_BUILTIN_CMPPD:
index f1ae08e6f7da12a9206da1170c5a3e6c2e41c5af..e6d62082bf9068c2707f3a0c1485603c7b72ee02 100644 (file)
@@ -1,3 +1,24 @@
+2018-08-27  Martin Liska  <mliska@suse.cz>
+
+       * call.c (build_call_a): Use new function
+        fndecl_built_in_p and remove check for FUNCTION_DECL if
+        possible.
+       (build_cxx_call): Likewise.
+       * constexpr.c (constexpr_fn_retval): Likewise.
+       (cxx_eval_builtin_function_call): Likewise.
+       (cxx_eval_call_expression): Likewise.
+       (potential_constant_expression_1): Likewise.
+       * cp-gimplify.c (cp_gimplify_expr): Likewise.
+       (cp_fold): Likewise.
+       * decl.c (decls_match): Likewise.
+       (validate_constexpr_redeclaration): Likewise.
+       (duplicate_decls): Likewise.
+       (make_rtl_for_nonlocal_decl): Likewise.
+       * name-lookup.c (consider_binding_level): Likewise.
+       (cp_emit_debug_info_for_using): Likewise.
+       * semantics.c (finish_call_expr): Likewise.
+       * tree.c (builtin_valid_in_constant_expr_p): Likewise.
+
 2018-08-26  Marek Polacek  <polacek@redhat.com>
 
        PR c++/87080
index 626830c0d9a43a26f7973b5d107309d37c49a524..d74f2be7d7c575c096a8de809e0861c9762fb654 100644 (file)
@@ -389,7 +389,7 @@ build_call_a (tree function, int n, tree *argarray)
   /* Don't pass empty class objects by value.  This is useful
      for tags in STL, which are used to control overload resolution.
      We don't need to handle other cases of copying empty classes.  */
-  if (! decl || ! DECL_BUILT_IN (decl))
+  if (!decl || !fndecl_built_in_p (decl))
     for (i = 0; i < n; i++)
       {
        tree arg = CALL_EXPR_ARG (function, i);
@@ -8869,8 +8869,7 @@ build_cxx_call (tree fn, int nargs, tree *argarray,
   /* Check that arguments to builtin functions match the expectations.  */
   if (fndecl
       && !processing_template_decl
-      && DECL_BUILT_IN (fndecl)
-      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+      && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     {
       int i;
 
index 54c8b5edf8d155d12635bdfdf096fc041464a370..f646519135ffee9aec3e0965269302e09112ecb3 100644 (file)
@@ -721,8 +721,7 @@ constexpr_fn_retval (tree body)
        {
          tree fun = get_function_named_in_call (body);
          if (fun != NULL_TREE
-             && DECL_BUILT_IN_CLASS (fun) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (fun) == BUILT_IN_UNREACHABLE)
+             && fndecl_built_in_p (fun, BUILT_IN_UNREACHABLE))
            return NULL_TREE;
        }
       /* Fallthru.  */
@@ -1198,8 +1197,8 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
 
   /* For __builtin_is_constant_evaluated, defer it if not
      ctx->pretend_const_required, otherwise fold it to true.  */
-  if (DECL_BUILT_IN_CLASS (fun) == BUILT_IN_FRONTEND
-      && (int) DECL_FUNCTION_CODE (fun) == CP_BUILT_IN_IS_CONSTANT_EVALUATED)
+  if (fndecl_built_in_p (fun, CP_BUILT_IN_IS_CONSTANT_EVALUATED,
+                      BUILT_IN_FRONTEND))
     {
       if (!ctx->pretend_const_required)
        {
@@ -1242,8 +1241,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
          /* Do not allow__builtin_unreachable in constexpr function.
             The __builtin_unreachable call with BUILTINS_LOCATION
             comes from cp_maybe_instrument_return.  */
-         if (DECL_BUILT_IN_CLASS (fun) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (fun) == BUILT_IN_UNREACHABLE
+         if (fndecl_built_in_p (fun, BUILT_IN_UNREACHABLE)
              && EXPR_LOCATION (t) == BUILTINS_LOCATION)
            error ("%<constexpr%> call flows off the end of the function");
          else
@@ -1528,7 +1526,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
   if (is_ubsan_builtin_p (fun))
     return void_node;
 
-  if (is_builtin_fn (fun))
+  if (fndecl_built_in_p (fun))
     return cxx_eval_builtin_function_call (ctx, t, fun,
                                           lval, non_constant_p, overflow_p);
   if (!DECL_DECLARED_CONSTEXPR_P (fun))
@@ -5522,7 +5520,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
                if (!DECL_DECLARED_CONSTEXPR_P (fun)
                    /* Allow any built-in function; if the expansion
                       isn't constant, we'll deal with that then.  */
-                   && !is_builtin_fn (fun))
+                   && !fndecl_built_in_p (fun))
                  {
                    if (flags & tf_error)
                      {
index f61099141026b793daab149f989ca2b14d265d48..90a8f9fef8f2398af46e7572c93480a97515e819 100644 (file)
@@ -797,9 +797,8 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
        {
          tree decl = cp_get_callee_fndecl_nofold (*expr_p);
          if (decl
-             && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_FRONTEND
-             && ((int) DECL_FUNCTION_CODE (decl)
-                 == CP_BUILT_IN_IS_CONSTANT_EVALUATED))
+             && fndecl_built_in_p (decl, CP_BUILT_IN_IS_CONSTANT_EVALUATED,
+                                 BUILT_IN_FRONTEND))
            *expr_p = boolean_false_node;
        }
       break;
@@ -2489,7 +2488,7 @@ cp_fold (tree x)
        /* Some built-in function calls will be evaluated at compile-time in
           fold ().  Set optimize to 1 when folding __builtin_constant_p inside
           a constexpr function so that fold_builtin_1 doesn't fold it to 0.  */
-       if (callee && DECL_BUILT_IN (callee) && !optimize
+       if (callee && fndecl_built_in_p (callee) && !optimize
            && DECL_IS_BUILTIN_CONSTANT_P (callee)
            && current_function_decl
            && DECL_DECLARED_CONSTEXPR_P (current_function_decl))
@@ -2497,9 +2496,8 @@ cp_fold (tree x)
 
        /* Defer folding __builtin_is_constant_evaluated.  */
        if (callee
-           && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_FRONTEND
-           && ((int) DECL_FUNCTION_CODE (callee)
-               == CP_BUILT_IN_IS_CONSTANT_EVALUATED))
+           && fndecl_built_in_p (callee, CP_BUILT_IN_IS_CONSTANT_EVALUATED,
+                               BUILT_IN_FRONTEND))
          break;
 
        x = copy_node (x);
index 9056ad0dbcebc364401c12b1b72b3f82a2ca54ec..c9c5fa6b4d5ad88d607f63ef59815dc678557274 100644 (file)
@@ -968,7 +968,7 @@ decls_match (tree newdecl, tree olddecl, bool record_versions /* = true */)
       if (same_type_p (TREE_TYPE (f1), r2))
        {
          if (!prototype_p (f2) && DECL_EXTERN_C_P (olddecl)
-             && (DECL_BUILT_IN (olddecl)
+             && (fndecl_built_in_p (olddecl)
 #ifdef SYSTEM_IMPLICIT_EXTERN_C
                  || (DECL_IN_SYSTEM_HEADER (newdecl) && !DECL_CLASS_SCOPE_P (newdecl))
                  || (DECL_IN_SYSTEM_HEADER (olddecl) && !DECL_CLASS_SCOPE_P (olddecl))
@@ -1208,7 +1208,7 @@ validate_constexpr_redeclaration (tree old_decl, tree new_decl)
     return true;
   if (TREE_CODE (old_decl) == FUNCTION_DECL)
     {
-      if (DECL_BUILT_IN (old_decl))
+      if (fndecl_built_in_p (old_decl))
        {
          /* Hide a built-in declaration.  */
          DECL_DECLARED_CONSTEXPR_P (old_decl)
@@ -1442,7 +1442,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
            {
              warning_at (newdecl_loc,
                          OPT_Wshadow, 
-                         DECL_BUILT_IN (olddecl)
+                         fndecl_built_in_p (olddecl)
                          ? G_("shadowing built-in function %q#D")
                          : G_("shadowing library function %q#D"), olddecl);
              /* Discard the old built-in function.  */
@@ -1450,7 +1450,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
            }
          /* If the built-in is not ansi, then programs can override
             it even globally without an error.  */
-         else if (! DECL_BUILT_IN (olddecl))
+         else if (! fndecl_built_in_p (olddecl))
            warning_at (newdecl_loc, 0,
                        "library function %q#D redeclared as non-function %q#D",
                        olddecl, newdecl);
@@ -1537,7 +1537,7 @@ next_arg:;
              /* Don't really override olddecl for __* prefixed builtins
                 except for __[^b]*_chk, the compiler might be using those
                 explicitly.  */
-             if (DECL_BUILT_IN (olddecl))
+             if (fndecl_built_in_p (olddecl))
                {
                  tree id = DECL_NAME (olddecl);
                  const char *name = IDENTIFIER_POINTER (id);
@@ -1578,9 +1578,9 @@ next_arg:;
                            "declaration %q#D", newdecl, olddecl);
              else
                warning (OPT_Wshadow, 
-                         DECL_BUILT_IN (olddecl)
-                         ? G_("shadowing built-in function %q#D")
-                         : G_("shadowing library function %q#D"), olddecl);
+                        fndecl_built_in_p (olddecl)
+                        ? G_("shadowing built-in function %q#D")
+                        : G_("shadowing library function %q#D"), olddecl);
            }
          else
            /* Discard the old built-in function.  */
@@ -2522,7 +2522,7 @@ next_arg:;
       /* If redeclaring a builtin function, it stays built in
         if newdecl is a gnu_inline definition, or if newdecl is just
         a declaration.  */
-      if (DECL_BUILT_IN (olddecl)
+      if (fndecl_built_in_p (olddecl)
          && (new_defines_function ? GNU_INLINE_P (newdecl) : types_match))
        {
          DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
@@ -6611,7 +6611,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec)
       else
        {
          if (TREE_CODE (decl) == FUNCTION_DECL
-             && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+             && fndecl_built_in_p (decl, BUILT_IN_NORMAL))
            set_builtin_user_assembler_name (decl, asmspec);
          set_user_assembler_name (decl, asmspec);
        }
index 8c7f68522da492220550683c45ae8f1676b1cd0d..8e009b29d61137e8c0bf75b82cf8ff55c7efd335 100644 (file)
@@ -5791,7 +5791,7 @@ consider_binding_level (tree name, best_match <tree, const char *> &bm,
 
       /* Skip anticipated decls of builtin functions.  */
       if (TREE_CODE (d) == FUNCTION_DECL
-         && DECL_BUILT_IN (d)
+         && fndecl_built_in_p (d)
          && DECL_ANTICIPATED (d))
        continue;
 
@@ -7274,7 +7274,7 @@ cp_emit_debug_info_for_using (tree t, tree context)
      of a builtin function.  */
   if (TREE_CODE (t) == FUNCTION_DECL
       && DECL_EXTERNAL (t)
-      && DECL_BUILT_IN (t))
+      && fndecl_built_in_p (t))
     return;
 
   /* Do not supply context to imported_module_or_decl, if
index bfdca5024d3128b66a6b9b6a4408871991c03335..b24d09224a963c72fb160357cde0f0278622f51c 100644 (file)
@@ -2546,8 +2546,7 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual,
 
          if ((complain & tf_warning)
              && TREE_CODE (fn) == FUNCTION_DECL
-             && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (fn) == BUILT_IN_MEMSET
+             && fndecl_built_in_p (fn, BUILT_IN_MEMSET)
              && vec_safe_length (*args) == 3
              && !any_type_dependent_arguments_p (*args))
            {
index 8a1d2993f946e8c12d726d5a90696420d07a6def..c6f216dab4b907a224ce9e8dccc887abde685a86 100644 (file)
@@ -420,9 +420,8 @@ builtin_valid_in_constant_expr_p (const_tree decl)
     return false;
   if (DECL_BUILT_IN_CLASS (decl) != BUILT_IN_NORMAL)
     {
-      if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_FRONTEND
-         && ((int) DECL_FUNCTION_CODE (decl)
-             == CP_BUILT_IN_IS_CONSTANT_EVALUATED))
+      if (fndecl_built_in_p (decl, CP_BUILT_IN_IS_CONSTANT_EVALUATED,
+                          BUILT_IN_FRONTEND))
        return true;
       /* Not a built-in.  */
       return false;
index 26c6007b9ed86d28fa69582f1c735cd769de0378..cfebfa0e110be56f17337dcb152984d782528889 100644 (file)
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -2419,8 +2419,7 @@ scan_insn (bb_info_t bb_info, rtx_insn *insn)
          && GET_CODE (sym) == SYMBOL_REF
          && SYMBOL_REF_DECL (sym)
          && TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL
-         && DECL_BUILT_IN_CLASS (SYMBOL_REF_DECL (sym)) == BUILT_IN_NORMAL
-         && DECL_FUNCTION_CODE (SYMBOL_REF_DECL (sym)) == BUILT_IN_MEMSET)
+         && fndecl_built_in_p (SYMBOL_REF_DECL (sym), BUILT_IN_MEMSET))
        memset_call = SYMBOL_REF_DECL (sym);
 
       if (const_call || memset_call)
index 58574bafbf3007e15d57946c3750914a5fa286a2..2645c259af8d45495d089799e0df346f38d2d87b 100644 (file)
@@ -10937,7 +10937,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
          }
 
        /* Check for a built-in function.  */
-       if (fndecl && DECL_BUILT_IN (fndecl))
+       if (fndecl && fndecl_built_in_p (fndecl))
          {
            gcc_assert (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_FRONTEND);
            return expand_builtin (exp, target, subtarget, tmode, ignore);
index 1e44a2454adbc26fefef595da5f07deed6521959..63e15f027fb4f10ffe02f4a3e9031fc68276ec7d 100644 (file)
@@ -3451,7 +3451,7 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
     case tcc_declaration:
       /* Consider __builtin_sqrt equal to sqrt.  */
       return (TREE_CODE (arg0) == FUNCTION_DECL
-             && DECL_BUILT_IN (arg0) && DECL_BUILT_IN (arg1)
+             && fndecl_built_in_p (arg0) && fndecl_built_in_p (arg1)
              && DECL_BUILT_IN_CLASS (arg0) == DECL_BUILT_IN_CLASS (arg1)
              && DECL_FUNCTION_CODE (arg0) == DECL_FUNCTION_CODE (arg1));
 
@@ -10761,8 +10761,7 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type,
          tree fndecl = get_callee_fndecl (arg0);
 
          if (fndecl
-             && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRLEN
+             && fndecl_built_in_p (fndecl, BUILT_IN_STRLEN)
              && call_expr_nargs (arg0) == 1
              && TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (arg0, 0))) == POINTER_TYPE)
            {
index 07341ebe66fc9ea20c4b6a249c74bf8e1d983005..cbca6a95b769cad77768b90ca7151befe131d4be 100644 (file)
@@ -6347,8 +6347,7 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree),
 
        fn = (*valueize) (gimple_call_fn (stmt));
        if (TREE_CODE (fn) == ADDR_EXPR
-           && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
-           && DECL_BUILT_IN (TREE_OPERAND (fn, 0))
+           && fndecl_built_in_p (TREE_OPERAND (fn, 0))
            && gimple_builtin_call_types_compatible_p (stmt,
                                                       TREE_OPERAND (fn, 0)))
          {
index 9623fb86a04e698cde47236dc6b32933fab515dd..c3777a1e761736ef805cc37f1d753ba4b4f53332 100644 (file)
@@ -355,7 +355,7 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
          }
 
        if (decl
-           && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+           && fndecl_built_in_p (decl, BUILT_IN_NORMAL))
          {
            if (DECL_FUNCTION_CODE (decl) == BUILT_IN_SETJMP)
              {
index dd63a28761b85cf38d38108d559db86531edb823..83e22735571fea8d14187ccb6a83d39b96de7b6c 100644 (file)
@@ -911,8 +911,7 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
   if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
     pp_string (buffer, " [tm-clone]");
   if (TREE_CODE (fn) == FUNCTION_DECL
-      && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
-      && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
+      && fndecl_built_in_p (fn, BUILT_IN_TM_START)
       && gimple_call_num_args (gs) > 0)
     {
       tree t = gimple_call_arg (gs, 0);
index 977dd860ef7ad94c0997184aefb7c1bdb266fec3..ea30b7108f8f9bbb526a280bd955ec2a8a85b71a 100644 (file)
@@ -1731,7 +1731,7 @@ wrestrict_dom_walker::check_call (gimple *call)
     return;
 
   tree func = gimple_call_fndecl (call);
-  if (!func || DECL_BUILT_IN_CLASS (func) != BUILT_IN_NORMAL)
+  if (!func || !fndecl_built_in_p (func, BUILT_IN_NORMAL))
     return;
 
   /* Argument number to extract from the call (depends on the built-in
index 8d56a966cc1f5b21dcb09ab58e76062d8497dd7b..e3e651b1e61ddd5e817ea7b52deea4abca22d413 100644 (file)
@@ -376,7 +376,7 @@ gimple_build_call_from_tree (tree t, tree fnptrtype)
   gimple_call_set_must_tail (call, CALL_EXPR_MUST_TAIL_CALL (t));
   gimple_call_set_return_slot_opt (call, CALL_EXPR_RETURN_SLOT_OPT (t));
   if (fndecl
-      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
+      && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
       && ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (fndecl)))
     gimple_call_set_alloca_for_var (call, CALL_ALLOCA_FOR_VAR_P (t));
   else
@@ -2681,8 +2681,7 @@ gimple_call_builtin_p (const gimple *stmt, enum built_in_function code)
   tree fndecl;
   if (is_gimple_call (stmt)
       && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
-      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL 
-      && DECL_FUNCTION_CODE (fndecl) == code)
+      && fndecl_built_in_p (fndecl, code))
     return gimple_builtin_call_types_compatible_p (stmt, fndecl);
   return false;
 }
@@ -2701,7 +2700,7 @@ gimple_call_combined_fn (const gimple *stmt)
 
       tree fndecl = gimple_call_fndecl (stmt);
       if (fndecl
-         && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
+         && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
          && gimple_builtin_call_types_compatible_p (stmt, fndecl))
        return as_combined_fn (DECL_FUNCTION_CODE (fndecl));
     }
index e35137aec2c7193f8e345b20cd3ec3e79334ce20..dbd0f0ebd0cd40ddfc59f833b74022f9b0d332c6 100644 (file)
@@ -3209,8 +3209,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
      transform all calls in the same manner as the expanders do, but
      we do transform most of them.  */
   fndecl = get_callee_fndecl (*expr_p);
-  if (fndecl
-      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+  if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     switch (DECL_FUNCTION_CODE (fndecl))
       {
       CASE_BUILT_IN_ALLOCA:
@@ -3245,7 +3244,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
       default:
         ;
       }
-  if (fndecl && DECL_BUILT_IN (fndecl))
+  if (fndecl && fndecl_built_in_p (fndecl))
     {
       tree new_tree = fold_call_expr (input_location, *expr_p, !want_value);
       if (new_tree && new_tree != *expr_p)
@@ -3297,9 +3296,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
       tree last_arg_fndecl = get_callee_fndecl (last_arg);
 
       if (last_arg_fndecl
-         && TREE_CODE (last_arg_fndecl) == FUNCTION_DECL
-         && DECL_BUILT_IN_CLASS (last_arg_fndecl) == BUILT_IN_NORMAL
-         && DECL_FUNCTION_CODE (last_arg_fndecl) == BUILT_IN_VA_ARG_PACK)
+         && fndecl_built_in_p (last_arg_fndecl, BUILT_IN_VA_ARG_PACK))
        {
          tree call = *expr_p;
 
@@ -3773,8 +3770,7 @@ gimple_boolify (tree expr)
       /* For __builtin_expect ((long) (x), y) recurse into x as well
         if x is truth_value_p.  */
       if (fn
-         && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
-         && DECL_FUNCTION_CODE (fn) == BUILT_IN_EXPECT
+         && fndecl_built_in_p (fn, BUILT_IN_EXPECT)
          && call_expr_nargs (call) == 2)
        {
          tree arg = CALL_EXPR_ARG (call, 0);
@@ -5719,8 +5715,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
          STRIP_USELESS_TYPE_CONVERSION (CALL_EXPR_FN (*from_p));
          tree fndecl = get_callee_fndecl (*from_p);
          if (fndecl
-             && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
+             && fndecl_built_in_p (fndecl, BUILT_IN_EXPECT)
              && call_expr_nargs (*from_p) == 3)
            call_stmt = gimple_build_call_internal (IFN_BUILTIN_EXPECT, 3,
                                                    CALL_EXPR_ARG (*from_p, 0),
@@ -5978,7 +5973,7 @@ gimplify_addr_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
         being taken (we can unify those cases here) then we can mark
         the builtin for implicit generation by GCC.  */
       if (TREE_CODE (op0) == FUNCTION_DECL
-         && DECL_BUILT_IN_CLASS (op0) == BUILT_IN_NORMAL
+         && fndecl_built_in_p (op0, BUILT_IN_NORMAL)
          && builtin_decl_declared_p (DECL_FUNCTION_CODE (op0)))
        set_builtin_decl_implicit_p (DECL_FUNCTION_CODE (op0), true);
 
index a392ed89bad0b753f8073dea1e2347bde608f9a2..09f2b7fced662ca5fc1d423a8931c6219009079c 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-27  Martin Liska  <mliska@suse.cz>
+
+       * go-gcc.cc (Gcc_backend::call_expression): Use new function
+        fndecl_built_in_p and remove check for FUNCTION_DECL if
+        possible.
+
 2018-07-20  Martin Sebor  <msebor@redhat.com>
 
        PR middle-end/82063
index 76a2026f1e09c83a7c3907f0ef0e5ee5227c9e1f..1a449b7cc470537a92c21ab3d4c0a0c9d1fa4234 100644 (file)
@@ -1948,8 +1948,8 @@ Gcc_backend::call_expression(Bfunction*, // containing fcn for call
   tree excess_type = NULL_TREE;
   if (optimize
       && TREE_CODE(fndecl) == FUNCTION_DECL
-      && DECL_IS_BUILTIN(fndecl)
-      && DECL_BUILT_IN_CLASS(fndecl) == BUILT_IN_NORMAL
+      && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
+      && DECL_IS_BUILTIN (fndecl)
       && nargs > 0
       && ((SCALAR_FLOAT_TYPE_P(rettype)
           && SCALAR_FLOAT_TYPE_P(TREE_TYPE(args[0])))
index 416de933a22b57777c0340f26493c147fb42669b..69e092ec4fad2b3dffcbbbff503c6495ecd2c726 100644 (file)
@@ -5300,8 +5300,7 @@ gen_hsa_insns_for_call (gimple *stmt, hsa_bb *hbb)
       tree function_decl = gimple_call_fndecl (stmt);
       /* Prefetch pass can create type-mismatching prefetch builtin calls which
         fail the gimple_call_builtin_p test above.  Handle them here.  */
-      if (DECL_BUILT_IN_CLASS (function_decl)
-         && DECL_FUNCTION_CODE (function_decl) == BUILT_IN_PREFETCH)
+      if (fndecl_built_in_p (function_decl, BUILT_IN_PREFETCH))
        return;
 
       if (function_decl == NULL_TREE)
index 42dd4cc29042300a89ee75e00860d2552484fbbc..4838194cd7365da9caed7b9a7ce18e4ff762fa27 100644 (file)
@@ -638,8 +638,7 @@ determine_versionability (struct cgraph_node *node,
   if (DECL_EXTERNAL (node->decl))
     for (cgraph_edge *edge = node->callees; !reason && edge;
         edge = edge->next_callee)
-      if (DECL_BUILT_IN (edge->callee->decl)
-         && DECL_BUILT_IN_CLASS (edge->callee->decl) == BUILT_IN_NORMAL)
+      if (fndecl_built_in_p (edge->callee->decl, BUILT_IN_NORMAL))
         {
          if (DECL_FUNCTION_CODE (edge->callee->decl) == BUILT_IN_VA_ARG_PACK)
            reason = "external function which calls va_arg_pack";
index d8311d25ab2b95aed43246b2ff44dfb2aad53da5..62095c6cf6f17418555072ccc3ce487c50d9f335 100644 (file)
@@ -2455,10 +2455,8 @@ compute_fn_summary (struct cgraph_node *node, bool early)
               for (e = node->callees; e; e = e->next_callee)
                 {
                   tree cdecl = e->callee->decl;
-                  if (DECL_BUILT_IN (cdecl)
-                      && DECL_BUILT_IN_CLASS (cdecl) == BUILT_IN_NORMAL
-                      && (DECL_FUNCTION_CODE (cdecl) == BUILT_IN_APPLY_ARGS
-                          || DECL_FUNCTION_CODE (cdecl) == BUILT_IN_VA_START))
+                  if (fndecl_built_in_p (cdecl, BUILT_IN_APPLY_ARGS)
+                      || fndecl_built_in_p (cdecl, BUILT_IN_VA_START))
                     break;
                 }
               node->local.can_change_signature = !e;
index 1ab1fcccdaec51a95d99acac8842f687039681a7..1e3a92a125f5adddf05c98e3e96ac4ed60b45e9d 100644 (file)
@@ -218,7 +218,7 @@ ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec adjustments)
     }
 
   /* When signature changes, we need to clear builtin info.  */
-  if (DECL_BUILT_IN (fndecl))
+  if (fndecl_built_in_p (fndecl))
     {
       DECL_BUILT_IN_CLASS (fndecl) = NOT_BUILT_IN;
       DECL_FUNCTION_CODE (fndecl) = (enum built_in_function) 0;
index 0e6440f8997c54b8b92e3c69e04af3ae196271cf..38f5bcf00a6f2b36052caccd520e0b3ba81cb24c 100644 (file)
@@ -899,8 +899,7 @@ visit_bb (basic_block bb, basic_block return_bb,
       /* Check builtins that prevent splitting.  */
       if (gimple_code (stmt) == GIMPLE_CALL
          && (decl = gimple_call_fndecl (stmt)) != NULL_TREE
-         && DECL_BUILT_IN (decl)
-         && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+         && fndecl_built_in_p (decl, BUILT_IN_NORMAL))
        switch (DECL_FUNCTION_CODE (decl))
          {
          /* FIXME: once we will allow passing non-parm values to split part,
@@ -1347,7 +1346,7 @@ split_function (basic_block return_bb, struct split_point *split_point,
   /* For usual cloning it is enough to clear builtin only when signature
      changes.  For partial inlining we however can not expect the part
      of builtin implementation to have same semantic as the whole.  */
-  if (DECL_BUILT_IN (node->decl))
+  if (fndecl_built_in_p (node->decl))
     {
       DECL_BUILT_IN_CLASS (node->decl) = NOT_BUILT_IN;
       DECL_FUNCTION_CODE (node->decl) = (enum built_in_function) 0;
index 907dc9d0e2b03f90fe979554205469a87eca84a5..000207fa31b846b389d28a1f70caf0d896716ddb 100644 (file)
@@ -203,7 +203,7 @@ cgraph_externally_visible_p (struct cgraph_node *node,
      using the implicit built-in declarations anymore.  Similarly this enables
      us to remove them as unreachable before actual calls may appear during
      expansion or folding.  */
-  if (DECL_BUILT_IN (node->decl))
+  if (fndecl_built_in_p (node->decl))
     return true;
 
   /* If linker counts on us, we must preserve the function.  */
index d5e390cb5f4cc4dc5061cd6dd7c54bb19dbaa430..1e6a7adeaa20a7b1594169e1f1f7be043f81d685 100644 (file)
@@ -1266,7 +1266,7 @@ input_node (struct lto_file_decl_data *file_data,
      have already been read will have their tag stored in the 'aux'
      field.  Since built-in functions can be referenced in multiple
      functions, they are expected to be read more than once.  */
-  if (node->aux && !DECL_BUILT_IN (node->decl))
+  if (node->aux && !fndecl_built_in_p (node->decl))
     internal_error ("bytecode stream: found multiple instances of cgraph "
                    "node with uid %d", node->get_uid ());
 
index 9e28d678342c1d4a48293b8becef816a227472ea..f9d0f3e08ec4745eb5c92a1112c1f2ab627e3383 100644 (file)
@@ -2618,7 +2618,8 @@ write_symbol (struct streamer_tree_cache_d *cache,
   unsigned char c;
 
   gcc_checking_assert (TREE_PUBLIC (t)
-                      && !is_builtin_fn (t)
+                      && (TREE_CODE (t) != FUNCTION_DECL
+                          || !fndecl_built_in_p (t))
                       && !DECL_ABSTRACT_P (t)
                       && (!VAR_P (t) || !DECL_HARD_REGISTER (t)));
 
index a92317cb77412c360e9a2b3c9155562cffe256a9..c05f6fbe5dca3c641ab436e5619a44a592191993 100644 (file)
@@ -1,3 +1,14 @@
+2018-08-27  Martin Liska  <mliska@suse.cz>
+
+       * lto-lang.c (handle_const_attribute): Use new function
+        fndecl_built_in_p and remove check for FUNCTION_DECL if
+        possible.
+       * lto-symtab.c (lto_symtab_merge_p): Likewise.
+       (lto_symtab_merge_decls_1): Likewise.
+       (lto_symtab_merge_symbols): Likewise.
+       * lto.c (lto_maybe_register_decl): Likewise.
+       (read_cgraph_and_symbols): Likewise.
+
 2018-08-21  Tom de Vries  <tdevries@suse.de>
 
        * lto.c (lto_main):  Call debuginfo_early_start and
index de6ec1c077a9b267f4bd589c0ecaf964a442af57..8eb4a25a6340df346648cddce38ad4f2cc5f249e 100644 (file)
@@ -303,8 +303,7 @@ handle_const_attribute (tree *node, tree ARG_UNUSED (name),
                        tree ARG_UNUSED (args), int ARG_UNUSED (flags),
                        bool * ARG_UNUSED (no_add_attrs))
 {
-  if (TREE_CODE (*node) != FUNCTION_DECL
-      || !DECL_BUILT_IN (*node))
+  if (!fndecl_built_in_p (*node))
     inform (UNKNOWN_LOCATION, "%s:%s: %E: %E", __FILE__, __func__, *node, name);
 
   tree type = TREE_TYPE (*node);
index 0d603c0281f7811356f83b4c9eae9b16b114e995..cf08d455d877808b484bf2f18b01ae55da4c0387 100644 (file)
@@ -546,14 +546,14 @@ lto_symtab_merge_p (tree prevailing, tree decl)
   
   if (TREE_CODE (prevailing) == FUNCTION_DECL)
     {
-      if (DECL_BUILT_IN (prevailing) != DECL_BUILT_IN (decl))
+      if (fndecl_built_in_p (prevailing) != fndecl_built_in_p (decl))
        {
          if (dump_file)
            fprintf (dump_file, "Not merging decls; "
                     "DECL_BUILT_IN mismatch\n");
          return false;
        }
-      if (DECL_BUILT_IN (prevailing)
+      if (fndecl_built_in_p (prevailing)
          && (DECL_BUILT_IN_CLASS (prevailing) != DECL_BUILT_IN_CLASS (decl)
              || DECL_FUNCTION_CODE (prevailing) != DECL_FUNCTION_CODE (decl)))
        {
@@ -797,7 +797,7 @@ lto_symtab_merge_decls_1 (symtab_node *first)
        {
          for (e = first; e; e = e->next_sharing_asm_name)
            if (TREE_CODE (e->decl) == FUNCTION_DECL
-               && !DECL_BUILT_IN (e->decl)
+               && !fndecl_built_in_p (e->decl)
                && lto_symtab_symbol_p (e))
              {
                prevailing = e;
@@ -1030,7 +1030,7 @@ lto_symtab_merge_symbols (void)
              /* Builtins are not merged via decl merging.  It is however
                 possible that tree merging unified the declaration.  We
                 do not want duplicate entries in symbol table.  */
-             if (cnode && DECL_BUILT_IN (node->decl)
+             if (cnode && fndecl_built_in_p (node->decl)
                  && (cnode2 = cgraph_node::get (node->decl))
                  && cnode2 != cnode)
                lto_cgraph_replace_node (cnode2, cnode);
index 10618896022c8af4e18a9fb7fde7a157901dd569..5b92bee026e81abec7c8c4a095cdf1074b0e80d4 100644 (file)
@@ -894,7 +894,7 @@ lto_maybe_register_decl (struct data_in *data_in, tree t, unsigned ix)
   if (TREE_CODE (t) == VAR_DECL)
     lto_register_var_decl_in_symtab (data_in, t, ix);
   else if (TREE_CODE (t) == FUNCTION_DECL
-          && !DECL_BUILT_IN (t))
+          && !fndecl_built_in_p (t))
     lto_register_function_decl_in_symtab (data_in, t, ix);
 }
 
@@ -2923,7 +2923,8 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
   FOR_EACH_SYMBOL (snode)
     if (snode->externally_visible && snode->real_symbol_p ()
        && snode->lto_file_data && snode->lto_file_data->resolution_map
-       && !is_builtin_fn (snode->decl)
+       && !(TREE_CODE (snode->decl) != FUNCTION_DECL
+            || fndecl_built_in_p (snode->decl))
        && !(VAR_P (snode->decl) && DECL_HARD_REGISTER (snode->decl)))
       {
        ld_plugin_symbol_resolution_t *res;
index 843c66fd22199b3b77737030c5f489d7c2f1c482..fdabf67249b5827ae1bddf1762d31492ee5a3d3c 100644 (file)
@@ -2975,9 +2975,8 @@ scan_omp_1_op (tree *tp, int *walk_subtrees, void *data)
 static bool
 setjmp_or_longjmp_p (const_tree fndecl)
 {
-  if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-      && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SETJMP
-         || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_LONGJMP))
+  if (fndecl_built_in_p (fndecl, BUILT_IN_SETJMP)
+      || fndecl_built_in_p (fndecl, BUILT_IN_LONGJMP))
     return true;
 
   tree declname = DECL_NAME (fndecl);
@@ -8832,7 +8831,7 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       call_stmt = as_a <gcall *> (stmt);
       fndecl = gimple_call_fndecl (call_stmt);
       if (fndecl
-         && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+         && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
        switch (DECL_FUNCTION_CODE (fndecl))
          {
          case BUILT_IN_GOMP_BARRIER:
index 8c8e79153fc00f2708a72f462454622a3c9ce790..ca6a901cd5615c00ad5f2fe3c6cafc0974a772e3 100644 (file)
@@ -3996,10 +3996,12 @@ strip_predict_hints (function *fun, bool early)
              tree fndecl = gimple_call_fndecl (stmt);
 
              if (!early
-                 && ((DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_EXPECT)
+                 && ((fndecl != NULL_TREE
+                      && fndecl_built_in_p (fndecl, BUILT_IN_EXPECT)
                       && gimple_call_num_args (stmt) == 2)
-                     || (DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL,
-                                          BUILT_IN_EXPECT_WITH_PROBABILITY)
+                     || (fndecl != NULL_TREE
+                         && fndecl_built_in_p (fndecl,
+                                               BUILT_IN_EXPECT_WITH_PROBABILITY)
                          && gimple_call_num_args (stmt) == 3)
                      || (gimple_call_internal_p (stmt)
                          && gimple_call_internal_fn (stmt) == IFN_BUILTIN_EXPECT)))
index 5347e0647043485277a63d95ce29c626a928c4c7..8caf9dd0dd085c96a1b2e7ecffe7723a25771a37 100644 (file)
@@ -427,7 +427,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent,
        fputs (" autoinline", file);
       if (code == FUNCTION_DECL && DECL_UNINLINABLE (node))
        fputs (" uninlinable", file);
-      if (code == FUNCTION_DECL && DECL_BUILT_IN (node))
+      if (code == FUNCTION_DECL && fndecl_built_in_p (node))
        fputs (" built-in", file);
       if (code == FUNCTION_DECL && DECL_STATIC_CHAIN (node))
        fputs (" static-chain", file);
@@ -502,7 +502,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent,
          print_node (file, "size", DECL_SIZE (node), indent + 4);
          print_node (file, "unit-size", DECL_SIZE_UNIT (node), indent + 4);
 
-         if (code != FUNCTION_DECL || DECL_BUILT_IN (node))
+         if (code != FUNCTION_DECL || fndecl_built_in_p (node))
            indent_to (file, indent + 3);
 
          if (DECL_USER_ALIGN (node))
@@ -514,7 +514,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent,
            fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
                     DECL_OFFSET_ALIGN (node));
 
-         if (code == FUNCTION_DECL && DECL_BUILT_IN (node))
+         if (code == FUNCTION_DECL && fndecl_built_in_p (node))
            {
              if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
                fprintf (file, " built-in: BUILT_IN_MD:%d", DECL_FUNCTION_CODE (node));
index c5464cbe6d7e1a01ed26fe3092e6f32a863a6f49..3cf1f629413768363925a3a13c153e5b290c5057 100644 (file)
@@ -2323,7 +2323,7 @@ symtab_node::output_to_lto_symbol_table_p (void)
     return false;
   /* FIXME: Builtins corresponding to real functions probably should have
      symbol table entries.  */
-  if (is_builtin_fn (decl))
+  if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl))
     return false;
 
   /* We have real symbol that should be in symbol table.  However try to trim
index ca14915ef0d3a478af7aad73c797485b521e9ef3..1d4eb80620295ae9ab48ee2c18ac0bf282fff399 100644 (file)
@@ -235,8 +235,7 @@ is_tm_irrevocable (tree x)
   if (TREE_CODE (x) == ADDR_EXPR)
     x = TREE_OPERAND (x, 0);
   if (TREE_CODE (x) == FUNCTION_DECL
-      && DECL_BUILT_IN_CLASS (x) == BUILT_IN_NORMAL
-      && DECL_FUNCTION_CODE (x) == BUILT_IN_TM_IRREVOCABLE)
+      && fndecl_built_in_p (x, BUILT_IN_TM_IRREVOCABLE))
     return true;
 
   return false;
@@ -358,7 +357,8 @@ is_tm_load (gimple *stmt)
     return false;
 
   fndecl = gimple_call_fndecl (stmt);
-  return (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
+  return (fndecl
+         && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
          && BUILTIN_TM_LOAD_P (DECL_FUNCTION_CODE (fndecl)));
 }
 
@@ -374,7 +374,7 @@ is_tm_simple_load (gimple *stmt)
     return false;
 
   fndecl = gimple_call_fndecl (stmt);
-  if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+  if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     {
       enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
       return (fcode == BUILT_IN_TM_LOAD_1
@@ -402,7 +402,8 @@ is_tm_store (gimple *stmt)
     return false;
 
   fndecl = gimple_call_fndecl (stmt);
-  return (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
+  return (fndecl
+         && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
          && BUILTIN_TM_STORE_P (DECL_FUNCTION_CODE (fndecl)));
 }
 
@@ -418,7 +419,8 @@ is_tm_simple_store (gimple *stmt)
     return false;
 
   fndecl = gimple_call_fndecl (stmt);
-  if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+  if (fndecl
+      && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     {
       enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
       return (fcode == BUILT_IN_TM_STORE_1
@@ -440,9 +442,7 @@ is_tm_simple_store (gimple *stmt)
 static bool
 is_tm_abort (tree fndecl)
 {
-  return (fndecl
-         && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-         && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_TM_ABORT);
+  return (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_TM_ABORT));
 }
 
 /* Build a GENERIC tree for a user abort.  This is called by front ends
@@ -2007,7 +2007,7 @@ tm_region_init_1 (struct tm_region *region, basic_block bb)
       if (gimple_code (g) == GIMPLE_CALL)
        {
          tree fn = gimple_call_fndecl (g);
-         if (fn && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL)
+         if (fn && fndecl_built_in_p (fn, BUILT_IN_NORMAL))
            {
              if ((DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_COMMIT
                   || DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_COMMIT_EH)
index a47be1d0362ce395968ddf53cd588c31fd1ad64b..01401cad6e6c17c9b2896d5a40d674266e3d800a 100644 (file)
@@ -737,7 +737,7 @@ gen_shrink_wrap_conditions (gcall *bi_call, vec<gimple *> conds,
 
   call = bi_call;
   fn = gimple_call_fndecl (call);
-  gcc_assert (fn && DECL_BUILT_IN (fn));
+  gcc_assert (fn && fndecl_built_in_p (fn));
   fnc = DECL_FUNCTION_CODE (fn);
   *nconds = 0;
 
index b021fb0f97ba6acec3bcc2244feb1e93e396f2ef..cf12cb1f3913f597543727cb2bb6affb7dbf6041 100644 (file)
@@ -3426,7 +3426,7 @@ verify_gimple_call (gcall *stmt)
       return true;
     }
 
-  if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+  if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     {
       switch (DECL_FUNCTION_CODE (fndecl))
        {
@@ -6882,7 +6882,7 @@ move_stmt_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
       /* Remap the region numbers for __builtin_eh_{pointer,filter}.  */
       {
        tree r, fndecl = gimple_call_fndecl (stmt);
-       if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+       if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
          switch (DECL_FUNCTION_CODE (fndecl))
            {
            case BUILT_IN_EH_COPY_VALUES:
@@ -8303,15 +8303,14 @@ stmt_can_terminate_bb_p (gimple *t)
 
   if (is_gimple_call (t)
       && fndecl
-      && DECL_BUILT_IN (fndecl)
+      && fndecl_built_in_p (fndecl)
       && (call_flags & ECF_NOTHROW)
       && !(call_flags & ECF_RETURNS_TWICE)
       /* fork() doesn't really return twice, but the effect of
          wrapping it in __gcov_fork() which calls __gcov_flush()
         and clears the counters before forking has the same
         effect as returning twice.  Force a fake edge.  */
-      && !(DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-          && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FORK))
+      && !fndecl_built_in_p (fndecl, BUILT_IN_FORK))
     return false;
 
   if (is_gimple_call (t))
index 20e2db9e29a5e455034baabb4cf9806e731b3115..fb931aa4389469ccb2c32a89313e5c9c6760d6bc 100644 (file)
@@ -1984,7 +1984,7 @@ lower_eh_constructs_2 (struct leh_state *state, gimple_stmt_iterator *gsi)
        tree fndecl = gimple_call_fndecl (stmt);
        tree rhs, lhs;
 
-       if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+       if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
          switch (DECL_FUNCTION_CODE (fndecl))
            {
            case BUILT_IN_EH_POINTER:
index e181468fba91a6e17afb7b6dea0371e5fc5d8275..77eefac4e341f8f9f054bc4c43f92f080fb332a0 100644 (file)
@@ -1079,7 +1079,7 @@ if_convertible_stmt_p (gimple *stmt, vec<data_reference_p> refs)
                && !(flags & ECF_LOOPING_CONST_OR_PURE)
                /* We can only vectorize some builtins at the moment,
                   so restrict if-conversion to those.  */
-               && DECL_BUILT_IN (fndecl))
+               && fndecl_built_in_p (fndecl))
              return true;
          }
        return false;
index ef615cc347e837d9cb3c9980322f40ae65680fdf..9352acc8af6bd938ba6b252ba3e9ab58ef7d92c0 100644 (file)
@@ -1702,7 +1702,7 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
          case GIMPLE_CALL:
            {
              tree r, fndecl = gimple_call_fndecl (copy);
-             if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+             if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
                switch (DECL_FUNCTION_CODE (fndecl))
                  {
                  case BUILT_IN_EH_COPY_VALUES:
@@ -1939,8 +1939,7 @@ copy_bb (copy_body_data *id, basic_block bb,
          else if (call_stmt
                   && id->call_stmt
                   && (decl = gimple_call_fndecl (stmt))
-                  && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
-                  && DECL_FUNCTION_CODE (decl) == BUILT_IN_VA_ARG_PACK_LEN)
+                  && fndecl_built_in_p (decl, BUILT_IN_VA_ARG_PACK_LEN))
            {
              /* __builtin_va_arg_pack_len () should be replaced by
                 the number of anonymous arguments.  */
@@ -4039,7 +4038,7 @@ estimate_num_insns (gimple *stmt, eni_weights *weights)
        if (gimple_call_internal_p (stmt))
          return 0;
        else if ((decl = gimple_call_fndecl (stmt))
-                && DECL_BUILT_IN (decl))
+                && fndecl_built_in_p (decl))
          {
            /* Do not special case builtins where we see the body.
               This just confuse inliner.  */
@@ -4903,7 +4902,7 @@ fold_marked_statements (int first, hash_set<gimple *> *statements)
              gimple *old_stmt = gsi_stmt (gsi);
              tree old_decl = is_gimple_call (old_stmt) ? gimple_call_fndecl (old_stmt) : 0;
 
-             if (old_decl && DECL_BUILT_IN (old_decl))
+             if (old_decl && fndecl_built_in_p (old_decl))
                {
                  /* Folding builtins can create multiple instructions,
                     we need to look at all of them.  */
index 3e30f6bc3d437a3786a08bb0afae953a01b098b6..a9681ece0ae45a8ecb042c9ef920a4a12de5e91a 100644 (file)
@@ -1498,8 +1498,7 @@ scan_function (void)
 
                  if (dest)
                    {
-                     if (DECL_BUILT_IN_CLASS (dest) == BUILT_IN_NORMAL
-                         && DECL_FUNCTION_CODE (dest) == BUILT_IN_APPLY_ARGS)
+                     if (fndecl_built_in_p (dest, BUILT_IN_APPLY_ARGS))
                        encountered_apply_args = true;
                      if (recursive_call_p (current_function_decl, dest))
                        {
index d0f799eb39de067ec3ef84dab73e9181146b4b4b..95368a5c79d21c9f1bda0d2f896a1d613fbeead9 100644 (file)
@@ -807,7 +807,7 @@ surely_varying_stmt_p (gimple *stmt)
       tree fndecl, fntype = gimple_call_fntype (stmt);
       if (!gimple_call_lhs (stmt)
          || ((fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
-             && !DECL_BUILT_IN (fndecl)
+             && !fndecl_built_in_p (fndecl)
              && !lookup_attribute ("assume_aligned",
                                    TYPE_ATTRIBUTES (fntype))
              && !lookup_attribute ("alloc_align",
@@ -2560,7 +2560,7 @@ optimize_stack_restore (gimple_stmt_iterator i)
 
       callee = gimple_call_fndecl (stmt);
       if (!callee
-         || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL
+         || !fndecl_built_in_p (callee, BUILT_IN_NORMAL)
          /* All regular builtins are ok, just obviously not alloca.  */
          || ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (callee)))
        return NULL_TREE;
@@ -2596,9 +2596,7 @@ optimize_stack_restore (gimple_stmt_iterator i)
       if (is_gimple_call (stack_save))
        {
          callee = gimple_call_fndecl (stack_save);
-         if (callee
-             && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_SAVE)
+         if (callee && fndecl_built_in_p (callee, BUILT_IN_STACK_SAVE))
            {
              gimple_stmt_iterator stack_save_gsi;
              tree rhs;
@@ -3195,7 +3193,7 @@ pass_fold_builtins::execute (function *fun)
            }
 
          callee = gimple_call_fndecl (stmt);
-         if (!callee || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL)
+         if (!callee || !fndecl_built_in_p (callee, BUILT_IN_NORMAL))
            {
              gsi_next (&i);
              continue;
@@ -3370,8 +3368,7 @@ pass_fold_builtins::execute (function *fun)
            }
          callee = gimple_call_fndecl (stmt);
          if (!callee
-              || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL
-             || DECL_FUNCTION_CODE (callee) == fcode)
+             || !fndecl_built_in_p (callee, fcode))
            gsi_next (&i);
        }
     }
index d23148675c945bdce3ad70dc3fabb517295f26d3..91ce2aa4fc52d86e4f3680bc0ba2d3ca90c98ad3 100644 (file)
@@ -224,7 +224,7 @@ mark_stmt_if_obviously_necessary (gimple *stmt, bool aggressive)
       {
        tree callee = gimple_call_fndecl (stmt);
        if (callee != NULL_TREE
-           && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+           && fndecl_built_in_p (callee, BUILT_IN_NORMAL))
          switch (DECL_FUNCTION_CODE (callee))
            {
            case BUILT_IN_MALLOC:
@@ -565,7 +565,7 @@ mark_all_reaching_defs_necessary_1 (ao_ref *ref ATTRIBUTE_UNUSED,
     {
       tree callee = gimple_call_fndecl (def_stmt);
       if (callee != NULL_TREE
-         && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+         && fndecl_built_in_p (callee, BUILT_IN_NORMAL))
        switch (DECL_FUNCTION_CODE (callee))
          {
          case BUILT_IN_MALLOC:
index 7430fd7e706c2d38fb449c9d261dd9b02854f0da..f7cc034b26ed3a2f87feaff7c185892a5083cd75 100644 (file)
@@ -1987,8 +1987,7 @@ dom_opt_dom_walker::optimize_stmt (basic_block bb, gimple_stmt_iterator si)
             certain that the value simply isn't constant.  */
          tree callee = gimple_call_fndecl (stmt);
          if (callee
-             && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL
-             && DECL_FUNCTION_CODE (callee) == BUILT_IN_CONSTANT_P)
+             && fndecl_built_in_p (callee, BUILT_IN_CONSTANT_P))
            {
              propagate_tree_value_into_stmt (&si, integer_zero_node);
              stmt = gsi_stmt (si);
index 4ed61c37a5fa5c8705928cb864936f97d9ce136b..efdf2094c8bce6bc9122de6d1d3424e336809144 100644 (file)
@@ -1278,7 +1278,7 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
                 constant length.  */
              callee1 = gimple_call_fndecl (stmt1);
              if (callee1 == NULL_TREE
-                 || DECL_BUILT_IN_CLASS (callee1) != BUILT_IN_NORMAL
+                 || !fndecl_built_in_p (callee1, BUILT_IN_NORMAL)
                  || gimple_call_num_args (stmt1) != 3)
                break;
              if (DECL_FUNCTION_CODE (callee1) != BUILT_IN_MEMCPY
@@ -2538,7 +2538,7 @@ pass_forwprop::execute (function *fun)
              {
                tree callee = gimple_call_fndecl (stmt);
                if (callee != NULL_TREE
-                   && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+                   && fndecl_built_in_p (callee, BUILT_IN_NORMAL))
                  changed = simplify_builtin_call (&gsi, callee);
                break;
              }
index 01a954eeb1e52fdc341c8e4c114607675ab1d2a2..9c62f20866c8b59e53d694438812721cea68ba57 100644 (file)
@@ -471,9 +471,7 @@ stmt_cost (gimple *stmt)
       /* Unless the call is a builtin_constant_p; this always folds to a
         constant, so moving it is useless.  */
       fndecl = gimple_call_fndecl (stmt);
-      if (fndecl
-         && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-         && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CONSTANT_P)
+      if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_CONSTANT_P))
        return 0;
 
       return LIM_EXPENSIVE;
index a90d9d28e4ef6ce66fa380f314a9749fa952be0a..25378da6f4ab27dbce51e10461efc18cc416a4d7 100644 (file)
@@ -793,7 +793,7 @@ pass_cse_reciprocals::execute (function *fun)
                    {
                      fndecl = gimple_call_fndecl (call);
                      if (!fndecl
-                         || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD)
+                         || !fndecl_built_in_p (fndecl, BUILT_IN_MD))
                        continue;
                      fndecl = targetm.builtin_reciprocal (fndecl);
                      if (!fndecl)
index c927cb8078f1ad2f70e246c8584fb2d020aa5719..42676487c86bfdf0d5e41089b224651fcad1754c 100644 (file)
@@ -1373,7 +1373,7 @@ fully_constant_vn_reference_p (vn_reference_t ref)
   if (op->opcode == CALL_EXPR
       && TREE_CODE (op->op0) == ADDR_EXPR
       && TREE_CODE (TREE_OPERAND (op->op0, 0)) == FUNCTION_DECL
-      && DECL_BUILT_IN (TREE_OPERAND (op->op0, 0))
+      && fndecl_built_in_p (TREE_OPERAND (op->op0, 0))
       && operands.length () >= 2
       && operands.length () <= 3)
     {
index d0792aa38c879f3f4c71cbf1048e9c0f4f6229cc..b90d4a17985b73a44de611144bbdb14d471ea12f 100644 (file)
@@ -581,7 +581,7 @@ get_string_length (strinfo *si)
 
       gcc_assert (is_gimple_call (stmt));
       callee = gimple_call_fndecl (stmt);
-      gcc_assert (callee && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL);
+      gcc_assert (callee && fndecl_built_in_p (callee, BUILT_IN_NORMAL));
       lhs = gimple_call_lhs (stmt);
       /* unshare_strinfo is intentionally not called here.  The (delayed)
         transformation of strcpy or strcat into stpcpy is done at the place
index fd24f84fb146e71b7a18a7548df648969c0f3361..225583511384906dca5142f5ae7df1a5abb8838d 100644 (file)
@@ -4075,7 +4075,7 @@ handle_lhs_call (gcall *stmt, tree lhs, int flags, vec<ce_s> rhsc,
         initialized and thus may point to global memory.  All
         builtin functions with the malloc attribute behave in a sane way.  */
       if (!fndecl
-         || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
+         || !fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
        make_constraint_from (vi, nonlocal_id);
       tmpc.var = vi->id;
       tmpc.offset = 0;
@@ -4729,7 +4729,7 @@ find_func_aliases_for_call (struct function *fn, gcall *t)
   varinfo_t fi;
 
   if (fndecl != NULL_TREE
-      && DECL_BUILT_IN (fndecl)
+      && fndecl_built_in_p (fndecl)
       && find_func_aliases_for_builtin_call (fn, t))
     return;
 
index 4339520039ba61c669d1120e78375fb57f405ead..3396a5c28dfcb26774b520c1bd0c9409748fbb76 100644 (file)
@@ -683,7 +683,7 @@ find_replaceable_in_bb (temp_expr_table *tab, basic_block bb)
         insns instead of a true call.  */
       if (is_gimple_call (stmt)
          && !((fndecl = gimple_call_fndecl (stmt))
-              && DECL_BUILT_IN (fndecl)))
+              && fndecl_built_in_p (fndecl)))
        cur_call_cnt++;
 
       /* Increment counter if this statement sets a local
index c8594851957035e85843d63b29edffe3981503d0..f40dc5641cd2bd5a5e57452025163db1d80f050d 100644 (file)
@@ -694,7 +694,7 @@ optimize_va_list_gpr_fpr_size (function *fun)
 
          callee = gimple_call_fndecl (stmt);
          if (!callee
-             || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL)
+             || !fndecl_built_in_p (callee, BUILT_IN_NORMAL))
            continue;
 
          switch (DECL_FUNCTION_CODE (callee))
@@ -867,9 +867,8 @@ optimize_va_list_gpr_fpr_size (function *fun)
              tree callee = gimple_call_fndecl (stmt);
 
              if (callee
-                 && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL
-                 && (DECL_FUNCTION_CODE (callee) == BUILT_IN_VA_START
-                     || DECL_FUNCTION_CODE (callee) == BUILT_IN_VA_END))
+                 && (fndecl_built_in_p (callee, BUILT_IN_VA_START)
+                     || fndecl_built_in_p (callee, BUILT_IN_VA_END)))
                continue;
            }
 
index 9ebed9de524de57e473160e2d899284ee23ebf09..8e9c2cbd2897c4735082dfd6a6c2e805ffbeff83 100644 (file)
@@ -476,7 +476,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
   tail_recursion = false;
   func = gimple_call_fndecl (call);
   if (func
-      && !DECL_BUILT_IN (func)
+      && !fndecl_built_in_p (func)
       && recursive_call_p (current_function_decl, func))
     {
       tree arg;
index f00a519b3020510bbac40f12871511edfe132834..5ae467437b5ace5ba0e6f97675658046c5722fd7 100644 (file)
@@ -5240,7 +5240,7 @@ need_assembler_name_p (tree decl)
     {
       /* Do not set assembler name on builtins.  Allow RTL expansion to
         decide whether to expand inline or via a regular call.  */
-      if (DECL_BUILT_IN (decl)
+      if (fndecl_built_in_p (decl)
          && DECL_BUILT_IN_CLASS (decl) != BUILT_IN_FRONTEND)
        return false;
 
@@ -5371,10 +5371,9 @@ free_lang_data_in_decl (tree decl)
         nodes and thus we can't use TREE_CHAIN in multiple lists.  */
       tree *nextp = &BLOCK_VARS (DECL_INITIAL (decl));
       while (*nextp)
-        {
-          tree var = *nextp;
-          if (TREE_CODE (var) == FUNCTION_DECL
-              && DECL_BUILT_IN (var))
+       {
+         tree var = *nextp;
+         if (fndecl_built_in_p (var))
            *nextp = TREE_CHAIN (var);
          else
            nextp = &TREE_CHAIN (var);
@@ -9100,7 +9099,7 @@ get_call_combined_fn (const_tree call)
     return as_combined_fn (CALL_EXPR_IFN (call));
 
   tree fndecl = get_callee_fndecl (call);
-  if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+  if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     return as_combined_fn (DECL_FUNCTION_CODE (fndecl));
 
   return CFN_LAST;
index 5d4f034e0085f6d6ea1e6cbf196ebefbee09137e..db04eb7e58beb0cbffb9d8e28669386ff444a3d0 100644 (file)
@@ -2995,25 +2995,11 @@ extern vec<tree, va_gc> **decl_debug_args_insert (tree);
 #define DECL_STRUCT_FUNCTION(NODE) \
   (FUNCTION_DECL_CHECK (NODE)->function_decl.f)
 
-/* In a FUNCTION_DECL, nonzero means a built in function of a
-   standard library or more generally a built in function that is
-   recognized by optimizers and expanders.
-
-   Note that it is different from the DECL_IS_BUILTIN accessor.  For
-   instance, user declared prototypes of C library functions are not
-   DECL_IS_BUILTIN but may be DECL_BUILT_IN.  */
-#define DECL_BUILT_IN(NODE) (DECL_BUILT_IN_CLASS (NODE) != NOT_BUILT_IN)
 
 /* For a builtin function, identify which part of the compiler defined it.  */
 #define DECL_BUILT_IN_CLASS(NODE) \
    (FUNCTION_DECL_CHECK (NODE)->function_decl.built_in_class)
 
-/* For a function declaration, return true if NODE is non-null and it is
-   a builtin of a CLASS with requested NAME.  */
-#define DECL_BUILT_IN_P(NODE, CLASS, NAME) \
-  (NODE != NULL_TREE && DECL_BUILT_IN_CLASS (NODE) == CLASS \
-   && DECL_FUNCTION_CODE (NODE) == NAME)
-
 /* In FUNCTION_DECL, a chain of ..._DECL nodes.  */
 #define DECL_ARGUMENTS(NODE) \
    (FUNCTION_DECL_CHECK (NODE)->function_decl.arguments)
@@ -5848,4 +5834,49 @@ type_has_mode_precision_p (const_tree t)
   return known_eq (TYPE_PRECISION (t), GET_MODE_PRECISION (TYPE_MODE (t)));
 }
 
+/* For a FUNCTION_DECL NODE, nonzero means a built in function of a
+   standard library or more generally a built in function that is
+   recognized by optimizers and expanders.
+
+   Note that it is different from the DECL_IS_BUILTIN accessor.  For
+   instance, user declared prototypes of C library functions are not
+   DECL_IS_BUILTIN but may be DECL_BUILT_IN.
+
+   When a NULL argument is pass or tree code of the NODE is not FUNCTION_DECL
+   false is returned.  */
+
+inline bool
+fndecl_built_in_p (const_tree node)
+{
+  return (DECL_BUILT_IN_CLASS (node) != NOT_BUILT_IN);
+}
+
+/* For a FUNCTION_DECL NODE, return true when a function is
+   a built-in of class KLASS.  */
+
+inline bool
+fndecl_built_in_p (const_tree node, built_in_class klass)
+{
+  return (fndecl_built_in_p (node) && DECL_BUILT_IN_CLASS (node) == klass);
+}
+
+/* For a FUNCTION_DECL NODE, return true when a function is
+   a built-in of class KLASS with name equal to NAME.  */
+
+inline bool
+fndecl_built_in_p (const_tree node, int name, built_in_class klass)
+{
+  return (fndecl_built_in_p (node, klass) && DECL_FUNCTION_CODE (node) == name);
+}
+
+/* For a FUNCTION_DECL NODE, return true when a function is
+   a built-in of class BUILT_IN_NORMAL class with name equal to NAME.  */
+
+inline bool
+fndecl_built_in_p (const_tree node, built_in_function name)
+{
+  return (fndecl_built_in_p (node, BUILT_IN_NORMAL)
+         && DECL_FUNCTION_CODE (node) == name);
+}
+
 #endif  /* GCC_TREE_H  */
index 722f5702612887d56a477b43248fc049835d14b1..9bbcecc58af9943fd6fed3d4cf86e0b0b3cd52e1 100644 (file)
@@ -663,7 +663,7 @@ bool
 is_ubsan_builtin_p (tree t)
 {
   return TREE_CODE (t) == FUNCTION_DECL
-        && DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL
+        && fndecl_built_in_p (t, BUILT_IN_NORMAL)
         && strncmp (IDENTIFIER_POINTER (DECL_NAME (t)),
                     "__builtin___ubsan_", 18) == 0;
 }
index 99de27d9d3c400695624fa78733422cfc573fe30..2180da48895827967bc902fba604fc5c69478885 100644 (file)
@@ -2401,7 +2401,7 @@ static hash_set<tree> *pending_assemble_externals_set;
 static bool
 incorporeal_function_p (tree decl)
 {
-  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
+  if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl))
     {
       const char *name;