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] Move tree_rest_of_compilation


To cgraphunit.c, where its only caller (should) reside.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2012-04-10  Richard Guenther  <rguenther@suse.de>

	* toplev.h (tree_rest_of_compilation): Remove.
	* tree-optimize.c (tree_rest_of_compilation): Likewise.
	* cgraph.h (tree_rest_of_compilation): Declare.
	* tree-optimize.c (tree_rest_of_compilation): Move ...
	* cgraphunit.c (tree_rest_of_compilation): ... here.
	* cgraph.c (cgraph_add_new_function): Adjust.
	* Makefile.in (tree-optimize.o): Adjust.
	(cgraphunit.o): Likewise.

Index: trunk/gcc/cgraph.h
===================================================================
*** trunk.orig/gcc/cgraph.h	2012-04-10 10:19:22.000000000 +0200
--- trunk/gcc/cgraph.h	2012-04-10 10:20:45.216721264 +0200
*************** void cgraph_mark_if_needed (tree);
*** 565,570 ****
--- 565,571 ----
  void cgraph_analyze_function (struct cgraph_node *);
  void cgraph_finalize_compilation_unit (void);
  void cgraph_optimize (void);
+ void tree_rest_of_compilation (struct cgraph_node *);
  void cgraph_mark_needed_node (struct cgraph_node *);
  void cgraph_mark_address_taken_node (struct cgraph_node *);
  void cgraph_mark_reachable_node (struct cgraph_node *);
Index: trunk/gcc/cgraphunit.c
===================================================================
*** trunk.orig/gcc/cgraphunit.c	2012-04-10 10:20:00.000000000 +0200
--- trunk/gcc/cgraphunit.c	2012-04-10 10:57:26.947589800 +0200
*************** along with GCC; see the file COPYING3.
*** 111,116 ****
--- 111,117 ----
  #include "coretypes.h"
  #include "tm.h"
  #include "tree.h"
+ #include "output.h"
  #include "rtl.h"
  #include "tree-flow.h"
  #include "tree-inline.h"
*************** along with GCC; see the file COPYING3.
*** 141,146 ****
--- 142,148 ----
  #include "ipa-inline.h"
  #include "ipa-utils.h"
  #include "lto-streamer.h"
+ #include "regset.h"     /* FIXME: For reg_obstack.  */
  
  static void cgraph_expand_all_functions (void);
  static void cgraph_mark_functions_to_output (void);
*************** assemble_thunks_and_aliases (struct cgra
*** 1768,1773 ****
--- 1770,1863 ----
        }
  }
  
+ /* For functions-as-trees languages, this performs all optimization and
+    compilation for FNDECL.  */
+ 
+ void
+ tree_rest_of_compilation (struct cgraph_node *node)
+ {
+   tree fndecl = node->decl;
+   location_t saved_loc;
+ 
+   timevar_push (TV_REST_OF_COMPILATION);
+ 
+   gcc_assert (cgraph_global_info_ready);
+ 
+   /* Initialize the default bitmap obstack.  */
+   bitmap_obstack_initialize (NULL);
+ 
+   /* Initialize the RTL code for the function.  */
+   current_function_decl = fndecl;
+   saved_loc = input_location;
+   input_location = DECL_SOURCE_LOCATION (fndecl);
+   init_function_start (fndecl);
+ 
+   gimple_register_cfg_hooks ();
+ 
+   bitmap_obstack_initialize (&reg_obstack); /* FIXME, only at RTL generation*/
+ 
+   execute_all_ipa_transforms ();
+ 
+   /* Perform all tree transforms and optimizations.  */
+ 
+   /* Signal the start of passes.  */
+   invoke_plugin_callbacks (PLUGIN_ALL_PASSES_START, NULL);
+ 
+   execute_pass_list (all_passes);
+ 
+   /* Signal the end of passes.  */
+   invoke_plugin_callbacks (PLUGIN_ALL_PASSES_END, NULL);
+ 
+   bitmap_obstack_release (&reg_obstack);
+ 
+   /* Release the default bitmap obstack.  */
+   bitmap_obstack_release (NULL);
+ 
+   set_cfun (NULL);
+ 
+   /* If requested, warn about function definitions where the function will
+      return a value (usually of some struct or union type) which itself will
+      take up a lot of stack space.  */
+   if (warn_larger_than && !DECL_EXTERNAL (fndecl) && TREE_TYPE (fndecl))
+     {
+       tree ret_type = TREE_TYPE (TREE_TYPE (fndecl));
+ 
+       if (ret_type && TYPE_SIZE_UNIT (ret_type)
+ 	  && TREE_CODE (TYPE_SIZE_UNIT (ret_type)) == INTEGER_CST
+ 	  && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type),
+ 				   larger_than_size))
+ 	{
+ 	  unsigned int size_as_int
+ 	    = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type));
+ 
+ 	  if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0)
+ 	    warning (OPT_Wlarger_than_, "size of return value of %q+D is %u bytes",
+                      fndecl, size_as_int);
+ 	  else
+ 	    warning (OPT_Wlarger_than_, "size of return value of %q+D is larger than %wd bytes",
+                      fndecl, larger_than_size);
+ 	}
+     }
+ 
+   gimple_set_body (fndecl, NULL);
+   if (DECL_STRUCT_FUNCTION (fndecl) == 0
+       && !cgraph_get_node (fndecl)->origin)
+     {
+       /* Stop pointing to the local nodes about to be freed.
+ 	 But DECL_INITIAL must remain nonzero so we know this
+ 	 was an actual function definition.
+ 	 For a nested function, this is done in c_pop_function_context.
+ 	 If rest_of_compilation set this to 0, leave it 0.  */
+       if (DECL_INITIAL (fndecl) != 0)
+ 	DECL_INITIAL (fndecl) = error_mark_node;
+     }
+ 
+   input_location = saved_loc;
+ 
+   ggc_collect ();
+   timevar_pop (TV_REST_OF_COMPILATION);
+ }
+ 
  /* Expand function specified by NODE.  */
  
  static void
