public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add -fno-instrument-function v2
@ 2013-08-10 19:36 Andi Kleen
  2013-09-08 21:05 ` PING " Andi Kleen
  0 siblings, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2013-08-10 19:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

[I posted this originally quite some time ago.
This version fixes all review problems, particularly
it works for C++ too and the test case really works.]

This adds a new C/C++ option to force
__attribute__((no_instrument_function)) on every function compiled.

This is useful together with LTO. You may want to have the whole
program compiled with -pg and have to specify that in the LTO
link, but want to disable it for some specific files. As the
option works on the frontend level it is already passed through
properly by LTO.

Without LTO it is equivalent to not specifing -pg or -mfentry.

This fixes some missing functionality in the Linux kernel LTO port.

Passed bootstrap and test suite on x86_64-linux. Ok?

gcc/:

2013-08-10  Andi Kleen <ak@linux.intel.com>

	* c.opt (fno-instrument-function): Document.

gcc/c:

2013-08-10  Andi Kleen <ak@linux.intel.com>

	* c-decl.c (start_function): Handle force_no_instrument_function

gcc/cp:

2013-08-10  Andi Kleen <ak@linux.intel.com>

	* decl.c (start_preparsed_function): Handle
  	force_no_instrument_function

gcc/testsuite:

2013-08-10  Andi Kleen <ak@linux.intel.com>

	* g++.dg/fno-instrument-function.C: Add.
	* gcc.dg/fno-instrument-function.c: Add.
---
 gcc/c-family/c.opt                             |  4 ++++
 gcc/c/c-decl.c                                 |  3 +++
 gcc/cp/decl.c                                  |  3 +++
 gcc/doc/invoke.texi                            |  8 +++++++-
 gcc/testsuite/g++.dg/fno-instrument-function.C | 18 ++++++++++++++++++
 gcc/testsuite/gcc.dg/fno-instrument-function.c | 24 ++++++++++++++++++++++++
 6 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/fno-instrument-function.C
 create mode 100644 gcc/testsuite/gcc.dg/fno-instrument-function.c

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 10ae84d..2159f89 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1014,6 +1014,10 @@ fnil-receivers
 ObjC ObjC++ Var(flag_nil_receivers) Init(1)
 Assume that receivers of Objective-C messages may be nil
 
+fno-instrument-function
+C C++ ObjC ObjC++ RejectNegative Report Var(force_no_instrument_function)
+Force __attribute__((no_instrument_function)) for all functions in translation unit.
+
 fnonansi-builtins
 C++ ObjC++ Var(flag_no_nonansi_builtin, 0)
 
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index d9bbf5c..15717a9 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -7876,6 +7876,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
   if (current_scope == file_scope)
     maybe_apply_pragma_weak (decl1);
 
+  if (force_no_instrument_function)
+    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;  
+
   /* Warn for unlikely, improbable, or stupid declarations of `main'.  */
   if (warn_main && MAIN_NAME_P (DECL_NAME (decl1)))
     {
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 01804d2..103188b 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13023,6 +13023,9 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
       && lookup_attribute ("noinline", attrs))
     warning (0, "inline function %q+D given attribute noinline", decl1);
 
+  if (force_no_instrument_function)
+    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;
+
   /* Handle gnu_inline attribute.  */
   if (GNU_INLINE_P (decl1))
     {
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 782b569..bc20a77 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -169,7 +169,7 @@ in the following sections.
 -aux-info @var{filename} -fallow-parameterless-variadic-functions @gol
 -fno-asm  -fno-builtin  -fno-builtin-@var{function} @gol
 -fhosted  -ffreestanding -fopenmp -fms-extensions -fplan9-extensions @gol
--trigraphs  -traditional  -traditional-cpp @gol
+-trigraphs  -traditional  -traditional-cpp -fno-instrument-function @gol
 -fallow-single-precision  -fcond-mismatch -flax-vector-conversions @gol
 -fsigned-bitfields  -fsigned-char @gol
 -funsigned-bitfields  -funsigned-char}
@@ -1868,6 +1868,12 @@ Allow implicit conversions between vectors with differing numbers of
 elements and/or incompatible element types.  This option should not be
 used for new code.
 
+@item -fno-instrument-function
+@opindex fno-instrument-function
+Override @option{-pg} for this translation unit. This is useful with
+Link Time Optimization (LTO) to override the effects of -pg for a 
+specific source file.
+
 @item -funsigned-char
 @opindex funsigned-char
 Let the type @code{char} be unsigned, like @code{unsigned char}.
