+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
+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'.
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;
{
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);
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);
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 "
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". */
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);
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;
{
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). */
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;
}
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))
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);
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));
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. */
/* 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 *);
+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.
{
/* 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]))
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))
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))
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;
+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
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))
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;
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. */
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)
&& 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))
|| 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. */
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);
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
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));
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,
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
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];
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)
#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
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;
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))
{
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:
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))
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. */
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
{
/* 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));
/* 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
/* 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 ()
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))
{
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 ();
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. */
{
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;
{
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:
+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
/* 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);
/* 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;
{
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. */
/* 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)
{
/* 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
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))
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)
{
{
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;
/* 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))
/* 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);
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))
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)
{
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. */
}
/* 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);
/* 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);
"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. */
/* 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);
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);
}
/* 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;
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
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))
{
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;
&& 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)
}
/* 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);
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));
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)
{
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)))
{
}
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)
{
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);
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
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
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;
}
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));
}
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:
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)
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;
/* 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);
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),
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);
+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
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])))
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)
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";
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;
}
/* 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;
/* 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,
/* 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;
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. */
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 ());
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)));
+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
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);
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)))
{
{
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;
/* 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);
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);
}
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;
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);
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:
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)))
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);
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))
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));
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
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;
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)));
}
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
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)));
}
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
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
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)
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;
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))
{
/* 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:
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))
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:
&& !(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;
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:
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. */
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. */
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. */
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))
{
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",
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;
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;
}
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;
}
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);
}
}
{
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:
{
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:
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);
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
{
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;
}
/* 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;
{
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)
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)
{
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
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;
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;
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
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))
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;
}
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;
{
/* 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;
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);
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;
#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)
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 */
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;
}
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;