*************** cgraph_expand_function (struct cgraph_no
*** 1783,1789 ****
    gcc_assert (node->lowered);
  
    /* Generate RTL for the body of DECL.  */
!   tree_rest_of_compilation (decl);
  
    /* Make sure that BE didn't give up on compiling.  */
    gcc_assert (TREE_ASM_WRITTEN (decl));
--- 1873,1879 ----
    gcc_assert (node->lowered);
  
    /* Generate RTL for the body of DECL.  */
!   tree_rest_of_compilation (node);
  
    /* Make sure that BE didn't give up on compiling.  */
    gcc_assert (TREE_ASM_WRITTEN (decl));
Index: trunk/gcc/toplev.h
===================================================================
*** trunk.orig/gcc/toplev.h	2012-04-10 10:19:22.000000000 +0200
--- trunk/gcc/toplev.h	2012-04-10 10:20:45.217721264 +0200
*************** extern unsigned int save_decoded_options
*** 29,35 ****
  extern int toplev_main (int, char **);
  extern void rest_of_decl_compilation (tree, int, int);
  extern void rest_of_type_compilation (tree, int);
- extern void tree_rest_of_compilation (tree);
  extern void init_optimization_passes (void);
  extern void finish_optimization_passes (void);
  extern bool enable_rtl_dump_file (void);
--- 29,34 ----
Index: trunk/gcc/tree-optimize.c
===================================================================
*** trunk.orig/gcc/tree-optimize.c	2012-04-10 10:20:00.000000000 +0200
--- trunk/gcc/tree-optimize.c	2012-04-10 10:20:45.217721264 +0200
*************** along with GCC; see the file COPYING3.
*** 45,51 ****
  #include "cfgloop.h"
  #include "except.h"
  #include "plugin.h"
- #include "regset.h"	/* FIXME: For reg_obstack.  */
  
  /* Gate: execute, or not, all of the non-trivial optimizations.  */
  
--- 45,50 ----
*************** struct gimple_opt_pass pass_init_datastr
*** 366,455 ****
    0					/* todo_flags_finish */
   }
  };