diff --git a/gcc/testsuite/g++.dg/fno-instrument-function.C b/gcc/testsuite/g++.dg/fno-instrument-function.C
new file mode 100644
index 0000000..e2f6518
--- /dev/null
+++ b/gcc/testsuite/g++.dg/fno-instrument-function.C
@@ -0,0 +1,18 @@
+/* Test -fno-instrument-function */
+/* { dg-do compile } */
+/* { dg-options "-pg -fno-instrument-function" } */
+/* { dg-final { scan-assembler-not "mcount" } } */
+/* Origin: Andi Kleen */
+extern void foobar(const char *);
+
+void func(void)
+{
+  foobar ("Hello world\n");
+}
+
+void func2(void)
+{
+  int i;
+  for (i = 0; i < 10; i++)
+    foobar ("Hello world");
+}
diff --git a/gcc/testsuite/gcc.dg/fno-instrument-function.c b/gcc/testsuite/gcc.dg/fno-instrument-function.c
new file mode 100644
index 0000000..9c68fa8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fno-instrument-function.c
@@ -0,0 +1,24 @@
+/* Test -fno-instrument-function */
+/* { dg-do compile } */
+/* { dg-options "-pg -fno-instrument-function" } */
+/* { dg-final { scan-assembler-not "mcount" } } */
+/* Origin: Andi Kleen */
+extern void foobar(char *);
+
+void func(void)
+{
+  foobar ("Hello world\n");
+}
+
+void func2(void)
+{
+  int i;
+  for (i = 0; i < 10; i++)
+    foobar ("Hello world");
+}
+
+void func3(a)
+char *a;
+{
+  foobar("Hello world");
+}
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* PING Re: [PATCH] Add -fno-instrument-function v2
  2013-08-10 19:36 [PATCH] Add -fno-instrument-function v2 Andi Kleen
@ 2013-09-08 21:05 ` Andi Kleen
  2013-10-07 23:00   ` PING^2 " Andi Kleen
  0 siblings, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2013-09-08 21:05 UTC (permalink / raw)
  To: gcc-patches; +Cc: hubicka

Andi Kleen <andi@firstfloor.org> writes:

> From: Andi Kleen <ak@linux.intel.com>
>
> [I posted this originally quite some time ago.
> This version fixes all review problems, particularly
> it works for C++ too and the test case really works.]

Ping!

Could someone please review it.

Note this might be obsolete with Honza's LTO option work, but if it's
not covered in his first iteration I would still have it earlier for the
Linux kernel LTO build (fixed ftrace)

-Andi

