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

login
register
mail settings
Submitter Andi Kleen
Date July 16, 2010, 11:57 p.m.
Message ID <20100716235724.GK7338@basil.fritz.box>
Download mbox | patch
Permalink /patch/59130/
State New
Headers show

Comments

Andi Kleen - July 16, 2010, 11:57 p.m.
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
Kai Tietz - July 17, 2010, 5:33 a.m.
2010/7/17 Andi Kleen <andi@firstfloor.org>:
> 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
>
> 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"
>
> 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
>

Hmm, I can't reproduce this. Clear if PROFILE_BEFORE_PROLOGUE isn't
set, then default remains profile counter call after prologue. But if
you have 'defined(MCOUNT_NAME) && defined
(MCOUNT_NAME_BEFORE_PROLOGUE)' the variable only_default is false, and
so the error you are showing shouldn't be reachable. Do I miss here
something?

Kai

Patch

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"