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]

Remove expand_body langhook


Hi,
this patch removes expand_body langhooks and adds emit_associated_thunks as
discussed earlier.  I tried to keep the patch on minimum, so I didn't include
cleanups to cgraph and passmanager the change enables.

There are 3 nontrivial changes in the patch - c-decl and thunk emiting code
is brought to use cgraph_add_new_function instead of calling to backend directly
and fortran no longer calls debug output for local statics; this is done by cgraph
already for some time so it is redundant.

Bootstrapped/regtested i686-linux, ppc-linux in progress, OK?

Honza

	* decl.c (java_expand_body): Kill.
	(LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION): Kill.

	* toplev.c (process_options): All frontends now do unit-at-a-time.
	* cgraphunit.c: Update comments.
	(cgraph_expand_function): Call passmanager dirrectly; emit thunks.
	* c-decl.c (finish_function): Use cgraph_add_new_function.

	* Make-lng.in: Add dependency on cgrpah for cp/medhot.o
	* method.c: Include cgraph.h
	(use_thunk): Use cgraph_add_new_function.
	* cp-objecp-common.h (LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION): Kill.
	(LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS): Define.
	* cp-tree.h (expand_body): Kill.
	(emit_associated_thunks): Declare.
	* semantics.c (emit_associated_thunks): Export.
	(expand_body): Kill.

	* misc.c (gnat_expand_body): Kill.
	(LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION): Kill.

	* f95-lang.c (gfc_expand_function): Kill.
	(LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION): Kill.

	* function.c (expand_function_end): We are always unit-at-a-time.
Index: java/decl.c
===================================================================
*** java/decl.c	(revision 128277)
--- java/decl.c	(working copy)
*************** finish_method (tree fndecl)
*** 1862,1875 ****
    cgraph_finalize_function (fndecl, false);
  }
  
- /* Optimize and expand a function's entire body.  */
- 
- void
- java_expand_body (tree fndecl)
- {
-   tree_rest_of_compilation (fndecl);
- }
- 
  /* We pessimistically marked all methods and fields external until we
     knew what set of classes we were planning to compile.  Now mark those
     associated with CLASS to be generated locally as not external.  */
--- 1862,1867 ----
Index: java/lang.c
===================================================================
*** java/lang.c	(revision 128277)
--- java/lang.c	(working copy)
*************** struct language_function GTY(())
*** 192,200 ****
  #undef LANG_HOOKS_GET_CALLEE_FNDECL
  #define LANG_HOOKS_GET_CALLEE_FNDECL java_get_callee_fndecl
  
- #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
- #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION java_expand_body
- 
  #undef LANG_HOOKS_CLEAR_BINDING_STACK
  #define LANG_HOOKS_CLEAR_BINDING_STACK java_clear_binding_stack
  
--- 192,197 ----
Index: toplev.c
===================================================================
*** toplev.c	(revision 128277)
--- toplev.c	(working copy)
*************** process_options (void)
*** 1785,1795 ****
    if (flag_asynchronous_unwind_tables)
      flag_unwind_tables = 1;
  
-   /* Disable unit-at-a-time mode for frontends not supporting callgraph
-      interface.  */
-   if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
-     flag_unit_at_a_time = 0;
- 
    if (!flag_unit_at_a_time)
      flag_section_anchors = 0;
  
--- 1785,1790 ----
Index: cgraphunit.c
===================================================================
*** cgraphunit.c	(revision 128277)
--- cgraphunit.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 76,90 ****
        ??? On the tree-ssa genericizing should take place here and we will avoid
        need for these hooks (replacing them by genericizing hook)
  
-     - expand_function callback
- 
-       This function is used to expand function and pass it into RTL back-end.
-       Front-end should not make any assumptions about when this function can be
-       called.  In particular cgraph_assemble_pending_functions,
-       varpool_assemble_pending_variables, cgraph_finalize_function,
-       varpool_finalize_function, cgraph_optimize can cause arbitrarily
-       previously finalized functions to be expanded.
- 
      We implement two compilation modes.
  
        - unit-at-a-time:  In this mode analyzing of all functions is deferred
--- 76,81 ----
*************** cgraph_expand_function (struct cgraph_no
*** 1074,1080 ****
      }
  
    /* Generate RTL for the body of DECL.  */
!   lang_hooks.callgraph.expand_function (decl);
  
    /* Make sure that BE didn't give up on compiling.  */
    /* ??? Can happen with nested function of extern inline.  */
--- 1065,1073 ----
      }
  
    /* Generate RTL for the body of DECL.  */
!   if (lang_hooks.callgraph.emit_associated_thunks)
!     lang_hooks.callgraph.emit_associated_thunks (decl);
!   tree_rest_of_compilation (decl);
  
    /* Make sure that BE didn't give up on compiling.  */
    /* ??? Can happen with nested function of extern inline.  */