> This adds a new C/C++ option to force
> __attribute__((no_instrument_function)) on every function compiled.
>
> This is useful together with LTO. You may want to have the whole
> program compiled with -pg and have to specify that in the LTO
> link, but want to disable it for some specific files. As the
> option works on the frontend level it is already passed through
> properly by LTO.
>
> Without LTO it is equivalent to not specifing -pg or -mfentry.
>
> This fixes some missing functionality in the Linux kernel LTO port.
>
> Passed bootstrap and test suite on x86_64-linux. Ok?
>
> gcc/:
>
> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>
> 	* c.opt (fno-instrument-function): Document.
>
> gcc/c:
>
> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>
> 	* c-decl.c (start_function): Handle force_no_instrument_function
>
> gcc/cp:
>
> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>
> 	* decl.c (start_preparsed_function): Handle
>   	force_no_instrument_function
>
> gcc/testsuite:
>
> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>
> 	* g++.dg/fno-instrument-function.C: Add.
> 	* gcc.dg/fno-instrument-function.c: Add.
> ---
>  gcc/c-family/c.opt                             |  4 ++++
>  gcc/c/c-decl.c                                 |  3 +++
>  gcc/cp/decl.c                                  |  3 +++
>  gcc/doc/invoke.texi                            |  8 +++++++-
>  gcc/testsuite/g++.dg/fno-instrument-function.C | 18 ++++++++++++++++++
>  gcc/testsuite/gcc.dg/fno-instrument-function.c | 24 ++++++++++++++++++++++++
>  6 files changed, 59 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/fno-instrument-function.C
>  create mode 100644 gcc/testsuite/gcc.dg/fno-instrument-function.c
>
> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
> index 10ae84d..2159f89 100644
> --- a/gcc/c-family/c.opt
> +++ b/gcc/c-family/c.opt
> @@ -1014,6 +1014,10 @@ fnil-receivers
>  ObjC ObjC++ Var(flag_nil_receivers) Init(1)
>  Assume that receivers of Objective-C messages may be nil
>  
> +fno-instrument-function
> +C C++ ObjC ObjC++ RejectNegative Report Var(force_no_instrument_function)
> +Force __attribute__((no_instrument_function)) for all functions in translation unit.
> +
>  fnonansi-builtins
>  C++ ObjC++ Var(flag_no_nonansi_builtin, 0)
>  
> diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
> index d9bbf5c..15717a9 100644
> --- a/gcc/c/c-decl.c
> +++ b/gcc/c/c-decl.c
> @@ -7876,6 +7876,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
>    if (current_scope == file_scope)
>      maybe_apply_pragma_weak (decl1);
>  
> +  if (force_no_instrument_function)
> +    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;  
> +
>    /* Warn for unlikely, improbable, or stupid declarations of `main'.  */
>    if (warn_main && MAIN_NAME_P (DECL_NAME (decl1)))
>      {
> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> index 01804d2..103188b 100644
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -13023,6 +13023,9 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
>        && lookup_attribute ("noinline", attrs))
>      warning (0, "inline function %q+D given attribute noinline", decl1);
>  
> +  if (force_no_instrument_function)
> +    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;
> +
>    /* Handle gnu_inline attribute.  */
>    if (GNU_INLINE_P (decl1))
>      {
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 782b569..bc20a77 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -169,7 +169,7 @@ in the following sections.
>  -aux-info @var{filename} -fallow-parameterless-variadic-functions @gol
>  -fno-asm  -fno-builtin  -fno-builtin-@var{function} @gol
>  -fhosted  -ffreestanding -fopenmp -fms-extensions -fplan9-extensions @gol
> --trigraphs  -traditional  -traditional-cpp @gol
> +-trigraphs  -traditional  -traditional-cpp -fno-instrument-function @gol
>  -fallow-single-precision  -fcond-mismatch -flax-vector-conversions @gol
>  -fsigned-bitfields  -fsigned-char @gol
>  -funsigned-bitfields  -funsigned-char}
> @@ -1868,6 +1868,12 @@ Allow implicit conversions between vectors with differing numbers of
>  elements and/or incompatible element types.  This option should not be
>  used for new code.
>  
> +@item -fno-instrument-function
> +@opindex fno-instrument-function
> +Override @option{-pg} for this translation unit. This is useful with
> +Link Time Optimization (LTO) to override the effects of -pg for a 
> +specific source file.
> +
>  @item -funsigned-char
>  @opindex funsigned-char
>  Let the type @code{char} be unsigned, like @code{unsigned char}.
> diff --git a/gcc/testsuite/g++.dg/fno-instrument-function.C b/gcc/testsuite/g++.dg/fno-instrument-function.C
> new file mode 100644
> index 0000000..e2f6518
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/fno-instrument-function.C
> @@ -0,0 +1,18 @@
> +/* Test -fno-instrument-function */
> +/* { dg-do compile } */
> +/* { dg-options "-pg -fno-instrument-function" } */
> +/* { dg-final { scan-assembler-not "mcount" } } */
> +/* Origin: Andi Kleen */
> +extern void foobar(const char *);
> +
> +void func(void)
> +{
> +  foobar ("Hello world\n");
> +}
> +
> +void func2(void)
> +{
> +  int i;
> +  for (i = 0; i < 10; i++)
> +    foobar ("Hello world");
> +}
> diff --git a/gcc/testsuite/gcc.dg/fno-instrument-function.c b/gcc/testsuite/gcc.dg/fno-instrument-function.c
> new file mode 100644
> index 0000000..9c68fa8
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/fno-instrument-function.c
> @@ -0,0 +1,24 @@
> +/* Test -fno-instrument-function */
> +/* { dg-do compile } */
> +/* { dg-options "-pg -fno-instrument-function" } */
> +/* { dg-final { scan-assembler-not "mcount" } } */
> +/* Origin: Andi Kleen */
> +extern void foobar(char *);
> +
> +void func(void)
> +{
> +  foobar ("Hello world\n");
> +}
> +
> +void func2(void)
> +{
> +  int i;
> +  for (i = 0; i < 10; i++)
> +    foobar ("Hello world");
> +}
> +
> +void func3(a)
> +char *a;
> +{
> +  foobar("Hello world");
> +}

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PING^2 Re: [PATCH] Add -fno-instrument-function v2
  2013-09-08 21:05 ` PING " Andi Kleen
@ 2013-10-07 23:00   ` Andi Kleen
  2013-11-11 14:46     ` PING^3 " Andi Kleen
  0 siblings, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2013-10-07 23:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: hubicka

Andi Kleen <andi@firstfloor.org> writes:

PING^2

> Andi Kleen <andi@firstfloor.org> writes:
>
>> From: Andi Kleen <ak@linux.intel.com>
>>
>> [I posted this originally quite some time ago.
>> This version fixes all review problems, particularly
>> it works for C++ too and the test case really works.]
>
> Ping!
>
> Could someone please review it.
>
> Note this might be obsolete with Honza's LTO option work, but if it's
> not covered in his first iteration I would still have it earlier for the
> Linux kernel LTO build (fixed ftrace)
>
> -Andi
>
>> This adds a new C/C++ option to force
>> __attribute__((no_instrument_function)) on every function compiled.
>>
>> This is useful together with LTO. You may want to have the whole
>> program compiled with -pg and have to specify that in the LTO
>> link, but want to disable it for some specific files. As the
>> option works on the frontend level it is already passed through
>> properly by LTO.
>>
>> Without LTO it is equivalent to not specifing -pg or -mfentry.
>>
>> This fixes some missing functionality in the Linux kernel LTO port.
>>
>> Passed bootstrap and test suite on x86_64-linux. Ok?
>>
>> gcc/:
>>
>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>
>> 	* c.opt (fno-instrument-function): Document.
>>
>> gcc/c:
>>
>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>
>> 	* c-decl.c (start_function): Handle force_no_instrument_function
>>
>> gcc/cp:
>>
>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>
>> 	* decl.c (start_preparsed_function): Handle
>>   	force_no_instrument_function
>>
>> gcc/testsuite:
>>
>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>
>> 	* g++.dg/fno-instrument-function.C: Add.
>> 	* gcc.dg/fno-instrument-function.c: Add.
>> ---
>>  gcc/c-family/c.opt                             |  4 ++++
>>  gcc/c/c-decl.c                                 |  3 +++
>>  gcc/cp/decl.c                                  |  3 +++
>>  gcc/doc/invoke.texi                            |  8 +++++++-
>>  gcc/testsuite/g++.dg/fno-instrument-function.C | 18 ++++++++++++++++++
>>  gcc/testsuite/gcc.dg/fno-instrument-function.c | 24 ++++++++++++++++++++++++
>>  6 files changed, 59 insertions(+), 1 deletion(-)
>>  create mode 100644 gcc/testsuite/g++.dg/fno-instrument-function.C
>>  create mode 100644 gcc/testsuite/gcc.dg/fno-instrument-function.c
>>
>> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
>> index 10ae84d..2159f89 100644
>> --- a/gcc/c-family/c.opt
>> +++ b/gcc/c-family/c.opt
>> @@ -1014,6 +1014,10 @@ fnil-receivers
>>  ObjC ObjC++ Var(flag_nil_receivers) Init(1)
>>  Assume that receivers of Objective-C messages may be nil
>>  
>> +fno-instrument-function
>> +C C++ ObjC ObjC++ RejectNegative Report Var(force_no_instrument_function)
>> +Force __attribute__((no_instrument_function)) for all functions in translation unit.
>> +
>>  fnonansi-builtins
>>  C++ ObjC++ Var(flag_no_nonansi_builtin, 0)
>>  
>> diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
>> index d9bbf5c..15717a9 100644
>> --- a/gcc/c/c-decl.c
>> +++ b/gcc/c/c-decl.c
>> @@ -7876,6 +7876,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
>>    if (current_scope == file_scope)
>>      maybe_apply_pragma_weak (decl1);
>>  
>> +  if (force_no_instrument_function)
>> +    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;  
>> +
>>    /* Warn for unlikely, improbable, or stupid declarations of `main'.  */
>>    if (warn_main && MAIN_NAME_P (DECL_NAME (decl1)))
>>      {
>> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
>> index 01804d2..103188b 100644
>> --- a/gcc/cp/decl.c
>> +++ b/gcc/cp/decl.c
>> @@ -13023,6 +13023,9 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
>>        && lookup_attribute ("noinline", attrs))
>>      warning (0, "inline function %q+D given attribute noinline", decl1);
>>  
>> +  if (force_no_instrument_function)
>> +    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;
>> +
>>    /* Handle gnu_inline attribute.  */
>>    if (GNU_INLINE_P (decl1))
>>      {
>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>> index 782b569..bc20a77 100644
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -169,7 +169,7 @@ in the following sections.
>>  -aux-info @var{filename} -fallow-parameterless-variadic-functions @gol
>>  -fno-asm  -fno-builtin  -fno-builtin-@var{function} @gol
>>  -fhosted  -ffreestanding -fopenmp -fms-extensions -fplan9-extensions @gol
>> --trigraphs  -traditional  -traditional-cpp @gol
>> +-trigraphs  -traditional  -traditional-cpp -fno-instrument-function @gol
>>  -fallow-single-precision  -fcond-mismatch -flax-vector-conversions @gol
>>  -fsigned-bitfields  -fsigned-char @gol
>>  -funsigned-bitfields  -funsigned-char}
>> @@ -1868,6 +1868,12 @@ Allow implicit conversions between vectors with differing numbers of
>>  elements and/or incompatible element types.  This option should not be
>>  used for new code.
>>  
>> +@item -fno-instrument-function
>> +@opindex fno-instrument-function
>> +Override @option{-pg} for this translation unit. This is useful with
>> +Link Time Optimization (LTO) to override the effects of -pg for a 
>> +specific source file.
>> +
>>  @item -funsigned-char
>>  @opindex funsigned-char
>>  Let the type @code{char} be unsigned, like @code{unsigned char}.
>> diff --git a/gcc/testsuite/g++.dg/fno-instrument-function.C b/gcc/testsuite/g++.dg/fno-instrument-function.C
>> new file mode 100644
>> index 0000000..e2f6518
>> --- /dev/null
>> +++ b/gcc/testsuite/g++.dg/fno-instrument-function.C
>> @@ -0,0 +1,18 @@
>> +/* Test -fno-instrument-function */
>> +/* { dg-do compile } */
>> +/* { dg-options "-pg -fno-instrument-function" } */
>> +/* { dg-final { scan-assembler-not "mcount" } } */
>> +/* Origin: Andi Kleen */
>> +extern void foobar(const char *);
>> +
>> +void func(void)
>> +{
>> +  foobar ("Hello world\n");
>> +}
>> +
>> +void func2(void)
>> +{
>> +  int i;
>> +  for (i = 0; i < 10; i++)
>> +    foobar ("Hello world");
>> +}
>> diff --git a/gcc/testsuite/gcc.dg/fno-instrument-function.c b/gcc/testsuite/gcc.dg/fno-instrument-function.c
>> new file mode 100644
>> index 0000000..9c68fa8
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/fno-instrument-function.c
>> @@ -0,0 +1,24 @@
>> +/* Test -fno-instrument-function */
>> +/* { dg-do compile } */
>> +/* { dg-options "-pg -fno-instrument-function" } */
>> +/* { dg-final { scan-assembler-not "mcount" } } */
>> +/* Origin: Andi Kleen */
>> +extern void foobar(char *);
>> +
>> +void func(void)
>> +{
>> +  foobar ("Hello world\n");
>> +}
>> +
>> +void func2(void)
>> +{
>> +  int i;
>> +  for (i = 0; i < 10; i++)
>> +    foobar ("Hello world");
>> +}
>> +
>> +void func3(a)
>> +char *a;
>> +{
>> +  foobar("Hello world");
>> +}

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PING^3 Re: [PATCH] Add -fno-instrument-function v2
  2013-10-07 23:00   ` PING^2 " Andi Kleen
@ 2013-11-11 14:46     ` Andi Kleen
  2013-11-23  5:22       ` PING^4 " Andi Kleen
  0 siblings, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2013-11-11 14:46 UTC (permalink / raw)
  To: gcc-patches; +Cc: hubicka

Andi Kleen <andi@firstfloor.org> writes:


PING^3

Since it doesn't look like a generic solution for the
LTO options problem will appear this development cycle,
I would still like to pursue this option for 4.9.
This would help fixing parts of the linux kernel LTO
build.

Can someone please review the patch?

Thanks

> Andi Kleen <andi@firstfloor.org> writes:
>
> PING^2
>
>> Andi Kleen <andi@firstfloor.org> writes:
>>
>>> From: Andi Kleen <ak@linux.intel.com>
>>>
>>> [I posted this originally quite some time ago.
>>> This version fixes all review problems, particularly
>>> it works for C++ too and the test case really works.]
>>
>> Ping!
>>
>> Could someone please review it.
>>
>> Note this might be obsolete with Honza's LTO option work, but if it's
>> not covered in his first iteration I would still have it earlier for the
>> Linux kernel LTO build (fixed ftrace)
>>
>> -Andi
>>
>>> This adds a new C/C++ option to force
>>> __attribute__((no_instrument_function)) on every function compiled.
>>>
>>> This is useful together with LTO. You may want to have the whole
>>> program compiled with -pg and have to specify that in the LTO
>>> link, but want to disable it for some specific files. As the
>>> option works on the frontend level it is already passed through
>>> properly by LTO.
>>>
>>> Without LTO it is equivalent to not specifing -pg or -mfentry.
>>>
>>> This fixes some missing functionality in the Linux kernel LTO port.
>>>
>>> Passed bootstrap and test suite on x86_64-linux. Ok?
>>>
>>> gcc/:
>>>
>>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>>
>>> 	* c.opt (fno-instrument-function): Document.
>>>
>>> gcc/c:
>>>
>>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>>
>>> 	* c-decl.c (start_function): Handle force_no_instrument_function
>>>
>>> gcc/cp:
>>>
>>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>>
>>> 	* decl.c (start_preparsed_function): Handle
>>>   	force_no_instrument_function
>>>
>>> gcc/testsuite:
>>>
>>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>>
>>> 	* g++.dg/fno-instrument-function.C: Add.
>>> 	* gcc.dg/fno-instrument-function.c: Add.
>>> ---
>>>  gcc/c-family/c.opt                             |  4 ++++
>>>  gcc/c/c-decl.c                                 |  3 +++
>>>  gcc/cp/decl.c                                  |  3 +++
>>>  gcc/doc/invoke.texi                            |  8 +++++++-
>>>  gcc/testsuite/g++.dg/fno-instrument-function.C | 18 ++++++++++++++++++
>>>  gcc/testsuite/gcc.dg/fno-instrument-function.c | 24 ++++++++++++++++++++++++
>>>  6 files changed, 59 insertions(+), 1 deletion(-)
>>>  create mode 100644 gcc/testsuite/g++.dg/fno-instrument-function.C
>>>  create mode 100644 gcc/testsuite/gcc.dg/fno-instrument-function.c
>>>
>>> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
>>> index 10ae84d..2159f89 100644
>>> --- a/gcc/c-family/c.opt
>>> +++ b/gcc/c-family/c.opt
>>> @@ -1014,6 +1014,10 @@ fnil-receivers
>>>  ObjC ObjC++ Var(flag_nil_receivers) Init(1)
>>>  Assume that receivers of Objective-C messages may be nil
>>>  
>>> +fno-instrument-function
>>> +C C++ ObjC ObjC++ RejectNegative Report Var(force_no_instrument_function)
>>> +Force __attribute__((no_instrument_function)) for all functions in translation unit.
>>> +
>>>  fnonansi-builtins
>>>  C++ ObjC++ Var(flag_no_nonansi_builtin, 0)
>>>  
>>> diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
>>> index d9bbf5c..15717a9 100644
>>> --- a/gcc/c/c-decl.c
>>> +++ b/gcc/c/c-decl.c
>>> @@ -7876,6 +7876,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
>>>    if (current_scope == file_scope)
>>>      maybe_apply_pragma_weak (decl1);
>>>  
>>> +  if (force_no_instrument_function)
>>> +    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;  
>>> +
>>>    /* Warn for unlikely, improbable, or stupid declarations of `main'.  */
>>>    if (warn_main && MAIN_NAME_P (DECL_NAME (decl1)))
>>>      {
>>> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
>>> index 01804d2..103188b 100644
>>> --- a/gcc/cp/decl.c
>>> +++ b/gcc/cp/decl.c
>>> @@ -13023,6 +13023,9 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
>>>        && lookup_attribute ("noinline", attrs))
>>>      warning (0, "inline function %q+D given attribute noinline", decl1);
>>>  
>>> +  if (force_no_instrument_function)
>>> +    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;
>>> +
>>>    /* Handle gnu_inline attribute.  */
>>>    if (GNU_INLINE_P (decl1))
>>>      {
>>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>>> index 782b569..bc20a77 100644
>>> --- a/gcc/doc/invoke.texi
>>> +++ b/gcc/doc/invoke.texi
>>> @@ -169,7 +169,7 @@ in the following sections.
>>>  -aux-info @var{filename} -fallow-parameterless-variadic-functions @gol
>>>  -fno-asm  -fno-builtin  -fno-builtin-@var{function} @gol
>>>  -fhosted  -ffreestanding -fopenmp -fms-extensions -fplan9-extensions @gol
>>> --trigraphs  -traditional  -traditional-cpp @gol
>>> +-trigraphs  -traditional  -traditional-cpp -fno-instrument-function @gol
>>>  -fallow-single-precision  -fcond-mismatch -flax-vector-conversions @gol
>>>  -fsigned-bitfields  -fsigned-char @gol
>>>  -funsigned-bitfields  -funsigned-char}
>>> @@ -1868,6 +1868,12 @@ Allow implicit conversions between vectors with differing numbers of
>>>  elements and/or incompatible element types.  This option should not be
>>>  used for new code.
>>>  
>>> +@item -fno-instrument-function
>>> +@opindex fno-instrument-function
>>> +Override @option{-pg} for this translation unit. This is useful with
>>> +Link Time Optimization (LTO) to override the effects of -pg for a 
>>> +specific source file.
>>> +
>>>  @item -funsigned-char
>>>  @opindex funsigned-char
>>>  Let the type @code{char} be unsigned, like @code{unsigned char}.
>>> diff --git a/gcc/testsuite/g++.dg/fno-instrument-function.C b/gcc/testsuite/g++.dg/fno-instrument-function.C
>>> new file mode 100644
>>> index 0000000..e2f6518
>>> --- /dev/null
>>> +++ b/gcc/testsuite/g++.dg/fno-instrument-function.C
>>> @@ -0,0 +1,18 @@
>>> +/* Test -fno-instrument-function */
>>> +/* { dg-do compile } */
>>> +/* { dg-options "-pg -fno-instrument-function" } */
>>> +/* { dg-final { scan-assembler-not "mcount" } } */
>>> +/* Origin: Andi Kleen */
>>> +extern void foobar(const char *);
>>> +
>>> +void func(void)
>>> +{
>>> +  foobar ("Hello world\n");
>>> +}
>>> +
>>> +void func2(void)
>>> +{
>>> +  int i;
>>> +  for (i = 0; i < 10; i++)
>>> +    foobar ("Hello world");
>>> +}
>>> diff --git a/gcc/testsuite/gcc.dg/fno-instrument-function.c b/gcc/testsuite/gcc.dg/fno-instrument-function.c
>>> new file mode 100644
>>> index 0000000..9c68fa8
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.dg/fno-instrument-function.c
>>> @@ -0,0 +1,24 @@
>>> +/* Test -fno-instrument-function */
>>> +/* { dg-do compile } */
>>> +/* { dg-options "-pg -fno-instrument-function" } */
>>> +/* { dg-final { scan-assembler-not "mcount" } } */
>>> +/* Origin: Andi Kleen */
>>> +extern void foobar(char *);
>>> +
>>> +void func(void)
>>> +{
>>> +  foobar ("Hello world\n");
>>> +}
>>> +
>>> +void func2(void)
>>> +{
>>> +  int i;
>>> +  for (i = 0; i < 10; i++)
>>> +    foobar ("Hello world");
>>> +}
>>> +
>>> +void func3(a)
>>> +char *a;
>>> +{
>>> +  foobar("Hello world");
>>> +}

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PING^4 Re: [PATCH] Add -fno-instrument-function v2
  2013-11-11 14:46     ` PING^3 " Andi Kleen
@ 2013-11-23  5:22       ` Andi Kleen
  0 siblings, 0 replies; 5+ messages in thread
