Patchwork Fix ipa_reduced_postorder with respect to overwritable functions

login
register
mail settings
Submitter Martin Jambor
Date May 30, 2011, 6:08 p.m.
Message ID <20110530180816.GA8867@virgil.arch.suse.de>
Download mbox | patch
Permalink /patch/97944/
State New
Headers show

Comments

Martin Jambor - May 30, 2011, 6:08 p.m.
Hi,

I ran into issues caused by ipa_reduced_postorder not really
topologically sorting functions while compiling some part of the java
library (yes, this is the first time java has caught a bug for me).
The problem was that all the functions are apparently
AVAIL_OVERWRITABLE and even though I have instructed
ipa_reduced_postorder by its allow_overwritable parameter to include
such functions, it still blatantly ignores edges to such functions
which leads to all sorts of unexpectedly broken assumptions and weird
bugs.

Fixed thusly, bootstrapped and tested on x86_64-linux (and verified
that my problems caused by this went away too).

OK for trunk?

Thanks,

Martin


2011-05-30  Martin Jambor  <mjambor@suse.cz>

	* ipa-utils.c (searchc_env): New field allow_overwritable.
	(searchc): do not ignore edges to overwritable nodes if indicated
	by env->allow_overwritable.
	(ipa_reduced_postorder): Set env.allow_overwritable.
Jan Hubicka - May 31, 2011, 8:35 a.m.
> Hi,
> 
> I ran into issues caused by ipa_reduced_postorder not really
> topologically sorting functions while compiling some part of the java
> library (yes, this is the first time java has caught a bug for me).
> The problem was that all the functions are apparently
> AVAIL_OVERWRITABLE and even though I have instructed
> ipa_reduced_postorder by its allow_overwritable parameter to include
> such functions, it still blatantly ignores edges to such functions
> which leads to all sorts of unexpectedly broken assumptions and weird
> bugs.
> 
> Fixed thusly, bootstrapped and tested on x86_64-linux (and verified
> that my problems caused by this went away too).
> 
> OK for trunk?
OK,
Honza

Patch

Index: src/gcc/ipa-utils.c
===================================================================
--- src.orig/gcc/ipa-utils.c
+++ src/gcc/ipa-utils.c
@@ -67,6 +67,7 @@  struct searchc_env {
   int order_pos;
   splay_tree nodes_marked_new;
   bool reduce;
+  bool allow_overwritable;
   int count;
 };
 
@@ -101,11 +102,14 @@  searchc (struct searchc_env* env, struct
     {
       struct ipa_dfs_info * w_info;
       struct cgraph_node *w = edge->callee;
+      enum availability avail = cgraph_function_body_availability (w);
 
       if (ignore_edge && ignore_edge (edge))
         continue;
 
-      if (w->aux && cgraph_function_body_availability (edge->callee) > AVAIL_OVERWRITABLE)
+      if (w->aux
+	  && (avail > AVAIL_OVERWRITABLE
+	      || (env->allow_overwritable && avail == AVAIL_OVERWRITABLE)))
 	{
 	  w_info = (struct ipa_dfs_info *) w->aux;
 	  if (w_info->new_node)
@@ -171,6 +175,7 @@  ipa_reduced_postorder (struct cgraph_nod
   env.nodes_marked_new = splay_tree_new (splay_tree_compare_ints, 0, 0);
   env.count = 1;
   env.reduce = reduce;
+  env.allow_overwritable = allow_overwritable;
 
   for (node = cgraph_nodes; node; node = node->next)
     {