This is the mail archive of the 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]

Re: [patch i386]: Add for win32 targets pre-prologue profiling feature


2010/7/13 Richard Henderson <>:
> On 07/13/2010 05:47 AM, Kai Tietz wrote:
>> Hello,
>> This patch adds for i386/x86_64 win32 targets the feature of
>> pre-prologue profiling call. It additional takes care that for enabled
>> top-profiler call, the frame-pointer gets omitted, if possible.
>> One side-note here about "hotfix" and profiling. The top-profiler call
>> gets emitted in the ix86_asm_output_function_label. This is caused by
>> the fact, that for ix86 the call needs to be placed before the
>> code-pattern, and for x86_64 it can be placed after. Otherwise the x86
>> pattern for patchable region would be corrupted, as this pattern
>> contains frame-register setup. So I think that the use of the macro
>> PROFILE_BEFORE_PROLOGUE isn't usable here.
> Huh? ?This is exactly the opposite of what we discussed yesterday on IRC.
> For hotfix we have
> ? ? ? ?.rept 16
> ? ? ? ?.byte 0xcc
> ? ? ? ?.endr
> function:
> ? ? ? ?mov.s ? edi, edi
> ? ? ? ?push ? ?ebp
> ? ? ? ?mov.s ? esp, ebp
> If *any* of the above is not exactly so, then the runtime pattern match
> fails and the hotfix fails. ?If we were to write the profiler first,
> then we might as well not bother with the hotfix pieces, because they
> will never match.
> ... of course it doesn't help that we emit the last two insns above
> within the prologue, so if we simply place the profile before the
> prologue, we'll *still* be splitting the hotfix sequence for 32-bit.
> I think the best thing to do is to diagnose hotfix+profile and generate
> an error. ?I don't think there's anything reasonable we can do.
> In the end I don't think there's anything your AT_TOP macro does that
> PROFILE_BEFORE_PROLOGUE doesn't do just as well.
> r~

This patch implements it by new hook TARGET_PROFILE_BEFORE_PROLOGUE.
This feature is for now just active for win32 i386 targets and is
controlled by internal target macro PROFILE_SUPPORT_BEFORE_PROLOGUE.

2010-07-14  Kai Tietz

	* config/i386/cygming.h (PROFILE_SUPPORT_BEFORE_PROLOGUE): New.
	(MCOUNT_NAME): Win32 specific version.
	* config/i386/cygming.opt (mprofile-top): New option.
	* config/i386/i386.c (ix86_profile_before_prologue):
	New hook.
	(ix86_function_regparm): Handle profiling before
	prologue case.
	(ix86_function_sseregparm): Likewise.
	(ix86_cfun_abi): Likewise.
	(ix86_frame_pointer_required): Likewise.
	(ix86_select_alt_pic_regnum): Likewise.
	(ix86_save_reg): Likewise.
	(ix86_expand_prologue): Likewise.
	Additionally sorry for 32-bit "hotfix" and profile
	code before prologue.
	(x86_function_profiler): Use fprintf instead of fputs for
	assembly output.
	* doc/invoke.texi (mprofile-top): Document option.
	Add documentation.
	* doc/tm.texi: Regenerated.
	* final.c (final_start_function): Replace
	PROFILE_BEFORE_PROLOGUE guard by target hook.
	(profile_after_prologue): Likewise.
	* function.c (thread_prologue_and_epilogue_insns):
	* target.def (profile_before_prologue): New hook.
	* targhook.c (default_profile_before_prologue): New.
	* targhook.h (default_profile_before_prologue): New.

Tested for i686-pc-linux-gnu, i686-pc-mingw32, and x86_64-pc-mingw32.
Ok for apply?


|? (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

Description: Binary data

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