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] C++ fixes in ipa*


:ADDPATCH ipa:

Hi,

the attached patch fixes compiling the ipa* files with a C++ compiler.
Most changes are missing casts, the others a few type safe memory macros
and one variable rename to avoid a C++ keyword.

Tested on i686. Is this ok?

Thomas

	* ipa.c (cgraph_postorder): Cast according to the coding conventions.
	(cgraph_remove_unreachable_nodes): Likewise.
	* ipa-cp.c (ipcp_propagate_stage): Use BOTTOM instead of integer 0.
	* ipa-inline.c (update_caller_keys): Cast according to the coding
	conventions.
	(cgraph_decide_recursive_inlining): Likewise.
	(cgraph_decide_inlining_of_small_function): Likewise.
	(try_inline): Likewise.
	(cgraph_decide_inlining_incrementally): Likewise.
	* ipa-pure-const.c (get_function_state): Likewise.
	(scan_function): Likewise.
	(analyze_function): Likewise.
 	(static_execute): Likewise.
	* gcc/ipa-reference.c (scan_for_static_refs): Likewise.
	(merge_callee_local_info): Likewise.
	(analyze_function): Use type safe memory macros.
	(static_execute): Likewise. Cast according to the coding conventions.
	* ipa-type-escape.c (scan_for_regs): Cast according to the coding
	conventions.
	* ipa-utils.c (searchc): Likewise. Avoid using C++ keywords as variable
	names.
	(ipa_utils_reduced_inorder): Likewise. Use type safe memory macros.
	* ipa-utils.h (struct ipa_dfa_info): Avoid using C++ keywords as
	variable names.
