diff mbox

Symbol table 13/many: reachability code rewrite

Message ID 20120425113818.GI26622@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka April 25, 2012, 11:38 a.m. UTC
> This caused:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53088
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53089

The first one seems just moved warning because of different gimplification order.
Fixed thus.  Note that the warning comes out at weird place with input_location,
but that problem existed here before the patch.

I've comitted the following.

I am looking into the fortran coarays now.  It seems that coarray registration
is somehow broken, but I am not even sure how it is supposed to work.

Honza

Comments

Jan Hubicka April 25, 2012, 3:04 p.m. UTC | #1
Hi,
the fortran problem is caused by fact that fortran does nested funtions that
are static constructors.  I did not really think of that case in cgraph
construction code.  Fixed thus.

Honza
	PR middle-end/53089 
	* cgraphunit.c (cgraph_process_new_functions): Do not enqueue new functions here.
	(referred_to_p): Move ahead in file to avoid forward declaration.
	(cgraph_finalize_function): Finalize them here.
	* symtab.c (dump_symtab): Dump ctors and dtors.

Index: cgraphunit.c
===================================================================
*** cgraphunit.c	(revision 186770)
--- cgraphunit.c	(working copy)
*************** cgraph_process_new_functions (void)
*** 243,249 ****
  	  cgraph_finalize_function (fndecl, false);
  	  output = true;
            cgraph_call_function_insertion_hooks (node);
- 	  enqueue_node ((symtab_node) node);
  	  break;
  
  	case CGRAPH_STATE_IPA:
--- 243,248 ----
*************** cgraph_reset_node (struct cgraph_node *n
*** 320,325 ****
--- 319,340 ----
    cgraph_node_remove_callees (node);
  }
  
+ /* Return true when there are references to NODE.  */
+ 
+ static bool
+ referred_to_p (symtab_node node)
+ {
+   int i;
+   struct ipa_ref *ref;
+ 
+   for (i = 0; ipa_ref_list_referring_iterate (&node->symbol.ref_list, i, ref);
+        i++)
+     return true;
+   if (symtab_function_p (node) && cgraph (node)->callers)
+     return true;
+   return false;
+ }
+ 
  /* DECL has been parsed.  Take it, queue it, compile it at the whim of the
     logic in effect.  If NESTED is true, then our caller cannot stand to have
     the garbage collector run at the moment.  We would need to either create
*************** cgraph_finalize_function (tree decl, boo
*** 372,377 ****
--- 387,397 ----
  
    if (!nested)
      ggc_collect ();
+ 
+   if (cgraph_state == CGRAPH_STATE_CONSTRUCTION
+       && (cgraph_decide_is_function_needed (node, decl)
+ 	  || referred_to_p ((symtab_node)node)))
+     enqueue_node ((symtab_node)node);
  }
  
  /* Add the function FNDECL to the call graph.
*************** process_function_and_variable_attributes
*** 1114,1135 ****
      }
  }
  
- /* Return true when there are references to NODE.  */
- 
- static bool
- referred_to_p (symtab_node node)
- {
-   int i;
-   struct ipa_ref *ref;
- 
-   for (i = 0; ipa_ref_list_referring_iterate (&node->symbol.ref_list, i, ref);
-        i++)
-     return true;
-   if (symtab_function_p (node) && cgraph (node)->callers)
-     return true;
-   return false;
- }
- 
  /* Mark DECL as finalized.  By finalizing the declaration, frontend instruct the
     middle end to output the variable to asm file, if needed or externally
     visible.  */
