Message ID | 20100717094532.GB9340@basil.fritz.box |
---|---|
State | New |
Headers | show |
Hello, I found one missing nit for cygwin/mingw, which is corrected by this patch. For win32 target an initial call to _monstartup has to be done in main before mcount get called. For this I added to cygming.h the new macro PROFILE_HOOK_BEFORE_PROFILE to handle it. So new patch with updated ChangeLog * config/i386/cygming.h (MCOUNT_NAME): New. (MCOUNT_NAME_BEFORE_PROLOGUE): New. (PROFILE_HOOK_BEFORE_PROFILE): New. (PROFILE_HOOK): Check if not fentry is active. * config/i386/i386.c (ix86_profile_before_prologue): New. (override_options): Add special handling for -mfentry. (ix86_function_regparm): Likewise. (ix86_function_sseregparm): Likewise. (ix86_frame_pointer_required): Likewise. (ix86_expand_prologue): Check for ms_hook_prologue. (x86_function_profiler): Adjust mcount output and call PROFILE_HOOK_BEFORE_PROFILE. (TARGET_PROFILE_BEFORE_PROLOGUE): Define hook. * config/i386/i386.opt (mfentry): New. * doc/invoke.texi (mfentry): Add documentation. * doc/tm.texi: Regenerated.. * doc/tm.texi.in (TARGET_PROFILE_BEFORE_PROLOGUE): New. * final.c (final_start_function): Replace macro PROFILE_BEFORE_PROLOGUE by target hook. * function.c (thread_prologue_and_epilogue_insns): Likewise. * target.def (profile_before_prologue): New hook. * targhooks.c (default_profile_before_prologue): New. * targhooks.h (default_profile_before_prologue): New. Tested for i686-pc-mingw32, i686-pc-cygwin, and x86_64-pc-mingw32. Ok for apply? Regards, Kai
2010/7/18 Kai Tietz <ktietz70@googlemail.com>: > Hello, > > I found one missing nit for cygwin/mingw, which is corrected by this > patch. For win32 target an initial call to _monstartup has to be done > in main before mcount get called. For this I added to cygming.h the > new macro PROFILE_HOOK_BEFORE_PROFILE to handle it. > > So new patch with updated ChangeLog > > * config/i386/cygming.h (MCOUNT_NAME): New. > (MCOUNT_NAME_BEFORE_PROLOGUE): New. > (PROFILE_HOOK_BEFORE_PROFILE): New. > (PROFILE_HOOK): Check if not fentry is active. > * config/i386/i386.c (ix86_profile_before_prologue): New. > (override_options): Add special handling for -mfentry. > (ix86_function_regparm): Likewise. > (ix86_function_sseregparm): Likewise. > (ix86_frame_pointer_required): Likewise. > (ix86_expand_prologue): Check for ms_hook_prologue. > (x86_function_profiler): Adjust mcount output and > call PROFILE_HOOK_BEFORE_PROFILE. > (TARGET_PROFILE_BEFORE_PROLOGUE): Define hook. > * config/i386/i386.opt (mfentry): New. > * doc/invoke.texi (mfentry): Add documentation. > * doc/tm.texi: Regenerated.. > * doc/tm.texi.in (TARGET_PROFILE_BEFORE_PROLOGUE): New. > * final.c (final_start_function): Replace macro > PROFILE_BEFORE_PROLOGUE by target hook. > * function.c (thread_prologue_and_epilogue_insns): Likewise. > * target.def (profile_before_prologue): New hook. > * targhooks.c (default_profile_before_prologue): New. > * targhooks.h (default_profile_before_prologue): New. > > > Tested for i686-pc-mingw32, i686-pc-cygwin, and x86_64-pc-mingw32. Ok for apply? > > Regards, > Kai > Hmm, it doesn't hurt, but it seems to me that for old behavior the monstartup hook got called after the mcount function. So I am not sure here if the last patch is necessary at all, so withdraw recent patch and fallback to the patch before. Sorry for the noise. Kai
diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h index 81dfd1e..54051ed 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h @@ -48,6 +48,10 @@ along with GCC; see the file COPYING3. If not see #define NO_PROFILE_COUNTERS 1 +/* Choose the correct profiler mcount name. */ +#undef MCOUNT_NAME_BEFORE_PROLOGUE +#define MCOUNT_NAME_BEFORE_PROLOGUE "__fentry__" + #undef MCOUNT_NAME #define MCOUNT_NAME "mcount" diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h index 33b4dc9..f40fa31 100644 --- a/gcc/config/i386/linux64.h +++ b/gcc/config/i386/linux64.h @@ -123,3 +123,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see x86_64 glibc provides it in %fs:0x28. */ #define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? 0x28 : 0x14) #endif + +/* Choose the correct profiler mcount name. */ +#undef MCOUNT_NAME_BEFORE_PROLOGUE +#define MCOUNT_NAME_BEFORE_PROLOGUE "__fentry__" + +#undef MCOUNT_NAME +#define MCOUNT_NAME "mcount"