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]

C++ PATCH for a tad bit more function-at-a-time processing



This patch builds some of the static initialization code in
function-at-a-time mode.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-09-23  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (language_function): Add cannot_inline.
	* decl.c (start_function): Restore current_function_cannot_inline
	from the saved value.
	(save_function_data): Save current_function_cannot_inline.
	* decl2.c (start_objects): Change prototype.  Build the function
	in function-at-a-time mode.
	(finish_objects): Likewise.
	(generate_ctor_or_dtor_function): Adjust accordingly.

Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.315
diff -c -p -r1.315 cp-tree.h
*** cp-tree.h	1999/09/24 01:17:23	1.315
--- cp-tree.h	1999/09/24 01:25:11
*************** struct language_function
*** 678,683 ****
--- 678,685 ----
  
    struct named_label_list *x_named_label_uses;
    struct binding_level *bindings;
+ 
+   const char *cannot_inline;
  };
  
  /* The current C++-specific per-function global variables.  */
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.465
diff -c -p -r1.465 decl.c
*** decl.c	1999/09/23 21:04:08	1.465
--- decl.c	1999/09/24 01:25:21
*************** start_function (declspecs, declarator, a
*** 12944,12949 ****
--- 12944,12954 ----
  	 already did semantic analysis.  */
        current_function->x_whole_function_mode_p = 1;
  
+       /* If we decided that we didn't want to inline this function,
+ 	 make sure the back-end knows that.  */
+       if (!current_function_cannot_inline)
+ 	current_function_cannot_inline = cp_function_chain->cannot_inline;
+ 
        /* We don't need the saved data anymore.  */
        free (DECL_SAVED_FUNCTION_DATA (decl1));
        DECL_SAVED_FUNCTION_DATA (decl1) = NULL;
*************** save_function_data (decl)
*** 13305,13310 ****
--- 13310,13320 ----
  
    /* When we get back here again, we will be expanding.  */
    f->x_expanding_p = 1;
+ 
+   /* If we've already decided that we cannot inline this function, we
+      must remember that fact when we actually go to expand the
+      function.  */
+   f->cannot_inline = current_function_cannot_inline;
  }
  
  /* At the end of every destructor we generate code to restore virtual
Index: decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.266
diff -c -p -r1.266 decl2.c
*** decl2.c	1999/09/24 01:17:24	1.266
--- decl2.c	1999/09/24 01:25:24
*************** static tree ambiguous_decl PROTO((tree, 
*** 78,85 ****
  static tree build_anon_union_vars PROTO((tree, tree*, int, int));
  static int acceptable_java_type PROTO((tree));
  static void output_vtable_inherit PROTO((tree));
! static void start_objects PROTO((int, int));
! static void finish_objects PROTO((int, int));
  static tree merge_functions PROTO((tree, tree));
  static tree decl_namespace PROTO((tree));
  static tree validate_nonmember_using_decl PROTO((tree, tree *, tree *));
--- 78,85 ----
  static tree build_anon_union_vars PROTO((tree, tree*, int, int));
  static int acceptable_java_type PROTO((tree));
  static void output_vtable_inherit PROTO((tree));
! static tree start_objects PROTO((int, int));
! static void finish_objects PROTO((int, int, tree));
  static tree merge_functions PROTO((tree, tree));
  static tree decl_namespace PROTO((tree));
  static tree validate_nonmember_using_decl PROTO((tree, tree *, tree *));
*************** get_sentry (base)
*** 2758,2768 ****
  /* Start the process of running a particular set of global constructors
     or destructors.  Subroutine of do_[cd]tors.  */
  