From: Andi Kleen @ 2013-11-23  5:22 UTC (permalink / raw)
  To: gcc-patches; +Cc: hubicka

Andi Kleen <andi@firstfloor.org> writes:

PING^4 if it isn't already too late for 4.9.

> Andi Kleen <andi@firstfloor.org> writes:
>
>
> PING^3
>
> Since it doesn't look like a generic solution for the
> LTO options problem will appear this development cycle,
> I would still like to pursue this option for 4.9.
> This would help fixing parts of the linux kernel LTO
> build.
>
> Can someone please review the patch?
>
> Thanks
>
>> Andi Kleen <andi@firstfloor.org> writes:
>>
>> PING^2
>>
>>> Andi Kleen <andi@firstfloor.org> writes:
>>>
>>>> From: Andi Kleen <ak@linux.intel.com>
>>>>
>>>> [I posted this originally quite some time ago.
>>>> This version fixes all review problems, particularly
>>>> it works for C++ too and the test case really works.]
>>>
>>> Ping!
>>>
>>> Could someone please review it.
>>>
>>> Note this might be obsolete with Honza's LTO option work, but if it's
>>> not covered in his first iteration I would still have it earlier for the
>>> Linux kernel LTO build (fixed ftrace)
>>>
>>> -Andi
>>>
>>>> This adds a new C/C++ option to force
>>>> __attribute__((no_instrument_function)) on every function compiled.
>>>>
>>>> This is useful together with LTO. You may want to have the whole
>>>> program compiled with -pg and have to specify that in the LTO
>>>> link, but want to disable it for some specific files. As the
>>>> option works on the frontend level it is already passed through
>>>> properly by LTO.
>>>>
>>>> Without LTO it is equivalent to not specifing -pg or -mfentry.
>>>>
>>>> This fixes some missing functionality in the Linux kernel LTO port.
>>>>
>>>> Passed bootstrap and test suite on x86_64-linux. Ok?
>>>>
>>>> gcc/:
>>>>
>>>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>>>
>>>> 	* c.opt (fno-instrument-function): Document.
>>>>
>>>> gcc/c:
>>>>
>>>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>>>
>>>> 	* c-decl.c (start_function): Handle force_no_instrument_function
>>>>
>>>> gcc/cp:
>>>>
>>>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>>>
>>>> 	* decl.c (start_preparsed_function): Handle
>>>>   	force_no_instrument_function
>>>>
>>>> gcc/testsuite:
>>>>
>>>> 2013-08-10  Andi Kleen <ak@linux.intel.com>
>>>>
>>>> 	* g++.dg/fno-instrument-function.C: Add.
>>>> 	* gcc.dg/fno-instrument-function.c: Add.
>>>> ---
>>>>  gcc/c-family/c.opt                             |  4 ++++
>>>>  gcc/c/c-decl.c                                 |  3 +++
>>>>  gcc/cp/decl.c                                  |  3 +++
>>>>  gcc/doc/invoke.texi                            |  8 +++++++-
>>>>  gcc/testsuite/g++.dg/fno-instrument-function.C | 18 ++++++++++++++++++
>>>>  gcc/testsuite/gcc.dg/fno-instrument-function.c | 24 ++++++++++++++++++++++++
>>>>  6 files changed, 59 insertions(+), 1 deletion(-)
>>>>  create mode 100644 gcc/testsuite/g++.dg/fno-instrument-function.C
>>>>  create mode 100644 gcc/testsuite/gcc.dg/fno-instrument-function.c
>>>>
>>>> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
>>>> index 10ae84d..2159f89 100644
>>>> --- a/gcc/c-family/c.opt
>>>> +++ b/gcc/c-family/c.opt
>>>> @@ -1014,6 +1014,10 @@ fnil-receivers
>>>>  ObjC ObjC++ Var(flag_nil_receivers) Init(1)
>>>>  Assume that receivers of Objective-C messages may be nil
>>>>  
>>>> +fno-instrument-function
>>>> +C C++ ObjC ObjC++ RejectNegative Report Var(force_no_instrument_function)
>>>> +Force __attribute__((no_instrument_function)) for all functions in translation unit.
>>>> +
>>>>  fnonansi-builtins
>>>>  C++ ObjC++ Var(flag_no_nonansi_builtin, 0)
>>>>  
>>>> diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
>>>> index d9bbf5c..15717a9 100644
>>>> --- a/gcc/c/c-decl.c
>>>> +++ b/gcc/c/c-decl.c
>>>> @@ -7876,6 +7876,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
>>>>    if (current_scope == file_scope)
>>>>      maybe_apply_pragma_weak (decl1);
>>>>  
>>>> +  if (force_no_instrument_function)
>>>> +    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;  
>>>> +
>>>>    /* Warn for unlikely, improbable, or stupid declarations of `main'.  */
>>>>    if (warn_main && MAIN_NAME_P (DECL_NAME (decl1)))
>>>>      {
>>>> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
>>>> index 01804d2..103188b 100644
>>>> --- a/gcc/cp/decl.c
>>>> +++ b/gcc/cp/decl.c
>>>> @@ -13023,6 +13023,9 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
>>>>        && lookup_attribute ("noinline", attrs))
>>>>      warning (0, "inline function %q+D given attribute noinline", decl1);
>>>>  
>>>> +  if (force_no_instrument_function)
>>>> +    DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl1) = 1;
>>>> +
>>>>    /* Handle gnu_inline attribute.  */
>>>>    if (GNU_INLINE_P (decl1))
>>>>      {
>>>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>>>> index 782b569..bc20a77 100644
>>>> --- a/gcc/doc/invoke.texi
>>>> +++ b/gcc/doc/invoke.texi
>>>> @@ -169,7 +169,7 @@ in the following sections.
>>>>  -aux-info @var{filename} -fallow-parameterless-variadic-functions @gol
>>>>  -fno-asm  -fno-builtin  -fno-builtin-@var{function} @gol
>>>>  -fhosted  -ffreestanding -fopenmp -fms-extensions -fplan9-extensions @gol
>>>> --trigraphs  -traditional  -traditional-cpp @gol
>>>> +-trigraphs  -traditional  -traditional-cpp -fno-instrument-function @gol
>>>>  -fallow-single-precision  -fcond-mismatch -flax-vector-conversions @gol
>>>>  -fsigned-bitfields  -fsigned-char @gol
>>>>  -funsigned-bitfields  -funsigned-char}
>>>> @@ -1868,6 +1868,12 @@ Allow implicit conversions between vectors with differing numbers of
>>>>  elements and/or incompatible element types.  This option should not be
>>>>  used for new code.
>>>>  
>>>> +@item -fno-instrument-function
>>>> +@opindex fno-instrument-function
>>>> +Override @option{-pg} for this translation unit. This is useful with
>>>> +Link Time Optimization (LTO) to override the effects of -pg for a 
>>>> +specific source file.
>>>> +
>>>>  @item -funsigned-char
>>>>  @opindex funsigned-char
>>>>  Let the type @code{char} be unsigned, like @code{unsigned char}.
>>>> diff --git a/gcc/testsuite/g++.dg/fno-instrument-function.C b/gcc/testsuite/g++.dg/fno-instrument-function.C
>>>> new file mode 100644
>>>> index 0000000..e2f6518
>>>> --- /dev/null
>>>> +++ b/gcc/testsuite/g++.dg/fno-instrument-function.C
>>>> @@ -0,0 +1,18 @@
>>>> +/* Test -fno-instrument-function */
>>>> +/* { dg-do compile } */
>>>> +/* { dg-options "-pg -fno-instrument-function" } */
>>>> +/* { dg-final { scan-assembler-not "mcount" } } */
>>>> +/* Origin: Andi Kleen */
>>>> +extern void foobar(const char *);
>>>> +
>>>> +void func(void)
>>>> +{
>>>> +  foobar ("Hello world\n");
>>>> +}
>>>> +
>>>> +void func2(void)
>>>> +{
>>>> +  int i;
>>>> +  for (i = 0; i < 10; i++)
>>>> +    foobar ("Hello world");
>>>> +}
>>>> diff --git a/gcc/testsuite/gcc.dg/fno-instrument-function.c b/gcc/testsuite/gcc.dg/fno-instrument-function.c
>>>> new file mode 100644
>>>> index 0000000..9c68fa8
>>>> --- /dev/null
>>>> +++ b/gcc/testsuite/gcc.dg/fno-instrument-function.c
>>>> @@ -0,0 +1,24 @@
>>>> +/* Test -fno-instrument-function */
>>>> +/* { dg-do compile } */
>>>> +/* { dg-options "-pg -fno-instrument-function" } */
>>>> +/* { dg-final { scan-assembler-not "mcount" } } */
>>>> +/* Origin: Andi Kleen */
>>>> +extern void foobar(char *);
>>>> +
>>>> +void func(void)
>>>> +{
>>>> +  foobar ("Hello world\n");
>>>> +}
>>>> +
>>>> +void func2(void)
>>>> +{
>>>> +  int i;
>>>> +  for (i = 0; i < 10; i++)
>>>> +    foobar ("Hello world");
>>>> +}
>>>> +
>>>> +void func3(a)
>>>> +char *a;
>>>> +{
>>>> +  foobar("Hello world");
>>>> +}

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-22 21:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-10 19:36 [PATCH] Add -fno-instrument-function v2 Andi Kleen
2013-09-08 21:05 ` PING " Andi Kleen
2013-10-07 23:00   ` PING^2 " Andi Kleen
2013-11-11 14:46     ` PING^3 " Andi Kleen
2013-11-23  5:22       ` PING^4 " Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).