This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Disentangle DECL_FUNCTION_CODE overloading


Hi,

It all started with some random hacking in config/sparc and suddenly:

[eric@localhost sparc64-sun-solaris2.9]$ cat pdist.c
typedef long long int64_t;
typedef char vec8 __attribute__((vector_size(8)));

int64_t foo (vec8 a, vec8 b) {
  int64_t d = 0;
  d = __builtin_vis_pdist (a, b, d);
  return d;
}
[eric@localhost sparc64-sun-solaris2.9]$ gcc/xgcc -Bgcc pdist.c -S 
-mcpu=ultrasparc -mvis
pdist.c: In function 'foo':
pdist.c:6: error: 'va_start' used in function with fixed args

So __builtin_vis_pdist (a SPARC VIS builtin) has somehow morphed into 
__builtin_va_start (a "normal" builtin).  It turns out that DECL_FUNCTION_CODE 
is overloaded and the discriminant is DECL_BUILT_IN_CLASS so the latter must 
be checked before any access to the former.

Bootstrapped/regtested on amd64-mandrake-linux-gnu.  OK for mainline?


2005-01-18  Eric Botcazou  <ebotcazou@libertysurf.fr>

	* calls.c (expand_call): Check DECL_BUILT_IN_CLASS before
	accessing DECL_FUNCTION_CODE.
	* dojump.c (do_jump): Likewise.
	* gimplify.c (gimplify_call_expr): Likewise.
	* predict.c (expr_expected_value): Likewise.
	(strip_builtin_expect): Likewise.
	* tree-inline.c (estimate_num_insns_1): Likewise.
	* tree-ssa-loop-im.c (stmt_cost): Likewise
	* fold-const.c (fold): Test for BUILT_IN_NORMAL.
	(tree_expr_nonnegative_p): Likewise.


-- 
Eric Botcazou
Index: calls.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/calls.c,v
retrieving revision 1.376
diff -u -p -r1.376 calls.c
--- calls.c	11 Jan 2005 09:51:15 -0000	1.376
+++ calls.c	18 Jan 2005 14:44:20 -0000
@@ -2722,7 +2722,7 @@ expand_call (tree exp, rtx target, int i
 	      end_sequence ();
 	      if (flag_unsafe_math_optimizations
 		  && fndecl
-		  && DECL_BUILT_IN (fndecl)
+		  && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
 		  && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SQRT
 		      || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SQRTF
 		      || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SQRTL))
Index: dojump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dojump.c,v
retrieving revision 1.36
diff -u -p -r1.36 dojump.c
--- dojump.c	4 Jan 2005 14:37:20 -0000	1.36
+++ dojump.c	18 Jan 2005 14:44:22 -0000
@@ -527,7 +527,7 @@ do_jump (tree exp, rtx if_false_label, r
 	tree arglist = TREE_OPERAND (exp, 1);
 
 	if (fndecl
-	    && DECL_BUILT_IN (fndecl)
+	    && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
 	    && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
 	    && arglist != NULL_TREE
 	    && TREE_CHAIN (arglist) != NULL_TREE)
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.493
diff -u -p -r1.493 fold-const.c
--- fold-const.c	15 Jan 2005 09:46:02 -0000	1.493
+++ fold-const.c	18 Jan 2005 14:44:27 -0000
@@ -8982,8 +8982,7 @@ fold (tree expr)
 	  tree arglist;
 
 	  if (fndecl
-	      && DECL_BUILT_IN (fndecl)
-	      && DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD
+	      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
 	      && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRLEN
 	      && (arglist = TREE_OPERAND (arg0, 1))
 	      && TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) == POINTER_TYPE
@@ -9809,9 +9808,7 @@ tree_expr_nonnegative_p (tree t)
       {
 	tree fndecl = get_callee_fndecl (t);
 	tree arglist = TREE_OPERAND (t, 1);
-	if (fndecl
-	    && DECL_BUILT_IN (fndecl)
-	    && DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD)
+	if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
 	  switch (DECL_FUNCTION_CODE (fndecl))
 	    {
 #define CASE_BUILTIN_F(BUILT_IN_FN) \
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 2.101
diff -u -p -r2.101 gimplify.c
--- gimplify.c	1 Jan 2005 01:43:08 -0000	2.101
+++ gimplify.c	18 Jan 2005 14:44:29 -0000
@@ -1748,7 +1748,8 @@ gimplify_call_expr (tree *expr_p, tree *
 	  return GS_OK;
 	}
 
-      if (DECL_FUNCTION_CODE (decl) == BUILT_IN_VA_START)
+      if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
+	  && DECL_FUNCTION_CODE (decl) == BUILT_IN_VA_START)
         {
 	  tree arglist = TREE_OPERAND (*expr_p, 1);
 	  
Index: predict.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/predict.c,v
retrieving revision 1.135
diff -u -p -r1.135 predict.c
--- predict.c	22 Nov 2004 17:14:00 -0000	1.135
+++ predict.c	18 Jan 2005 14:44:30 -0000
@@ -947,7 +947,8 @@ expr_expected_value (tree expr, bitmap v
       tree decl = get_callee_fndecl (expr);
       if (!decl)
 	return NULL;
-      if (DECL_BUILT_IN (decl) && DECL_FUNCTION_CODE (decl) == BUILT_IN_EXPECT)
+      if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
+	  && DECL_FUNCTION_CODE (decl) == BUILT_IN_EXPECT)
 	{
 	  tree arglist = TREE_OPERAND (expr, 1);
 	  tree val;
@@ -1006,7 +1007,7 @@ strip_builtin_expect (void)
 	  if (TREE_CODE (stmt) == MODIFY_EXPR
 	      && TREE_CODE (TREE_OPERAND (stmt, 1)) == CALL_EXPR
 	      && (fndecl = get_callee_fndecl (TREE_OPERAND (stmt, 1)))
-	      && DECL_BUILT_IN (fndecl)
+	      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
 	      && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
 	      && (arglist = TREE_OPERAND (TREE_OPERAND (stmt, 1), 1))
 	      && TREE_CHAIN (arglist))
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.164
diff -u -p -r1.164 tree-inline.c
--- tree-inline.c	17 Jan 2005 20:48:00 -0000	1.164
+++ tree-inline.c	18 Jan 2005 14:44:31 -0000
@@ -1344,7 +1344,7 @@ estimate_num_insns_1 (tree *tp, int *wal
       {
 	tree decl = get_callee_fndecl (x);
 
-	if (decl && DECL_BUILT_IN (decl))
+	if (decl && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
 	  switch (DECL_FUNCTION_CODE (decl))
 	    {
 	    case BUILT_IN_CONSTANT_P:
Index: tree-ssa-loop-im.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-im.c,v
retrieving revision 2.25
diff -u -p -r2.25 tree-ssa-loop-im.c
--- tree-ssa-loop-im.c	12 Dec 2004 15:52:32 -0000	2.25
+++ tree-ssa-loop-im.c	18 Jan 2005 14:44:32 -0000
@@ -376,7 +376,7 @@ stmt_cost (tree stmt)
       /* Unless the call is a builtin_constant_p; this always folds to a
 	 constant, so moving it is useless.  */
       rhs = get_callee_fndecl (rhs);
-      if (DECL_BUILT_IN (rhs)
+      if (DECL_BUILT_IN_CLASS (rhs) == BUILT_IN_NORMAL
 	  && DECL_FUNCTION_CODE (rhs) == BUILT_IN_CONSTANT_P)
 	return 0;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]