From patchwork Fri Jul 16 23:57:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [i386] : Add for win32 targets pre-prologue profiling feature Date: Fri, 16 Jul 2010 13:57:24 -0000 From: Andi Kleen X-Patchwork-Id: 59130 Message-Id: <20100716235724.GK7338@basil.fritz.box> To: Kai Tietz Cc: Richard Henderson , Andi Kleen , GCC Patches On Thu, Jul 15, 2010 at 08:08:24PM +0200, Kai Tietz wrote: > Hello Andy, > > I updated my patch in that way, that it should be trivial to add the > counter function for before prologue profiling to linux target by a > one-liner. > Just make sure that for the i386-target the macro > MCOUNT_NAME_BEFORE_PROLOGUE is defined. > > I reworked the patch so that the option is now named -mfentry and it > is available for all i386 targets, if they have defined the counter > function's name via MCOUNT_NAME_BEFORE_PROLOGUE in target. > Additionally I added some option-checks for targets, which don't > support before prologue profiling. Kai, I tried the patch on x86_64-linux but it doesn't work for me. First I added the define to linux But when I try to set -mfentry on a simple test program I get sorry, unimplemented: -mfentry isn't supported for this target I think that's because of +#if defined(PROFILE_BEFORE_PROLOGUE) + default_profile_top_flag = 1; +#endif +#if defined(MCOUNT_NAME) && defined (MCOUNT_NAME_BEFORE_PROLOGUE) + only_default = 0; +#endif + + if (flag_fentry == -1) + flag_fentry = default_profile_top_flag; + else if (flag_fentry != default_profile_top_flag && only_default) + { + if (!default_profile_top_flag) + sorry ("-mfentry isn't supported for this target"); + else + sorry ("-mno-fentry isn't supported for this target"); and PROFILE_BEFORE_PROLOGUE is never set for i386, default_profile_flag is always 0 -Andi 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"