--- 1134,1139 ----
Index: symtab.c
===================================================================
*** symtab.c	(revision 186770)
--- symtab.c	(working copy)
*************** dump_symtab_base (FILE *f, symtab_node n
*** 414,419 ****
--- 414,426 ----
      fprintf (f, " virtual");
    if (DECL_ARTIFICIAL (node->symbol.decl))
      fprintf (f, " artificial");
+   if (TREE_CODE (node->symbol.decl) == FUNCTION_DECL)
+     {
+       if (DECL_STATIC_CONSTRUCTOR (node->symbol.decl))
+ 	fprintf (f, " constructor");
+       if (DECL_STATIC_DESTRUCTOR (node->symbol.decl))
+ 	fprintf (f, " destructor");
+     }
    fprintf (f, "\n");
    
    if (node->symbol.same_comdat_group)
Steven Bosscher April 25, 2012, 5:09 p.m. UTC | #2
On Wed, Apr 25, 2012 at 5:04 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> + /* Return true when there are references to NODE.  */
> +
> + static bool
> + referred_to_p (symtab_node node)
> + {
> +   int i;
> +   struct ipa_ref *ref;
> +
> +   for (i = 0; ipa_ref_list_referring_iterate (&node->symbol.ref_list, i, ref);
> +        i++)
> +     return true;

This looks odd. Don't you want to do something with ref?

> +   if (symtab_function_p (node) && cgraph (node)->callers)
> +     return true;
> +   return false;
> + }

Ciao!
Steven
Jan Hubicka April 25, 2012, 5:23 p.m. UTC | #3
> On Wed, Apr 25, 2012 at 5:04 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > + /* Return true when there are references to NODE.  */
> > +
> > + static bool
> > + referred_to_p (symtab_node node)
> > + {
> > +   int i;
> > +   struct ipa_ref *ref;
> > +
> > +   for (i = 0; ipa_ref_list_referring_iterate (&node->symbol.ref_list, i, ref);
> > +        i++)
> > +     return true;
> 
> This looks odd. Don't you want to do something with ref?
No, I have just iteration API, not API to check how many refs are there
and I want to see if there are any...

Honza
Jan Hubicka April 25, 2012, 6:46 p.m. UTC | #4
> > On Wed, Apr 25, 2012 at 5:04 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > > + /* Return true when there are references to NODE.  */
> > > +
> > > + static bool
> > > + referred_to_p (symtab_node node)
> > > + {
> > > +   int i;
> > > +   struct ipa_ref *ref;
> > > +
> > > +   for (i = 0; ipa_ref_list_referring_iterate (&node->symbol.ref_list, i, ref);
> > > +        i++)
> > > +     return true;
> > 
> > This looks odd. Don't you want to do something with ref?
> No, I have just iteration API, not API to check how many refs are there
> and I want to see if there are any...
Actually it is bit too much of cut&paste. Just
 if (ipa_ref_list_referring_iterate (&node->symbol.ref_list, 0, ref))
would work too.  i will update it ;)

Honza

> 
> Honza
Richard Henderson April 25, 2012, 6:58 p.m. UTC | #5
On 04/25/12 11:46, Jan Hubicka wrote:
>>> On Wed, Apr 25, 2012 at 5:04 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>>>> + /* Return true when there are references to NODE.  */
>>>> +
>>>> + static bool
>>>> + referred_to_p (symtab_node node)
>>>> + {
>>>> +   int i;
>>>> +   struct ipa_ref *ref;
>>>> +
>>>> +   for (i = 0; ipa_ref_list_referring_iterate (&node->symbol.ref_list, i, ref);
>>>> +        i++)
>>>> +     return true;
>>>
>>> This looks odd. Don't you want to do something with ref?
>> No, I have just iteration API, not API to check how many refs are there
>> and I want to see if there are any...
> Actually it is bit too much of cut&paste. Just
>  if (ipa_ref_list_referring_iterate (&node->symbol.ref_list, 0, ref))
> would work too.  i will update it ;)

And with a comment too, please.


r~
diff mbox

Patch

Index: gcc.target/i386/pr39082-1.c
===================================================================
--- gcc.target/i386/pr39082-1.c	(revision 186814)
+++ gcc.target/i386/pr39082-1.c	(working copy)
@@ -13,7 +13,7 @@  extern int bar1 (union un);
 extern union un bar2 (int);
 
 int
-foo1 (union un u)
+foo1 (union un u) /* { dg-message "note: the ABI of passing union with long double has changed in GCC 4.4" } */
 {
   bar1 (u);
   return u.i;
@@ -30,6 +30,6 @@  foo2 (void)
 int
 foo3 (int x)
 {
-  union un u = bar2 (x); /* { dg-message "note: the ABI of passing union with long double has changed in GCC 4.4" } */
+  union un u = bar2 (x);
   return u.i;
 }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 186814)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@ 
+2012-04-25  Jan Hubicka  <jh@suse.cz>
+
+	PR middle-end/53088
+	* gcc.target/i386/pr39082-1.c: Update warning location.
+
 2012-04-25  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c/52880