- 
- /* For functions-as-trees languages, this performs all optimization and
-    compilation for FNDECL.  */
- 
- void
- tree_rest_of_compilation (tree fndecl)
- {
-   location_t saved_loc;
- 
-   timevar_push (TV_REST_OF_COMPILATION);
- 
-   gcc_assert (cgraph_global_info_ready);
- 
-   /* Initialize the default bitmap obstack.  */
-   bitmap_obstack_initialize (NULL);
- 
-   /* Initialize the RTL code for the function.  */
-   current_function_decl = fndecl;
-   saved_loc = input_location;
-   input_location = DECL_SOURCE_LOCATION (fndecl);
-   init_function_start (fndecl);
- 
-   gimple_register_cfg_hooks ();
- 
-   bitmap_obstack_initialize (&reg_obstack); /* FIXME, only at RTL generation*/
- 
-   execute_all_ipa_transforms ();
- 
-   /* Perform all tree transforms and optimizations.  */
- 
-   /* Signal the start of passes.  */
-   invoke_plugin_callbacks (PLUGIN_ALL_PASSES_START, NULL);
- 
-   execute_pass_list (all_passes);
- 
-   /* Signal the end of passes.  */
-   invoke_plugin_callbacks (PLUGIN_ALL_PASSES_END, NULL);
- 
-   bitmap_obstack_release (&reg_obstack);
- 
-   /* Release the default bitmap obstack.  */
-   bitmap_obstack_release (NULL);
- 
-   set_cfun (NULL);
- 
-   /* If requested, warn about function definitions where the function will
-      return a value (usually of some struct or union type) which itself will
-      take up a lot of stack space.  */
-   if (warn_larger_than && !DECL_EXTERNAL (fndecl) && TREE_TYPE (fndecl))
-     {
-       tree ret_type = TREE_TYPE (TREE_TYPE (fndecl));
- 
-       if (ret_type && TYPE_SIZE_UNIT (ret_type)
- 	  && TREE_CODE (TYPE_SIZE_UNIT (ret_type)) == INTEGER_CST
- 	  && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type),
- 				   larger_than_size))
- 	{
- 	  unsigned int size_as_int
- 	    = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type));
- 
- 	  if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0)
- 	    warning (OPT_Wlarger_than_, "size of return value of %q+D is %u bytes",
-                      fndecl, size_as_int);
- 	  else
- 	    warning (OPT_Wlarger_than_, "size of return value of %q+D is larger than %wd bytes",
-                      fndecl, larger_than_size);
- 	}
-     }
- 
-   gimple_set_body (fndecl, NULL);
-   if (DECL_STRUCT_FUNCTION (fndecl) == 0
-       && !cgraph_get_node (fndecl)->origin)
-     {
-       /* Stop pointing to the local nodes about to be freed.
- 	 But DECL_INITIAL must remain nonzero so we know this
- 	 was an actual function definition.
- 	 For a nested function, this is done in c_pop_function_context.
- 	 If rest_of_compilation set this to 0, leave it 0.  */
-       if (DECL_INITIAL (fndecl) != 0)
- 	DECL_INITIAL (fndecl) = error_mark_node;
-     }
- 
-   input_location = saved_loc;
- 
-   ggc_collect ();
-   timevar_pop (TV_REST_OF_COMPILATION);
- }
--- 365,367 ----
Index: trunk/gcc/cgraph.c
===================================================================
*** trunk.orig/gcc/cgraph.c	2012-04-10 10:20:00.000000000 +0200
--- trunk/gcc/cgraph.c	2012-04-10 10:20:55.149720671 +0200
*************** cgraph_add_new_function (tree fndecl, bo
*** 2466,2472 ****
  	if (!gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
  	  execute_pass_list (pass_early_local_passes.pass.sub);
  	bitmap_obstack_release (NULL);
! 	tree_rest_of_compilation (fndecl);
  	pop_cfun ();
  	current_function_decl = NULL;
  	break;
--- 2466,2472 ----
  	if (!gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
  	  execute_pass_list (pass_early_local_passes.pass.sub);
  	bitmap_obstack_release (NULL);
! 	tree_rest_of_compilation (node);
  	pop_cfun ();
  	current_function_decl = NULL;
  	break;
Index: trunk/gcc/Makefile.in
===================================================================
*** trunk.orig/gcc/Makefile.in	2012-04-04 12:45:13.000000000 +0200
--- trunk/gcc/Makefile.in	2012-04-10 13:51:58.615964512 +0200
*************** tree-optimize.o : tree-optimize.c $(TREE
*** 2556,2562 ****
     coretypes.h $(TREE_DUMP_H) toplev.h $(DIAGNOSTIC_CORE_H) $(FUNCTION_H) langhooks.h \
     $(FLAGS_H) $(CGRAPH_H) $(PLUGIN_H) \
     $(TREE_INLINE_H) $(GGC_H) graph.h $(CGRAPH_H) \
!    $(TREE_PASS_H) $(CFGLOOP_H) $(EXCEPT_H) $(REGSET_H)
  
  gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(GIMPLE_H) \
     $(DIAGNOSTIC_H) $(GIMPLE_H) $(TREE_INLINE_H) langhooks.h \
--- 2556,2562 ----
     coretypes.h $(TREE_DUMP_H) toplev.h $(DIAGNOSTIC_CORE_H) $(FUNCTION_H) langhooks.h \
     $(FLAGS_H) $(CGRAPH_H) $(PLUGIN_H) \
     $(TREE_INLINE_H) $(GGC_H) graph.h $(CGRAPH_H) \
!    $(TREE_PASS_H) $(CFGLOOP_H) $(EXCEPT_H)
  
  gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(GIMPLE_H) \
     $(DIAGNOSTIC_H) $(GIMPLE_H) $(TREE_INLINE_H) langhooks.h \
*************** cgraphunit.o : cgraphunit.c $(CONFIG_H)
*** 2922,2928 ****
     $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(TIMEVAR_H) $(IPA_PROP_H) \
     gt-cgraphunit.h tree-iterator.h $(COVERAGE_H) $(TREE_DUMP_H) \
     tree-pretty-print.h gimple-pretty-print.h ipa-inline.h $(IPA_UTILS_H) \
!    $(LTO_STREAMER_H)
  cgraphbuild.o : cgraphbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(CGRAPH_H) intl.h pointer-set.h $(GIMPLE_H) \
     $(TREE_FLOW_H) $(TREE_PASS_H) $(IPA_UTILS_H) $(EXCEPT_H) \
--- 2922,2928 ----
     $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(TIMEVAR_H) $(IPA_PROP_H) \
     gt-cgraphunit.h tree-iterator.h $(COVERAGE_H) $(TREE_DUMP_H) \
     tree-pretty-print.h gimple-pretty-print.h ipa-inline.h $(IPA_UTILS_H) \
!    $(LTO_STREAMER_H) output.h $(REGSET_H)
  cgraphbuild.o : cgraphbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) langhooks.h $(CGRAPH_H) intl.h pointer-set.h $(GIMPLE_H) \
     $(TREE_FLOW_H) $(TREE_PASS_H) $(IPA_UTILS_H) $(EXCEPT_H) \


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