! static void
  start_objects (method_type, initp)
       int method_type, initp;
  {
    tree fnname;
    char type[10];
  
    /* Make ctor or dtor function.  METHOD_TYPE may be 'I' or 'D'.  */
--- 2758,2769 ----
  /* Start the process of running a particular set of global constructors
     or destructors.  Subroutine of do_[cd]tors.  */
  
! static tree
  start_objects (method_type, initp)
       int method_type, initp;
  {
    tree fnname;
+   tree body;
    char type[10];
  
    /* Make ctor or dtor function.  METHOD_TYPE may be 'I' or 'D'.  */
*************** start_objects (method_type, initp)
*** 2787,2793 ****
    start_function (void_list_node,
  		  make_call_declarator (fnname, void_list_node, NULL_TREE,
  					NULL_TREE),
! 		  NULL_TREE, SF_DEFAULT | SF_EXPAND);
  
  #if defined(ASM_OUTPUT_CONSTRUCTOR) && defined(ASM_OUTPUT_DESTRUCTOR)
    /* It can be a static function as long as collect2 does not have
--- 2788,2794 ----
    start_function (void_list_node,
  		  make_call_declarator (fnname, void_list_node, NULL_TREE,
  					NULL_TREE),
! 		  NULL_TREE, SF_DEFAULT);
  
  #if defined(ASM_OUTPUT_CONSTRUCTOR) && defined(ASM_OUTPUT_DESTRUCTOR)
    /* It can be a static function as long as collect2 does not have
*************** start_objects (method_type, initp)
*** 2798,2808 ****
    /* Mark this declaration as used to avoid spurious warnings.  */
    TREE_USED (current_function_decl) = 1;
  
!   store_parm_decls ();
!   pushlevel (0);
!   clear_last_expr ();
!   push_momentary ();
!   expand_start_bindings (0);
  
    /* We cannot allow these functions to be elided, even if they do not
       have external linkage.  And, there's no point in deferring
--- 2799,2805 ----
    /* Mark this declaration as used to avoid spurious warnings.  */
    TREE_USED (current_function_decl) = 1;
  
!   body = begin_compound_stmt (/*has_no_scope=*/0);
  
    /* We cannot allow these functions to be elided, even if they do not
       have external linkage.  And, there's no point in deferring
*************** start_objects (method_type, initp)
*** 2810,2832 ****
       out anyhow.  */
    current_function_cannot_inline
      = "static constructors and destructors cannot be inlined";
  }
  
  /* Finish the process of running a particular set of global constructors
     or destructors.  Subroutine of do_[cd]tors.  */
  
  static void
! finish_objects (method_type, initp)
       int method_type, initp;
  {
!   char *fnname = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
  
    /* Finish up. */
!   expand_end_bindings (getdecls (), 1, 0);
!   poplevel (1, 0, 0);
!   pop_momentary ();
!   finish_function (lineno, 0);
  
    if (initp == DEFAULT_INIT_PRIORITY)
      {
        if (method_type == 'I')
--- 2807,2833 ----
       out anyhow.  */
    current_function_cannot_inline
      = "static constructors and destructors cannot be inlined";
+ 
+   return body;
  }
  
  /* Finish the process of running a particular set of global constructors
     or destructors.  Subroutine of do_[cd]tors.  */
  
  static void
! finish_objects (method_type, initp, body)
       int method_type, initp;
+      tree body;
  {
!   char *fnname;
!   tree fn;
  
    /* Finish up. */
!   finish_compound_stmt(/*has_no_scope=*/0, body);
!   fn = finish_function (lineno, 0);
!   expand_body (fn);
  
+   fnname = XSTR (XEXP (DECL_RTL (fn), 0), 0);
    if (initp == DEFAULT_INIT_PRIORITY)
      {
        if (method_type == 'I')
*************** generate_ctor_or_dtor_function (construc
*** 3338,3343 ****
--- 3339,3345 ----
  {
    char function_key;
    tree arguments;
+   tree body;
    size_t i;
  
    /* We use `I' to indicate initialization and `D' to indicate
*************** generate_ctor_or_dtor_function (construc
*** 3348,3354 ****
      function_key = 'D';
  
    /* Begin the function.  */
!   start_objects (function_key, priority);
  
    /* Call the static storage duration function with appropriate
       arguments.  */
--- 3350,3356 ----
      function_key = 'D';
  
    /* Begin the function.  */
!   body = start_objects (function_key, priority);
  
    /* Call the static storage duration function with appropriate
       arguments.  */
*************** generate_ctor_or_dtor_function (construc
*** 3358,3364 ****
  			     NULL_TREE);
        arguments = tree_cons (NULL_TREE, build_int_2 (constructor_p, 0),
  			     arguments);
!       expand_expr_stmt (build_function_call (VARRAY_TREE (ssdf_decls, i),
  					     arguments));
      }
  
--- 3360,3366 ----
  			     NULL_TREE);
        arguments = tree_cons (NULL_TREE, build_int_2 (constructor_p, 0),
  			     arguments);
!       finish_expr_stmt (build_function_call (VARRAY_TREE (ssdf_decls, i),
  					     arguments));
      }
  
*************** generate_ctor_or_dtor_function (construc
*** 3372,3382 ****
        for (fns = constructor_p ? static_ctors : static_dtors; 
  	   fns;
  	   fns = TREE_CHAIN (fns))
! 	expand_expr_stmt (build_function_call (TREE_VALUE (fns), NULL_TREE));
      }
  
    /* Close out the function.  */
!   finish_objects (function_key, priority);
  }
  
  /* Generate constructor and destructor functions for the priority
--- 3374,3384 ----
        for (fns = constructor_p ? static_ctors : static_dtors; 
  	   fns;
  	   fns = TREE_CHAIN (fns))
! 	finish_expr_stmt (build_function_call (TREE_VALUE (fns), NULL_TREE));
      }
  
    /* Close out the function.  */
!   finish_objects (function_key, priority, body);
  }
  
  /* Generate constructor and destructor functions for the priority


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