Patch: enable profiling of main() for mingw32.

Danny Smith danny_r_smith_2001@yahoo.co.nz
Wed Dec 4 18:50:00 GMT 2002


 --- Richard Henderson <rth@redhat.com> wrote: > On Thu, Dec 05, 2002 at
08:20:02AM +1100, Danny Smith wrote:
> 
>         * i386/mingw32.h (SUBTARGET_PROLOGUE): Override Cygwin definition.
>         * i386/uwin.h (SUBTARGET_PROLOGUE): Likewise.
> 
> > 	* config/i386.mingw32.h (SUBTARGET_PROLUGUE): Don't disable
> > 	the Cygwin definition.
> 
> Incidentally, I think Cygwin ought to be using PROFILE_HOOK
> for this.  As it is, the call happens somewhere in the middle
> of the prologue, which isn't ideal.
> 


Thanks.

I have revised patch to do that.  Tested on mingw32 with GCC 3.3 pre. I'm
bootstrapping cygwin now.  On mingw the revised patch gives virtually same
gprof output as did my former patch on simple testcase. 
It also gives same output as cygwin/GCC 3.2 with the SUBTARGET_PROLOGUE macro.

I have attached patch as well as inlining since may be line wrapping problems

Danny

ChangeLog

2002-12-04  Danny Smith  <dannysmith@users.sourceforge.net>

	* config/i386/cygwin32.h (SUBTARGET_PROLOGUE): Replace with
	PROFILE_HOOK.
	* config/i386/mingw32.h (SUBTARGET_PROLOGUE): Don't undef.

Index: cygwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/cygwin.h,v
retrieving revision 1.74
diff -c -3 -p -r1.74 cygwin.h
*** cygwin.h	24 Sep 2002 12:48:55 -0000	1.74
--- cygwin.h	5 Dec 2002 02:43:09 -0000
*************** extern void i386_pe_unique_section PARAM
*** 387,401 ****
  /* Don't assume anything about the header files.  */
  #define NO_IMPLICIT_EXTERN_C
  
! #define SUBTARGET_PROLOGUE						\
!   if (current_function_profile						\
!       && MAIN_NAME_P (DECL_NAME (current_function_decl)))		\
!      {									\
!       emit_call_insn (gen_rtx (CALL, VOIDmode, 				\
  	gen_rtx_MEM (FUNCTION_MODE,					\
  		     gen_rtx_SYMBOL_REF (Pmode, "_monstartup")),	\
  	const0_rtx));							\
!      }
  
  /* External function declarations.  */
  
--- 387,401 ----
  /* Don't assume anything about the header files.  */
  #define NO_IMPLICIT_EXTERN_C
  
! #undef PROFILE HOOK
! #define PROFILE_HOOK(unused)						\
!   if (MAIN_NAME_P (DECL_NAME (current_function_decl))			\
!     {									\
!       emit_call_insn (gen_rtx (CALL, VOIDmode,				\
  	gen_rtx_MEM (FUNCTION_MODE,					\
  		     gen_rtx_SYMBOL_REF (Pmode, "_monstartup")),	\
  	const0_rtx));							\
!     }
  
  /* External function declarations.  */
  
Index: mingw32.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/mingw32.h,v
retrieving revision 1.27
diff -c -3 -p -r1.27 mingw32.h
*** mingw32.h	29 Jun 2002 09:10:04 -0000	1.27
--- mingw32.h	4 Dec 2002 21:08:39 -0000
*************** do {						         \
*** 127,136 ****
    putc ('\"', asm_file);			         \
  } while (0)
  
- /* Override Cygwin's definition. This is necessary now due to the way
-    Cygwin profiling code is written. Once "fixed", we can remove this.  */
- #undef SUBTARGET_PROLOGUE
- 
  /* Define as short unsigned for compatability with MS runtime.  */
  #undef WINT_TYPE
  #define WINT_TYPE "short unsigned int"
--- 127,132 ----




http://www.yahoo.promo.com.au/hint/ - Yahoo! Hint Dropper
- Avoid getting hideous gifts this Christmas with Yahoo! Hint Dropper!
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cyg-ming-profile.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20021204/6ecfa392/attachment.ksh>


More information about the Gcc-patches mailing list