Index: cp/Make-lang.in
===================================================================
*** cp/Make-lang.in	(revision 128277)
--- cp/Make-lang.in	(working copy)
*************** cp/friend.o: cp/friend.c $(CXX_TREE_H) $
*** 255,261 ****
  cp/init.o: cp/init.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) $(RTL_H) $(EXPR_H) \
    toplev.h except.h $(TARGET_H)
  cp/method.o: cp/method.c $(CXX_TREE_H) $(TM_H) toplev.h $(RTL_H) $(EXPR_H) \
!   $(TM_P_H) $(TARGET_H) $(DIAGNOSTIC_H) gt-cp-method.h
  cp/cvt.o: cp/cvt.c $(CXX_TREE_H) $(TM_H) cp/decl.h $(FLAGS_H) toplev.h \
    convert.h $(TARGET_H)
  cp/search.o: cp/search.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h $(RTL_H)
--- 255,261 ----
  cp/init.o: cp/init.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) $(RTL_H) $(EXPR_H) \
    toplev.h except.h $(TARGET_H)
  cp/method.o: cp/method.c $(CXX_TREE_H) $(TM_H) toplev.h $(RTL_H) $(EXPR_H) \
!   $(TM_P_H) $(TARGET_H) $(DIAGNOSTIC_H) gt-cp-method.h $(CGRAPH_H)
  cp/cvt.o: cp/cvt.c $(CXX_TREE_H) $(TM_H) cp/decl.h $(FLAGS_H) toplev.h \
    convert.h $(TARGET_H)
  cp/search.o: cp/search.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h $(RTL_H)
Index: cp/method.c
===================================================================
*** cp/method.c	(revision 128277)
--- cp/method.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 38,43 ****
--- 38,44 ----
  #include "target.h"
  #include "tree-pass.h"
  #include "diagnostic.h"
+ #include "cgraph.h"
  
  /* Various flags to control the mangling process.  */
  
*************** use_thunk (tree thunk_fndecl, bool emit_
*** 522,529 ****
        pop_deferring_access_checks ();
  
        thunk_fndecl = finish_function (0);
!       tree_lowering_passes (thunk_fndecl);
!       expand_body (thunk_fndecl);
      }
  
    pop_from_top_level ();
--- 523,529 ----
        pop_deferring_access_checks ();
  
        thunk_fndecl = finish_function (0);
!       cgraph_add_new_function (thunk_fndecl, false);
      }
  
    pop_from_top_level ();
Index: cp/cp-objcp-common.h
===================================================================
*** cp/cp-objcp-common.h	(revision 128277)
--- cp/cp-objcp-common.h	(working copy)
*************** extern tree objcp_tsubst_copy_and_build 
*** 115,122 ****
  
  #undef LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR
  #define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR cxx_callgraph_analyze_expr
! #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
! #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION expand_body
  
  #undef LANG_HOOKS_MAKE_TYPE
  #define LANG_HOOKS_MAKE_TYPE cxx_make_type
--- 115,122 ----
  
  #undef LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR
  #DEFIne LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR cxx_callgraph_analyze_expr
! #undef LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS
! #define LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS emit_associated_thunks
  
  #undef LANG_HOOKS_MAKE_TYPE
  #define LANG_HOOKS_MAKE_TYPE cxx_make_type
Index: cp/cp-tree.h
===================================================================
*** cp/cp-tree.h	(revision 128277)
--- cp/cp-tree.h	(working copy)
*************** extern tree finish_typeof			(tree);
*** 4639,4645 ****
  extern tree finish_offsetof			(tree);
  extern void finish_decl_cleanup			(tree, tree);
  extern void finish_eh_cleanup			(tree);
! extern void expand_body				(tree);
  extern void finish_mem_initializers		(tree);
  extern tree check_template_template_default_arg (tree);
  extern void expand_or_defer_fn			(tree);
--- 4639,4645 ----
  extern tree finish_offsetof			(tree);
  extern void finish_decl_cleanup			(tree, tree);
  extern void finish_eh_cleanup			(tree);
! extern void emit_associated_thunks		(tree);
  extern void finish_mem_initializers		(tree);
  extern tree check_template_template_default_arg (tree);
  extern void expand_or_defer_fn			(tree);
Index: cp/semantics.c
===================================================================
*** cp/semantics.c	(revision 128277)
--- cp/semantics.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 54,60 ****
  
  static tree maybe_convert_cond (tree);
  static tree simplify_aggr_init_exprs_r (tree *, int *, void *);
- static void emit_associated_thunks (tree);
  static tree finalize_nrv_r (tree *, int *, void *);
  
  
--- 54,59 ----
*************** simplify_aggr_init_expr (tree *tp)
*** 3094,3100 ****
  
  /* Emit all thunks to FN that should be emitted when FN is emitted.  */
  