Index: gcc/ipa.c
===================================================================
--- gcc/ipa.c	(revision 125521)
+++ gcc/ipa.c	(working copy)
@@ -58,7 +58,7 @@ cgraph_postorder (struct cgraph_node **o
 	  {
 	    while (node2->aux != &last)
 	      {
-		edge = node2->aux;
+		edge = (struct cgraph_edge *) node2->aux;
 		if (edge->next_caller)
 		  node2->aux = edge->next_caller;
 		else
@@ -98,7 +98,7 @@ cgraph_postorder (struct cgraph_node **o
 bool
 cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
 {
-  struct cgraph_node *first = (void *) 1;
+  struct cgraph_node *first = (struct cgraph_node *) (void *) 1;
   struct cgraph_node *node, *next;
   bool changed = false;
   int insns = 0;
@@ -131,7 +131,7 @@ cgraph_remove_unreachable_nodes (bool be
     {
       struct cgraph_edge *e;
       node = first;
-      first = first->aux;
+      first = (struct cgraph_node *) first->aux;
 
       for (e = node->callees; e; e = e->next_callee)
 	if (!e->callee->aux
Index: gcc/ipa-cp.c
===================================================================
--- gcc/ipa-cp.c	(revision 125521)
+++ gcc/ipa-cp.c	(working copy)
@@ -570,7 +570,7 @@ static void
 ipcp_propagate_stage (void)
 {
   int i;
-  struct ipcp_formal cval1 = { 0, {0} }, cval = { 0,{0} };
+  struct ipcp_formal cval1 = { BOTTOM, {0} }, cval = { BOTTOM, {0} };
   struct ipcp_formal *cval2;
   struct cgraph_node *mt, *callee;
   struct cgraph_edge *cs;
Index: gcc/ipa-inline.c
===================================================================
--- gcc/ipa-inline.c	(revision 125521)
+++ gcc/ipa-inline.c	(working copy)
@@ -584,7 +584,7 @@ update_caller_keys (fibheap_t heap, stru
       for (edge = node->callers; edge; edge = edge->next_caller)
 	if (edge->aux)
 	  {
-	    fibheap_delete_node (heap, edge->aux);
+	    fibheap_delete_node (heap, (fibnode_t) edge->aux);
 	    edge->aux = NULL;
 	    if (edge->inline_failed)
 	      edge->inline_failed = failed_reason;
@@ -598,7 +598,7 @@ update_caller_keys (fibheap_t heap, stru
 	int badness = cgraph_edge_badness (edge);
 	if (edge->aux)
 	  {
-	    fibnode_t n = edge->aux;
+	    fibnode_t n = (fibnode_t) edge->aux;
 	    gcc_assert (n->data == edge);
 	    if (n->key == badness)
 	      continue;
@@ -606,7 +606,7 @@ update_caller_keys (fibheap_t heap, stru
 	    /* fibheap_replace_key only increase the keys.  */
 	    if (fibheap_replace_key (heap, n, badness))
 	      continue;
-	    fibheap_delete_node (heap, edge->aux);
+	    fibheap_delete_node (heap, (fibnode_t) edge->aux);
 	  }
 	edge->aux = fibheap_insert (heap, badness, edge);
       }
@@ -706,7 +706,8 @@ cgraph_decide_recursive_inlining (struct
 	 && (cgraph_estimate_size_after_inlining (1, node, master_clone)
 	     <= limit))
     {
-      struct cgraph_edge *curr = fibheap_extract_min (heap);
+      struct cgraph_edge *curr
+	= (struct cgraph_edge *) fibheap_extract_min (heap);
       struct cgraph_node *cnode;
 
       depth = 1;
@@ -857,7 +858,8 @@ cgraph_decide_inlining_of_small_function
   max_insns = compute_max_insns (overall_insns);
   min_insns = overall_insns;
 
-  while (overall_insns <= max_insns && (edge = fibheap_extract_min (heap)))
+  while (overall_insns <= max_insns
+	 && (edge = (struct cgraph_edge *) fibheap_extract_min (heap)))
     {
       int old_insns = overall_insns;
       struct cgraph_node *where;
@@ -994,7 +996,7 @@ cgraph_decide_inlining_of_small_function
 	    fprintf (dump_file, "New minimal insns reached: %i\n", min_insns);
 	}
     }
-  while ((edge = fibheap_extract_min (heap)) != NULL)
+  while ((edge = (struct cgraph_edge *) fibheap_extract_min (heap)) != NULL)
     {
       gcc_assert (edge->aux);
       edge->aux = NULL;
@@ -1181,7 +1183,7 @@ static bool
 try_inline (struct cgraph_edge *e, enum inlining_mode mode, int depth)
 {
   struct cgraph_node *callee = e->callee;
-  enum inlining_mode callee_mode = (size_t) callee->aux;
+  enum inlining_mode callee_mode = (enum inlining_mode) (size_t) callee->aux;
   bool always_inline = e->callee->local.disregard_inline_limits;
 
   /* We've hit cycle?  */
@@ -1258,7 +1260,7 @@ cgraph_decide_inlining_incrementally (st
   verify_cgraph_node (node);
 #endif
 
-  old_mode = (size_t)node->aux;
+  old_mode = (enum inlining_mode) (size_t)node->aux;
 
   if (mode != INLINE_ALWAYS_INLINE
       && lookup_attribute ("flatten", DECL_ATTRIBUTES (node->decl)) != NULL)
Index: gcc/ipa-pure-const.c
===================================================================
--- gcc/ipa-pure-const.c	(revision 125521)
+++ gcc/ipa-pure-const.c	(working copy)
@@ -80,8 +80,8 @@ typedef struct funct_state_d * funct_sta
 static inline funct_state
 get_function_state (struct cgraph_node *node)
 {
-  struct ipa_dfs_info * info = node->aux;
-  return info->aux;
+  struct ipa_dfs_info * info = (struct ipa_dfs_info *) node->aux;
+  return (funct_state) info->aux;
 }
 
 /* Check to see if the use (or definition when CHECHING_WRITE is true) 
@@ -396,7 +396,7 @@ scan_function (tree *tp, 
 		      int *walk_subtrees, 
 		      void *data)
 {
-  struct cgraph_node *fn = data;
+  struct cgraph_node *fn = (struct cgraph_node *) data;
   tree t = *tp;
   funct_state local = get_function_state (fn);
 
@@ -505,7 +505,7 @@ analyze_function (struct cgraph_node *fn
 {
   funct_state l = XCNEW (struct funct_state_d);
   tree decl = fn->decl;
-  struct ipa_dfs_info * w_info = fn->aux;
+  struct ipa_dfs_info * w_info = (struct ipa_dfs_info *) fn->aux;
 
   w_info->aux = l;
 
@@ -602,7 +602,7 @@ static_execute (void)
   struct cgraph_node *w;
   struct cgraph_node **order =
     XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
-  int order_pos = order_pos = ipa_utils_reduced_inorder (order, true, false);
+  int order_pos = ipa_utils_reduced_inorder (order, true, false);
   int i;
   struct ipa_dfs_info * w_info;
 
@@ -673,7 +673,7 @@ static_execute (void)
 		    }
 		}
 	    }
-	  w_info = w->aux;
+	  w_info = (struct ipa_dfs_info *) w->aux;
 	  w = w_info->next_cycle;
 	}
 
@@ -708,7 +708,7 @@ static_execute (void)
 		  break;
 		}
 	    }
-	  w_info = w->aux;
+	  w_info = (struct ipa_dfs_info *) w->aux;
 	  w = w_info->next_cycle;
 	}
     }
@@ -718,7 +718,7 @@ static_execute (void)
     /* Get rid of the aux information.  */
     if (node->aux)
       {
-	w_info = node->aux;
+	w_info = (struct ipa_dfs_info *) node->aux;
 	if (w_info->aux)
 	  free (w_info->aux);
 	free (node->aux);
Index: gcc/ipa-reference.c
===================================================================
--- gcc/ipa-reference.c	(revision 125521)
+++ gcc/ipa-reference.c	(working copy)
@@ -475,7 +475,7 @@ scan_for_static_refs (tree *tp, 
 		      int *walk_subtrees, 
 		      void *data)
 {
-  struct cgraph_node *fn = data;
+  struct cgraph_node *fn = (struct cgraph_node *) data;
   tree t = *tp;
   ipa_reference_local_vars_info_t local = NULL;
   if (fn)
@@ -692,7 +692,7 @@ merge_callee_local_info (struct cgraph_n
     get_reference_vars_info_from_cgraph (target)->local;
 
   /* Make the world safe for tail recursion.  */
-  struct ipa_dfs_info *node_info = x->aux;
+  struct ipa_dfs_info *node_info = (struct ipa_dfs_info *) x->aux;
   
   if (node_info->aux) 
     return;
@@ -787,9 +787,9 @@ static void
 analyze_function (struct cgraph_node *fn)
 {
   ipa_reference_vars_info_t info 
-    = xcalloc (1, sizeof (struct ipa_reference_vars_info_d));
+    = XCNEW (struct ipa_reference_vars_info_d);
   ipa_reference_local_vars_info_t l
-    = xcalloc (1, sizeof (struct ipa_reference_local_vars_info_d));
+    = XCNEW (struct ipa_reference_local_vars_info_d);
   tree decl = fn->decl;
 
   /* Add the info to the tree's annotation.  */
@@ -908,8 +908,8 @@ static_execute (void)
   struct varpool_node *vnode;
   struct cgraph_node *w;
   struct cgraph_node **order =
-    xcalloc (cgraph_n_nodes, sizeof (struct cgraph_node *));
-  int order_pos = order_pos = ipa_utils_reduced_inorder (order, false, true);
+    XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
+  int order_pos = ipa_utils_reduced_inorder (order, false, true);
   int i;
 
   ipa_init ();
@@ -1080,7 +1080,7 @@ static_execute (void)
     {
       ipa_reference_vars_info_t node_info;
       ipa_reference_global_vars_info_t node_g = 
-	xcalloc (1, sizeof (struct ipa_reference_global_vars_info_d));
+	XCNEW (struct ipa_reference_global_vars_info_d);
       ipa_reference_local_vars_info_t node_l;
       
       bool read_all;
@@ -1104,7 +1104,7 @@ static_execute (void)
 
       /* If any node in a cycle is calls_read_all or calls_write_all
 	 they all are. */
-      w_info = node->aux;
+      w_info = (struct ipa_dfs_info *) node->aux;
       w = w_info->next_cycle;
       while (w)
 	{
@@ -1113,7 +1113,7 @@ static_execute (void)
 	  read_all |= w_l->calls_read_all;
 	  write_all |= w_l->calls_write_all;
 
-	  w_info = w->aux;
+	  w_info = (struct ipa_dfs_info *) w->aux;
 	  w = w_info->next_cycle;
 	}
 
@@ -1136,7 +1136,7 @@ static_execute (void)
 		       node_l->statics_written);
 	}
 
-      w_info = node->aux;
+      w_info = (struct ipa_dfs_info *) node->aux;
       w = w_info->next_cycle;
       while (w)
 	{
@@ -1157,7 +1157,7 @@ static_execute (void)
 	  if (!write_all)
 	    bitmap_ior_into (node_g->statics_written,
 			     w_l->statics_written);
-	  w_info = w->aux;
+	  w_info = (struct ipa_dfs_info *) w->aux;
 	  w = w_info->next_cycle;
 	}
 
@@ -1165,7 +1165,7 @@ static_execute (void)
       while (w)
 	{
 	  propagate_bits (w);
-	  w_info = w->aux;
+	  w_info = (struct ipa_dfs_info *) w->aux;
 	  w = w_info->next_cycle;
 	}
     }
@@ -1182,12 +1182,12 @@ static_execute (void)
       node = order[i];
       merge_callee_local_info (node, node);
       
-      w_info = node->aux;
+      w_info = (struct ipa_dfs_info *) node->aux;
       w = w_info->next_cycle;
       while (w)
 	{
 	  merge_callee_local_info (w, w);
-	  w_info = w->aux;
+	  w_info = (struct ipa_dfs_info *) w->aux;
 	  w = w_info->next_cycle;
 	}
     }
@@ -1225,7 +1225,7 @@ static_execute (void)
 		      get_static_name (index));
 	    }
 
-	  w_info = node->aux;
+	  w_info = (struct ipa_dfs_info *) node->aux;
 	  w = w_info->next_cycle;
 	  while (w) 
 	    {
@@ -1251,7 +1251,7 @@ static_execute (void)
 		}
 	      
 
-	      w_info = w->aux;
+	      w_info = (struct ipa_dfs_info *) w->aux;
 	      w = w_info->next_cycle;
 	    }
 	  fprintf (dump_file, "\n  globals read: ");
Index: gcc/ipa-type-escape.c
===================================================================
--- gcc/ipa-type-escape.c	(revision 125521)
+++ gcc/ipa-type-escape.c	(working copy)
@@ -1499,7 +1499,7 @@ okay_pointer_operation (enum tree_code c
 static tree
 scan_for_refs (tree *tp, int *walk_subtrees, void *data)
 {
-  struct cgraph_node *fn = data;
+  struct cgraph_node *fn = (struct cgraph_node *) data;
   tree t = *tp;
 
   switch (TREE_CODE (t))  
Index: gcc/ipa-utils.c
===================================================================
--- gcc/ipa-utils.c	(revision 125521)
+++ gcc/ipa-utils.c	(working copy)
@@ -86,10 +86,10 @@ static void
 searchc (struct searchc_env* env, struct cgraph_node *v) 
 {
   struct cgraph_edge *edge;
-  struct ipa_dfs_info *v_info = v->aux;
+  struct ipa_dfs_info *v_info = (struct ipa_dfs_info *) v->aux;
   
   /* mark node as old */
-  v_info->new = false;
+  v_info->new_node = false;
   splay_tree_remove (env->nodes_marked_new, v->uid);
   
   v_info->dfn_number = env->count;
@@ -107,8 +107,8 @@ searchc (struct searchc_env* env, struct
       w = cgraph_master_clone (w);
       if (w && w->aux) 
 	{
-	  w_info = w->aux;
-	  if (w_info->new) 
+	  w_info = (struct ipa_dfs_info *) w->aux;
+	  if (w_info->new_node) 
 	    {
 	      searchc (env, w);
 	      v_info->low_link =
@@ -132,7 +132,7 @@ searchc (struct searchc_env* env, struct
       struct ipa_dfs_info *x_info;
       do {
 	x = env->stack[--(env->stack_size)];
-	x_info = x->aux;
+	x_info = (struct ipa_dfs_info *) x->aux;
 	x_info->on_stack = false;
 	
 	if (env->reduce) 
@@ -177,10 +177,10 @@ ipa_utils_reduced_inorder (struct cgraph
 		 AVAIL_OVERWRITABLE))))
       {
 	/* Reuse the info if it is already there.  */
-	struct ipa_dfs_info *info = node->aux;
+	struct ipa_dfs_info *info = (struct ipa_dfs_info *) node->aux;
 	if (!info)
-	  info = xcalloc (1, sizeof (struct ipa_dfs_info));
-	info->new = true;
+	  info = XCNEW (struct ipa_dfs_info);
+	info->new_node = true;
 	info->on_stack = false;
 	info->next_cycle = NULL;
 	node->aux = info;
Index: gcc/ipa-utils.h
===================================================================
--- gcc/ipa-utils.h	(revision 125521)
+++ gcc/ipa-utils.h	(working copy)
@@ -30,7 +30,7 @@ extern tree memory_identifier_string;
 struct ipa_dfs_info {
   int dfn_number;
   int low_link;
-  bool new;
+  bool new_node;
   bool on_stack;
   struct cgraph_node* next_cycle;
   PTR aux;

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