public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Use more DECL_BUILT_IN_P macro.
@ 2018-08-14  9:06 Martin Liška
  2018-08-14 16:03 ` Martin Sebor
  0 siblings, 1 reply; 14+ messages in thread
From: Martin Liška @ 2018-08-14  9:06 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 3026 bytes --]

Hi.

The patch adds more usages of the new macro. I hope it improves
readability of code.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2018-08-10  Martin Liska  <mliska@suse.cz>

	* tree.h (DECL_BUILT_IN_P): Add also check
        for TREE_CODE (NODE) == FUNCTION_DECL.
	* builtins.c (fold_call_expr): Use DECL_BUILT_IN_P macro.
	(fold_builtin_call_array): 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 (cgraph_node::create_clone): Likewise.
	* dse.c (scan_insn): Likewise.
	* fold-const.c (fold_binary_loc): Likewise.
	* gimple-pretty-print.c (dump_gimple_call): Likewise.
	* gimple.c (gimple_call_builtin_p): Likewise.
	* gimplify.c (gimplify_call_expr): Likewise.
	(gimple_boolify): Likewise.
	(gimplify_modify_expr): Likewise.
	* ipa-fnsummary.c (compute_fn_summary): Likewise.
	* omp-low.c (setjmp_or_longjmp_p): Likewise.
	* trans-mem.c (is_tm_irrevocable): Likewise.
	(is_tm_abort): Likewise.
	* tree-cfg.c (stmt_can_terminate_bb_p): Likewise.
	* tree-inline.c (copy_bb): Likewise.
	* tree-sra.c (scan_function): Likewise.
	* tree-ssa-ccp.c (optimize_stack_restore): Likewise.
	(pass_fold_builtins::execute): Likewise.
	* tree-ssa-dom.c (dom_opt_dom_walker::optimize_stmt): Likewise.
	* tree-ssa-loop-im.c (stmt_cost): Likewise.
	* tree-stdarg.c (optimize_va_list_gpr_fpr_size): Likewise.

gcc/c/ChangeLog:

2018-08-10  Martin Liska  <mliska@suse.cz>

	* c-parser.c (c_parser_postfix_expression_after_primary):
        Use DECL_BUILT_IN_P macro.

gcc/cp/ChangeLog:

2018-08-10  Martin Liska  <mliska@suse.cz>

	* constexpr.c (constexpr_fn_retval): Use DECL_BUILT_IN_P macro.
	(cxx_eval_builtin_function_call): Likewise.
	* cp-gimplify.c (cp_gimplify_expr): Likewise.
	(cp_fold): Likewise.
	* semantics.c (finish_call_expr): Likewise.
	* tree.c (builtin_valid_in_constant_expr_p): Likewise.
---
 gcc/builtins.c            | 10 ++--------
 gcc/c/c-parser.c          |  9 +++------
 gcc/cgraph.c              | 13 ++++++-------
 gcc/cgraphclones.c        |  4 ++--
 gcc/cp/constexpr.c        | 12 +++++-------
 gcc/cp/cp-gimplify.c      | 12 ++++--------
 gcc/cp/semantics.c        |  4 +---
 gcc/cp/tree.c             |  5 ++---
 gcc/dse.c                 |  5 ++---
 gcc/fold-const.c          |  4 +---
 gcc/gimple-pretty-print.c |  4 +---
 gcc/gimple.c              |  3 +--
 gcc/gimplify.c            | 14 ++++----------
 gcc/ipa-fnsummary.c       |  8 ++++----
 gcc/omp-low.c             |  5 ++---
 gcc/trans-mem.c           |  8 ++------
 gcc/tree-cfg.c            |  3 +--
 gcc/tree-inline.c         |  4 ++--
 gcc/tree-sra.c            |  4 ++--
 gcc/tree-ssa-ccp.c        |  8 ++------
 gcc/tree-ssa-dom.c        |  4 +---
 gcc/tree-ssa-loop-im.c    |  4 +---
 gcc/tree-stdarg.c         |  6 ++----
 gcc/tree.h                |  4 +++-
 24 files changed, 56 insertions(+), 101 deletions(-)



[-- Attachment #2: 0001-Use-more-DECL_BUILT_IN_P-macro.patch --]
[-- Type: text/x-patch, Size: 20310 bytes --]

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 867d153d798..e6279979544 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -9629,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 (DECL_BUILT_IN_P (fndecl2, BUILT_IN_NORMAL, BUILT_IN_VA_ARG_PACK))
 	    return NULL_TREE;
 	}
 
@@ -9675,10 +9672,7 @@ fold_builtin_call_array (location_t loc, tree,
       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 (DECL_BUILT_IN_P (fndecl2, BUILT_IN_NORMAL, BUILT_IN_VA_ARG_PACK))
 	    return NULL_TREE;
 	}
       if (avoid_folding_inline_builtin (fndecl))
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 7a926285f3a..6e44ee7e366 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -9159,9 +9159,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
 					      expr.value, exprlist,
 					      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
+	  if (DECL_BUILT_IN_P (expr.value, BUILT_IN_NORMAL, BUILT_IN_MEMSET)
 	      && vec_safe_length (exprlist) == 3)
 	    {
 	      tree arg0 = (*exprlist)[0];
@@ -9178,9 +9176,8 @@ 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)
+	      && DECL_BUILT_IN_P (orig_expr.value, BUILT_IN_NORMAL,
+				  BUILT_IN_CONSTANT_P))
 	    expr.original_code = C_MAYBE_CONST_EXPR;
 	  expr.original_type = NULL;
 	  if (exprlist)
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index d19f1aacab8..bc90ac3c7c6 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1559,8 +1559,8 @@ 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)
+	      && DECL_BUILT_IN_P (e->callee->decl, BUILT_IN_NORMAL,
+				  BUILT_IN_UNREACHABLE))
 	    {
               node->get_edge (old_stmt)->set_call_stmt
 		 (as_a <gcall *> (new_stmt));
@@ -3060,8 +3060,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 (DECL_BUILT_IN_P (callee->decl, BUILT_IN_NORMAL, BUILT_IN_UNREACHABLE))
     return false;
 
   if (callee->former_clone_of != node->decl
@@ -3186,9 +3186,8 @@ cgraph_node::verify_node (void)
 	  && !e->speculative
 	  /* 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)
+	      || !DECL_BUILT_IN_P (e->callee->decl, BUILT_IN_NORMAL,
+				   BUILT_IN_UNREACHABLE))
 	  && count
 	      == ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (decl))->count
 	  && (!e->count.ipa_p ()
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 6e84a31c1a5..b7c328f25b8 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -482,8 +482,8 @@ 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)
+	  || !DECL_BUILT_IN_P (e->callee->decl, BUILT_IN_NORMAL,
+			       BUILT_IN_UNREACHABLE))
         e->redirect_callee_duplicating_thunks (new_node);
     }
   new_node->expand_all_artificial_thunks ();
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index ece2c8a92d9..2fa7a34974e 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -712,9 +712,8 @@ constexpr_fn_retval (tree body)
     case CALL_EXPR:
 	{
 	  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)
+	  if (DECL_BUILT_IN_P (fun, BUILT_IN_NORMAL,
+			       BUILT_IN_UNREACHABLE))
 	    return NULL_TREE;
 	}
       /* Fallthru.  */
@@ -1189,8 +1188,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 (DECL_BUILT_IN_P (fun, BUILT_IN_FRONTEND,
+		       CP_BUILT_IN_IS_CONSTANT_EVALUATED))
     {
       if (!ctx->pretend_const_required)
 	{
@@ -1233,8 +1232,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 (DECL_BUILT_IN_P (fun, BUILT_IN_NORMAL, BUILT_IN_UNREACHABLE)
 	      && EXPR_LOCATION (t) == BUILTINS_LOCATION)
 	    error ("%<constexpr%> call flows off the end of the function");
 	  else
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 7db4accb504..e7c5c8deef2 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -796,10 +796,8 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       if (ret != GS_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))
+	  if (DECL_BUILT_IN_P (decl, BUILT_IN_FRONTEND,
+			       CP_BUILT_IN_IS_CONSTANT_EVALUATED))
 	    *expr_p = boolean_false_node;
 	}
       break;
@@ -2493,10 +2491,8 @@ cp_fold (tree x)
 	  nw = 1;
 
 	/* 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))
+	if (DECL_BUILT_IN_P (callee, BUILT_IN_FRONTEND,
+			     CP_BUILT_IN_IS_CONSTANT_EVALUATED))
 	  break;
 
 	x = copy_node (x);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index bfdca5024d3..153c020546a 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2545,9 +2545,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
+	      && DECL_BUILT_IN_P (fn, BUILT_IN_NORMAL, BUILT_IN_MEMSET)
 	      && vec_safe_length (*args) == 3
 	      && !any_type_dependent_arguments_p (*args))
 	    {
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 1cf3269d880..a91060d3c21 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -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 (DECL_BUILT_IN_P (decl, BUILT_IN_FRONTEND,
+			   CP_BUILT_IN_IS_CONSTANT_EVALUATED))
 	return true;
       /* Not a built-in.  */
       return false;
diff --git a/gcc/dse.c b/gcc/dse.c
index 26c6007b9ed..c09766241a1 100644
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -2418,9 +2418,8 @@ scan_insn (bb_info_t bb_info, rtx_insn *insn)
 	  && (sym = XEXP (XEXP (call, 0), 0))
 	  && 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)
+	  && DECL_BUILT_IN_P (SYMBOL_REF_DECL (sym), BUILT_IN_NORMAL,
+			      BUILT_IN_MEMSET))
 	memset_call = SYMBOL_REF_DECL (sym);
 
       if (const_call || memset_call)
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index b318fc7705f..55f063549ee 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -10752,9 +10752,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
+	  if (DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_STRLEN)
 	      && call_expr_nargs (arg0) == 1
 	      && TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (arg0, 0))) == POINTER_TYPE)
 	    {
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index d3c5ec6f79b..6eed1e8d3ea 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -910,9 +910,7 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
     fn = TREE_OPERAND (fn, 0);
   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
+  if (DECL_BUILT_IN_P (fn, BUILT_IN_NORMAL, BUILT_IN_TM_START)
       && gimple_call_num_args (gs) > 0)
     {
       tree t = gimple_call_arg (gs, 0);
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 8d56a966cc1..4fa519f0fe5 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -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)
+      && DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, code))
     return gimple_builtin_call_types_compatible_p (stmt, fndecl);
   return false;
 }
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 4a109aee27a..153f20c5ac9 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -3295,10 +3295,8 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
       tree last_arg = CALL_EXPR_ARG (*expr_p, nargs - 1);
       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)
+      if (DECL_BUILT_IN_P (last_arg_fndecl, BUILT_IN_NORMAL,
+			   BUILT_IN_VA_ARG_PACK))
 	{
 	  tree call = *expr_p;
 
@@ -3771,9 +3769,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
+      if (DECL_BUILT_IN_P (fn, BUILT_IN_NORMAL, BUILT_IN_EXPECT)
 	  && call_expr_nargs (call) == 2)
 	{
 	  tree arg = CALL_EXPR_ARG (call, 0);
@@ -5717,9 +5713,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	  CALL_EXPR_FN (*from_p) = TREE_OPERAND (CALL_EXPR_FN (*from_p), 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
+	  if (DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, 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),
diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
index a8fc2c2df9a..dabd858bf32 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -2455,10 +2455,10 @@ 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 (DECL_BUILT_IN_P (cdecl, BUILT_IN_NORMAL,
+					BUILT_IN_APPLY_ARGS)
+		       || DECL_BUILT_IN_P (cdecl, BUILT_IN_NORMAL,
+					   BUILT_IN_VA_START))
 		     break;
 		 }
 	       node->local.can_change_signature = !e;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 843c66fd221..e9f1bee8055 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -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 (DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_SETJMP)
+      || DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_LONGJMP))
     return true;
 
   tree declname = DECL_NAME (fndecl);
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index ca14915ef0d..e1fed1134c8 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -234,9 +234,7 @@ is_tm_irrevocable (tree x)
      irrevocable.  */
   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)
+  if (DECL_BUILT_IN_P (x, BUILT_IN_NORMAL, BUILT_IN_TM_IRREVOCABLE))
     return true;
 
   return false;
@@ -440,9 +438,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 DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_TM_ABORT);
 }
 
 /* Build a GENERIC tree for a user abort.  This is called by front ends
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 14d66b7a728..459f2ce8cc5 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -8312,8 +8312,7 @@ stmt_can_terminate_bb_p (gimple *t)
          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))
+      && !DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_FORK))
     return false;
 
   if (is_gimple_call (t))
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 6a16ce546cb..03db7453a75 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1939,8 +1939,8 @@ 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
+		   && DECL_BUILT_IN_P (decl, BUILT_IN_NORMAL,
+				       BUILT_IN_VA_ARG_PACK_LEN)
 		   && ! gimple_call_va_arg_pack_p (id->call_stmt))
 	    {
 	      /* __builtin_va_arg_pack_len () should be replaced by
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 3e30f6bc3d4..23c9b865a15 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1498,8 +1498,8 @@ scan_function (void)
 
 		  if (dest)
 		    {
-		      if (DECL_BUILT_IN_CLASS (dest) == BUILT_IN_NORMAL
-			  && DECL_FUNCTION_CODE (dest) == BUILT_IN_APPLY_ARGS)
+		      if (DECL_BUILT_IN_P (dest, BUILT_IN_NORMAL,
+					   BUILT_IN_APPLY_ARGS))
 			encountered_apply_args = true;
 		      if (recursive_call_p (current_function_decl, dest))
 			{
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 63c95318ace..3e30e78f9eb 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -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 (DECL_BUILT_IN_P (callee, BUILT_IN_NORMAL, BUILT_IN_STACK_SAVE))
 	    {
 	      gimple_stmt_iterator stack_save_gsi;
 	      tree rhs;
@@ -3369,9 +3367,7 @@ pass_fold_builtins::execute (function *fun)
 	      continue;
 	    }
 	  callee = gimple_call_fndecl (stmt);
-	  if (!callee
-              || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL
-	      || DECL_FUNCTION_CODE (callee) == fcode)
+	  if (!DECL_BUILT_IN_P (callee, BUILT_IN_NORMAL, fcode))
 	    gsi_next (&i);
 	}
     }
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 267880f3b5c..578eaa4233a 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1985,9 +1985,7 @@ dom_opt_dom_walker::optimize_stmt (basic_block bb, gimple_stmt_iterator si)
 	     folded to integer_one_node by now, it's fairly
 	     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)
+	  if (DECL_BUILT_IN_P (callee, BUILT_IN_NORMAL, BUILT_IN_CONSTANT_P))
 	    {
 	      propagate_tree_value_into_stmt (&si, integer_zero_node);
 	      stmt = gsi_stmt (si);
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 01a954eeb1e..4d0a24c8a0f 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -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 (DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_CONSTANT_P))
 	return 0;
 
       return LIM_EXPENSIVE;
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index c8594851957..58250eab5fa 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -866,10 +866,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))
+	      if (DECL_BUILT_IN_P (callee, BUILT_IN_NORMAL, BUILT_IN_VA_START)
+		  || DECL_BUILT_IN_P (callee, BUILT_IN_NORMAL, BUILT_IN_VA_END))
 		continue;
 	    }
 
diff --git a/gcc/tree.h b/gcc/tree.h
index 648e9e2a3c4..b464dbe683b 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3011,7 +3011,9 @@ extern vec<tree, va_gc> **decl_debug_args_insert (tree);
 /* 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 \
+  (NODE != NULL_TREE \
+   && TREE_CODE (NODE) == FUNCTION_DECL \
+   && DECL_BUILT_IN_CLASS (NODE) == CLASS \
    && DECL_FUNCTION_CODE (NODE) == NAME)
 
 /* In FUNCTION_DECL, a chain of ..._DECL nodes.  */


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-08-28 19:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-14  9:06 [PATCH] Use more DECL_BUILT_IN_P macro Martin Liška
2018-08-14 16:03 ` Martin Sebor
2018-08-15 12:52   ` Martin Liška
2018-08-20  8:35     ` Richard Biener
2018-08-23 10:46       ` Martin Liška
2018-08-23 11:58         ` Richard Biener
2018-08-23 13:30           ` Martin Liška
2018-08-23 13:58             ` Richard Biener
2018-08-23 14:43               ` Martin Liška
2018-08-27  7:20               ` Martin Liška
2018-08-27  8:18                 ` Richard Biener
2018-08-27 16:02                 ` Martin Sebor
2018-08-28  7:17                   ` Martin Liška
2018-08-28 19:18                 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).