! static void
  emit_associated_thunks (tree fn)
  {
    /* When we use vcall offsets, we emit thunks with the virtual
--- 3093,3099 ----
  
  /* Emit all thunks to FN that should be emitted when FN is emitted.  */
  
! void
  emit_associated_thunks (tree fn)
  {
    /* When we use vcall offsets, we emit thunks with the virtual
*************** emit_associated_thunks (tree fn)
*** 3129,3150 ****
  /* Generate RTL for FN.  */
  
  void
- expand_body (tree fn)
- {
-   /* Emit any thunks that should be emitted at the same time as FN.  */
-   emit_associated_thunks (fn);
- 
-   /* This function is only called from cgraph, or recursively from
-      emit_associated_thunks.  In neither case should we be currently
-      generating trees for a function.  */
-   gcc_assert (function_depth == 0);
- 
-   c_expand_body (fn);
- }
- 
- /* Generate RTL for FN.  */
- 
- void
  expand_or_defer_fn (tree fn)
  {
    /* When the parser calls us after finishing the body of a template
--- 3128,3133 ----
Index: ada/misc.c
===================================================================
*** ada/misc.c	(revision 128277)
--- ada/misc.c	(working copy)
*************** static int gnat_eh_type_covers		(tree, t
*** 100,106 ****
  static void gnat_parse_file		(int);
  static rtx gnat_expand_expr		(tree, rtx, enum machine_mode, int,
  					 rtx *);
- static void gnat_expand_body		(tree);
  static void internal_error_function	(const char *, va_list *);
  static void gnat_adjust_rli		(record_layout_info);
  static tree gnat_type_max_size		(const_tree);
--- 100,105 ----
*************** static tree gnat_type_max_size		(const_t
*** 149,156 ****
  #define LANG_HOOKS_DECL_PRINTABLE_NAME	gnat_printable_name
  #undef  LANG_HOOKS_DWARF_NAME
  #define LANG_HOOKS_DWARF_NAME		gnat_dwarf_name
- #undef  LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
- #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gnat_expand_body
  #undef  LANG_HOOKS_GIMPLIFY_EXPR
  #define LANG_HOOKS_GIMPLIFY_EXPR	gnat_gimplify_expr
  #undef  LANG_HOOKS_TYPE_FOR_MODE
--- 148,153 ----
*************** gnat_expand_expr (tree exp, rtx target, 
*** 678,691 ****
    return expand_expr_real (new, target, tmode, modifier, alt_rtl);
  }
  
- /* Generate the RTL for the body of GNU_DECL.  */
- 
- static void
- gnat_expand_body (tree gnu_decl)
- {
-   tree_rest_of_compilation (gnu_decl);
- }
- 
  /* Adjusts the RLI used to layout a record after all the fields have been
     added.  We only handle the packed case and cause it to use the alignment
     that will pad the record at the end.  */
--- 675,680 ----
Index: c-decl.c
===================================================================
*** c-decl.c	(revision 128277)
--- c-decl.c	(working copy)
*************** finish_function (void)
*** 6799,6805 ****
  	     This should be cleaned up later and this conditional removed.  */
  	  if (cgraph_global_info_ready)
  	    {
! 	      c_expand_body (fndecl);
  	      return;
  	    }
  
--- 6799,6805 ----
  	     This should be cleaned up later and this conditional removed.  */
  	  if (cgraph_global_info_ready)
  	    {
! 	      cgraph_add_new_function (fndecl, false);
  	      return;
  	    }
  
Index: fortran/f95-lang.c
===================================================================
*** fortran/f95-lang.c	(revision 128277)
--- fortran/f95-lang.c	(working copy)
*************** int global_bindings_p (void);
*** 98,104 ****
  void insert_block (tree);
  static void gfc_clear_binding_stack (void);
  static void gfc_be_parse_file (int);
- static void gfc_expand_function (tree);
  static alias_set_type gfc_get_alias_set (tree);
  
  #undef LANG_HOOKS_NAME
--- 98,103 ----
*************** static alias_set_type gfc_get_alias_set 
*** 135,141 ****
  #define LANG_HOOKS_MARK_ADDRESSABLE        gfc_mark_addressable
  #define LANG_HOOKS_TYPE_FOR_MODE           gfc_type_for_mode
  #define LANG_HOOKS_TYPE_FOR_SIZE           gfc_type_for_size
- #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gfc_expand_function
  #define LANG_HOOKS_CLEAR_BINDING_STACK     gfc_clear_binding_stack
  #define LANG_HOOKS_GET_ALIAS_SET	   gfc_get_alias_set
  #define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE	gfc_omp_privatize_by_reference
--- 134,139 ----
*************** static GTY(()) struct binding_level *fre
*** 194,238 ****
     It is indexed by a RID_... value.  */
  tree *ridpointers = NULL;
  
- /* language-specific flags.  */
- 
- static void
- gfc_expand_function (tree fndecl)
- {
-   tree t;
- 
-   if (DECL_INITIAL (fndecl)
-       && BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl)))
-     {
-       /* Local static equivalenced variables are never seen by
- 	 check_global_declarations, so we need to output debug
- 	 info by hand.  */
- 
-       t = BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl));
-       for (t = BLOCK_VARS (t); t; t = TREE_CHAIN (t))
- 	if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t)
- 	    && TREE_STATIC (t))
- 	  {
- 	    tree expr = DECL_VALUE_EXPR (t);
- 
- 	    if (TREE_CODE (expr) == COMPONENT_REF
- 		&& TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL
- 		&& TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0)))
- 		   == UNION_TYPE
- 		&& varpool_node (TREE_OPERAND (expr, 0))->needed
- 		&& errorcount == 0 && sorrycount == 0)
- 	      {
- 		timevar_push (TV_SYMOUT);
- 		(*debug_hooks->global_decl) (t);
- 		timevar_pop (TV_SYMOUT);
- 	      }
- 	  }
-     }
- 
-   tree_rest_of_compilation (fndecl);
- }
- 
- 
  /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
     or validate its data type for an `if' or `while' statement or ?..: exp.
  
