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]

Re: [PATCH] Allow passmanager to switch between IPA and local passes


> On Sun, Jun 05, 2005 at 12:21:08PM +0200, Jan Hubicka wrote:
> > ! 	  if (cfun)
> > ! 	    execute_pass_list (pass->sub);
> > ! 	  else
> > ! 	    {
> > ! 	      struct cgraph_node *node;
> > ! 	      tree_register_cfg_hooks ();
> > ! 	      for (node = cgraph_nodes; node; node = node->next)
> > ! 		if (node->analyzed)
> > ! 		  {
> > ! 		    push_cfun (DECL_STRUCT_FUNCTION (node->decl));
> > ! 		    current_function_decl = node->decl;
> > ! 		    execute_pass_list (pass->sub);
> > ! 		    free_dominance_info (CDI_DOMINATORS);
> > ! 		    free_dominance_info (CDI_POST_DOMINATORS);
> > ! 		    current_function_decl = NULL;
> > ! 		    pop_cfun ();
> > ! 		    ggc_collect ();
> 
> I think this just uglifies this function.  I think you should simply
> change...
> 
> >     execute_pass_list (all_ipa_passes);
> 
> ... this to be a different function.

Does this look acceptable?
Bootstrapping/regtesting i686-pc-gnu-linux...

2005-06-17  Jan Hubicka  <jh@suse.cz>
	* tree-optimize.c (execute_local_passes): New function.
	(execute_pass_list): Use it.
	(ipa_passes): Zero out cfun.

Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.107
diff -c -3 -p -r2.107 tree-optimize.c
*** tree-optimize.c	9 Jun 2005 13:05:36 -0000	2.107
--- tree-optimize.c	17 Jun 2005 08:59:04 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 50,55 ****
--- 50,56 ----
  #include "cfgloop.h"
  #include "except.h"
  
+ static void execute_local_passes (struct tree_opt_pass *pass);
  
  /* Global variables used to communicate with passes.  */
  int dump_flags;
*************** execute_pass_list (struct tree_opt_pass 
*** 665,676 ****
    do
      {
        if (execute_one_pass (pass) && pass->sub)
! 	execute_pass_list (pass->sub);
        pass = pass->next;
      }
    while (pass);
  }
  
  void
  tree_lowering_passes (tree fn)
  {
--- 666,704 ----
    do
      {
        if (execute_one_pass (pass) && pass->sub)
! 	{
! 	  if (cfun)
! 	    execute_pass_list (pass->sub);
! 	  else
! 	    execute_local_passes (pass->sub);
! 	}
        pass = pass->next;
      }
    while (pass);
  }
  
+ /* Outer pass is an IPA pass called once per program, while
+    the subpasses are assumed to be local passes caled once for each
+    function.  */
+ static void
+ execute_local_passes (struct tree_opt_pass *pass)
+ {
+   struct cgraph_node *node;
+   tree_register_cfg_hooks ();
+   for (node = cgraph_nodes; node; node = node->next)
+     if (node->analyzed)
+       {
+ 	push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+ 	current_function_decl = node->decl;
+ 	execute_pass_list (pass);
+ 	free_dominance_info (CDI_DOMINATORS);
+ 	free_dominance_info (CDI_POST_DOMINATORS);
+ 	current_function_decl = NULL;
+ 	pop_cfun ();
+ 	ggc_collect ();
+       }
+ }
+ 
  void
  tree_lowering_passes (tree fn)
  {
*************** tree_lowering_passes (tree fn)
*** 692,697 ****
--- 720,726 ----
  void
  ipa_passes (void)
  {
+   cfun = NULL;
    bitmap_obstack_initialize (NULL);
    execute_pass_list (all_ipa_passes);
    bitmap_obstack_release (NULL);


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