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 for "no_instrument_function" attribute


The attribute "no_instrument_function" allows the support routines for
"-finstrument-functions" to be compiled with the same set of options
as other functions.  The operation of this attribute has been extended
to apply to "-p" and "-pg" options. This will make it much easier to
compile multilibs such as newlib and have the profiling support within
the
library. The profiling support functions should be compiled without
profiling. With this extension to the "no_instrument_function"
attribute the profiling support routines in the library will be
compiled correctly regardless of whether a profiling option is passed
to the compiler. Is it okay to apply this patch?

	* function.h (struct function): Add profile.
	(current_function_profile): New.
	* function.c (expand_function_start): Add check to disable
	function profiling.
	* final.c (final_start_function): Check on per function basis.
	(profile_after_prologue): Likewise.
	(leaf_function_p): Likewise.

-- 
Will Cohen, GCC Engineer                         ------    ,__o
Red Hat, 2600 Meridian pkwy, Durham, NC 27713   ------   _-\_<,
Office (919)-547-0012 x390  Fax (919)-547-0024 ------   (*)/'(*)
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.336
diff -c -2 -p -r1.336 function.c
*** function.c	2001/12/09 20:13:04	1.336
--- function.c	2001/12/18 16:52:26
*************** expand_function_start (subr, parms_have_
*** 6353,6356 ****
--- 6353,6360 ----
         && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (subr));
  
+   current_function_profile
+     = (profile_flag
+        && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (subr));
+ 
    current_function_limit_stack
      = (stack_limit_rtx != NULL_RTX && ! DECL_NO_LIMIT_STACK (subr));
Index: function.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.h,v
retrieving revision 1.73
diff -c -2 -p -r1.73 function.h
*** function.h	2001/12/05 22:37:28	1.73
--- function.h	2001/12/18 16:52:26
*************** struct function
*** 435,438 ****
--- 435,441 ----
    unsigned int instrument_entry_exit : 1;
  
+   /* Nonzero if profiling code should be generated.  */
+   unsigned int profile : 1;
+ 
    /* Nonzero if stack limit checking should be enabled in the current
       function.  */
*************** extern int virtuals_instantiated;
*** 505,508 ****
--- 508,512 ----
  #define current_function_return_rtx (cfun->return_rtx)
  #define current_function_instrument_entry_exit (cfun->instrument_entry_exit)
+ #define current_function_profile (cfun->profile)
  #define current_function_limit_stack (cfun->limit_stack)
  #define current_function_uses_pic_offset_table (cfun->uses_pic_offset_table)
Index: final.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/final.c,v
retrieving revision 1.234
diff -c -2 -p -r1.234 final.c
*** final.c	2001/12/17 15:05:21	1.234
--- final.c	2001/12/18 16:52:26
*************** final_start_function (first, file, optim
*** 1548,1552 ****
       if the profiling code comes after the prologue.  */
  #ifdef PROFILE_BEFORE_PROLOGUE
!   if (profile_flag)
      profile_function (file);
  #endif /* PROFILE_BEFORE_PROLOGUE */
--- 1548,1552 ----
       if the profiling code comes after the prologue.  */
  #ifdef PROFILE_BEFORE_PROLOGUE
!   if (current_function_profile)
      profile_function (file);
  #endif /* PROFILE_BEFORE_PROLOGUE */
*************** profile_after_prologue (file)
*** 1594,1598 ****
  {
  #ifndef PROFILE_BEFORE_PROLOGUE
!   if (profile_flag)
      profile_function (file);
  #endif /* not PROFILE_BEFORE_PROLOGUE */
--- 1594,1598 ----
  {
  #ifndef PROFILE_BEFORE_PROLOGUE
!   if (current_function_profile)
      profile_function (file);
  #endif /* not PROFILE_BEFORE_PROLOGUE */
*************** leaf_function_p ()
*** 3840,3844 ****
    rtx link;
  
!   if (profile_flag || profile_arc_flag)
      return 0;
  
--- 3840,3844 ----
    rtx link;
  
!   if (current_function_profile || profile_arc_flag)
      return 0;
  
Index: doc/extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.49
diff -c -2 -p -r1.49 extend.texi
*** extend.texi	2001/12/17 19:19:57	1.49
--- extend.texi	2001/12/18 16:52:27
*************** Controlling C Dialect}.
*** 2096,2102 ****
  @cindex @code{no_instrument_function} function attribute
  @opindex finstrument-functions
! If @option{-finstrument-functions} is given, profiling function calls will
! be generated at entry and exit of most user-compiled functions.
! Functions with this attribute will not be so instrumented.
  
  @item section ("@var{section-name}")
--- 2096,2104 ----
  @cindex @code{no_instrument_function} function attribute
  @opindex finstrument-functions
! If @option{-finstrument-functions} is given, profiling function calls
! will be generated at entry and exit of most user-compiled functions.
! Functions with this attribute will not be so instrumented. This
! attribute also disables the instrumentation of the function caused by
! the @option{-pg} and @option{-p} options.
  
  @item section ("@var{section-name}")

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