--- 192,197 ----
Index: function.c
===================================================================
*** function.c	(revision 128277)
--- function.c	(working copy)
*************** expand_function_end (void)
*** 4408,4420 ****
  	  }
      }
  
-   /* Possibly warn about unused parameters.
-      When frontend does unit-at-a-time, the warning is already
-      issued at finalization time.  */
-   if (warn_unused_parameter
-       && !lang_hooks.callgraph.expand_function)
-     do_warn_unused_parameter (current_function_decl);
- 
    /* End any sequences that failed to be closed due to syntax errors.  */
    while (in_sequence_p ())
      end_sequence ();
--- 4408,4413 ----
Index: langhooks.h
===================================================================
*** langhooks.h	(revision 128277)
--- langhooks.h	(working copy)
*************** struct lang_hooks_for_callgraph
*** 44,51 ****
       are relevant to use of other declarations, mark them.  */
    tree (*analyze_expr) (tree *, int *, tree);
  
!   /* Produce RTL for function passed as argument.  */
!   void (*expand_function) (tree);
  };
  
  /* Lang hooks for management of language-specific data or status
--- 44,51 ----
       are relevant to use of other declarations, mark them.  */
    tree (*analyze_expr) (tree *, int *, tree);
  
!   /* Emmit thunks associated to function.  */
!   void (*emit_associated_thunks) (tree);
  };
  
  /* Lang hooks for management of language-specific data or status
Index: c-common.c
===================================================================
*** c-common.c	(revision 128277)
--- c-common.c	(working copy)
*************** c_expand_expr (tree exp, rtx target, enu
*** 4577,4591 ****
      }
  }
  
- 
- /* Generate the RTL for the body of FNDECL.  */
- 
- void
- c_expand_body (tree fndecl)
- {
-   tree_rest_of_compilation (fndecl);
- }
- 
  /* Hook used by staticp to handle language-specific tree codes.  */
  
  tree
--- 4577,4582 ----
Index: passes.c
===================================================================
*** passes.c	(revision 128277)
--- passes.c	(working copy)
*************** next_pass_1 (struct tree_opt_pass **list
*** 461,468 ****
         cgraph_expand_all_functions ()
             for each node N in the cgraph
  	       cgraph_expand_function (N)
! 		   lang_hooks.callgraph.expand_function (DECL (N))
! 		   	tree_rest_of_compilation (DECL (N))  -> all_passes
  */
  
  void
--- 461,467 ----
         cgraph_expand_all_functions ()
             for each node N in the cgraph
  	       cgraph_expand_function (N)
! 		  tree_rest_of_compilation (DECL (N))  -> all_passes
  */
  
  void
Index: langhooks-def.h
===================================================================
*** langhooks-def.h	(revision 128277)
--- langhooks-def.h	(working copy)
*************** extern void lhd_omp_firstprivatize_type_
*** 138,148 ****
  }
  
  #define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR lhd_callgraph_analyze_expr
! #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION NULL
  
  #define LANG_HOOKS_CALLGRAPH_INITIALIZER { \
    LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR, \
!   LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION, \
  }
  
  #define LANG_HOOKS_FUNCTION_INITIALIZER {	\
--- 138,148 ----
  }
  
  #define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR lhd_callgraph_analyze_expr
! #define LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS NULL
  
  #define LANG_HOOKS_CALLGRAPH_INITIALIZER { \
    LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR, \
!   LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS, \
  }
  
  #define LANG_HOOKS_FUNCTION_INITIALIZER {	\


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