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, pretty-ipa] Merge two functions counting the number of parameters


Hi,

when preparing patches to merge  this part of pretty-ipa into trunk, I
have  noticed I  have the  same functionality  in two  functions.  The
following patch merges them so that we count formal parameters only at
one place.

Since this is for the pretty-ipa branch and the change is quite
obvious, I'll commit it after it bootstraps as such.

Thanks,

Martin


2009-06-09  Martin Jambor  <mjambor@suse.cz>

	* ipa-prop.c (count_formal_parameters): Moved upwards, renamed to
	count_formal_params_1.
	(ipa_count_formal_params): Use count_formal_params_1.

Index: isra/gcc/ipa-prop.c
===================================================================
--- isra.orig/gcc/ipa-prop.c	2009-06-09 22:07:43.000000000 +0200
+++ isra/gcc/ipa-prop.c	2009-06-09 22:11:22.000000000 +0200
@@ -134,6 +134,20 @@ ipa_populate_param_decls (struct cgraph_
     }
 }
 
+/* Return how many formal parameters FNDECL has.  */
+
+static inline int
+count_formal_params_1 (tree fndecl)
+{
+  tree parm;
+  int count = 0;
+
+  for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
+    count++;
+
+  return count;
+}
+
 /* Count number of formal parameters in NOTE. Store the result to the
    appropriate field of INFO.  */
 
@@ -141,16 +155,9 @@ static void
 ipa_count_formal_params (struct cgraph_node *node,
 			 struct ipa_node_params *info)
 {
-  tree fndecl;
-  tree fnargs;
-  tree parm;
   int param_num;
 
-  fndecl = node->decl;
-  fnargs = DECL_ARGUMENTS (fndecl);
-  param_num = 0;
-  for (parm = fnargs; parm; parm = TREE_CHAIN (parm))
-    param_num++;
+  param_num = count_formal_params_1 (node->decl);
   ipa_set_param_count (info, param_num);
 }
 
@@ -1355,20 +1362,6 @@ dump_aggregate (tree t, int indent)
     dump_aggregate_1 (type, indent);
 }
 
-/* Return how many formal parameters FNDECL has.  */
-
-static inline int
-count_formal_parameters (tree fndecl)
-{
-  tree parm;
-  int count = 0;
-
-  for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
-    count++;
-
-  return count;
-}
-
 /* Return a heap allocated vector containing formal parameters of FNDECL.  */
 
 VEC(tree, heap) *
@@ -1378,7 +1371,7 @@ ipa_get_vector_of_formal_parms (tree fnd
   int count;
   tree parm;
 
-  count = count_formal_parameters (fndecl);
+  count = count_formal_params_1 (fndecl);
   args = VEC_alloc (tree, heap, count);
   for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
     VEC_quick_push (tree, args, parm);


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