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]

Patch for current_function_cannot_inline


In C++, an inline function effectively has only one definition, so any
static variables must also be commonized if the function is inlined.  This
is more trouble than it's worth to deal with, so we disable inlining of
such functions.  Which needs a backend flag to prevent -O3 from biting me.

1998-06-05  Jason Merrill  <jason@yorick.cygnus.com>

	* function.c: Define current_function_cannot_inline.
	(push_function_context_to): Save it.
	(pop_function_context_from): Restore it.
	* function.h (struct function): Provide it a home.
	* output.h: Declare it.
	* integrate.c (function_cannot_inline_p): Check it.

Index: function.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/function.c,v
retrieving revision 1.33
diff -c -p -r1.33 function.c
*** function.c	1998/05/23 23:14:50	1.33
--- function.c	1998/06/06 05:43:48
*************** int current_function_uses_pic_offset_tab
*** 214,219 ****
--- 214,223 ----
  /* The arg pointer hard register, or the pseudo into which it was copied.  */
  rtx current_function_internal_arg_pointer;
  
+ /* Nonzero if the current function cannot be made inline for some
+    language-specific reason.  */
+ int current_function_cannot_inline;
+ 
  /* The FUNCTION_DECL for an inline function currently being expanded.  */
  tree inline_function_decl;
  
*************** push_function_context_to (context)
*** 507,512 ****
--- 511,517 ----
    p->uses_const_pool = current_function_uses_const_pool;
    p->uses_pic_offset_table = current_function_uses_pic_offset_table;
    p->internal_arg_pointer = current_function_internal_arg_pointer;
+   p->cannot_inline = current_function_cannot_inline;
    p->max_parm_reg = max_parm_reg;
    p->parm_reg_stack_loc = parm_reg_stack_loc;
    p->outgoing_args_size = current_function_outgoing_args_size;
*************** pop_function_context_from (context)
*** 588,593 ****
--- 593,599 ----
    current_function_uses_const_pool = p->uses_const_pool;
    current_function_uses_pic_offset_table = p->uses_pic_offset_table;
    current_function_internal_arg_pointer = p->internal_arg_pointer;
+   current_function_cannot_inline = p->cannot_inline;
    max_parm_reg = p->max_parm_reg;
    parm_reg_stack_loc = p->parm_reg_stack_loc;
    current_function_outgoing_args_size = p->outgoing_args_size;
*************** init_function_start (subr, filename, lin
*** 5319,5324 ****
--- 5325,5331 ----
    current_function_epilogue_delay_list = 0;
    current_function_uses_const_pool = 0;
    current_function_uses_pic_offset_table = 0;
+   current_function_cannot_inline = 0;
  
    /* We have not yet needed to make a label to jump to for tail-recursion.  */
    tail_recursion_label = 0;
Index: function.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/function.h,v
retrieving revision 1.6
diff -c -p -r1.6 function.h
*** function.h	1998/05/28 06:46:37	1.6
--- function.h	1998/06/06 05:43:48
*************** struct function
*** 102,107 ****
--- 102,108 ----
    rtx tail_recursion_label;
    rtx tail_recursion_reentry;
    rtx internal_arg_pointer;
+   int cannot_inline;
    rtx arg_pointer_save_area;
    tree rtl_expr_chain;
    rtx last_parm_insn;
Index: output.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/output.h,v
retrieving revision 1.6
diff -c -p -r1.6 output.h
*** output.h	1998/05/19 08:42:37	1.6
--- output.h	1998/06/06 05:43:49
*************** extern int current_function_uses_pic_off
*** 437,442 ****
--- 437,446 ----
  /* This is nonzero if the current function uses the constant pool.  */
  extern int current_function_uses_const_pool;
  
+ /* This is nonzero if the current function cannot be made inline for some
+    language-specific reason.  */
+ int current_function_cannot_inline;
+ 
  /* The line number of the beginning of the current function.
     sdbout.c needs this so that it can output relative linenumbers.  */
  
Index: integrate.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/integrate.c,v
retrieving revision 1.31
diff -c -p -r1.31 integrate.c
*** integrate.c	1998/05/19 08:42:35	1.31
--- integrate.c	1998/06/06 05:43:49
*************** function_cannot_inline_p (fndecl)
*** 132,137 ****
--- 132,140 ----
    if (current_function_contains_functions)
      return "function with nested functions cannot be inline";
  
+   if (current_function_cannot_inline)
+     return "function cannot be inline";
+ 
    /* If its not even close, don't even look.  */
    if (!DECL_INLINE (fndecl) && get_max_uid () > 3 * max_insns)
      return "function too large to be inline";


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