Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-19 Thread Andi Kleen

This is the patch I committed. Should fix everyone's issues.

Fix mcount test cases to only run on supported targets

   * gcc.dg/pg-override.c: Only run on x86 Linux.
   * gcc.dg/pg.c: Dito.
   * gcc.target/i386/fentry-override.c: Exclude for PIC.
   * gcc.target/i386/fentry.c: Dito.

diff --git a/gcc/testsuite/gcc.dg/pg-override.c 
b/gcc/testsuite/gcc.dg/pg-override.c
index 60be162..9b8d8fa 100644
--- a/gcc/testsuite/gcc.dg/pg-override.c
+++ b/gcc/testsuite/gcc.dg/pg-override.c
@@ -1,6 +1,6 @@
 /* Test -fprofile override */
 /* { dg-do compile } */
-/* { dg-options -fprofile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options -fprofile { target i?86-*-linux* x86_64-*-linux* } } */
 /* { dg-final { scan-assembler-not mcount } } */
 /* Origin: Andi Kleen */
 extern void foobar(const char *);
diff --git a/gcc/testsuite/gcc.dg/pg.c b/gcc/testsuite/gcc.dg/pg.c
index 60be162..9b8d8fa 100644
--- a/gcc/testsuite/gcc.dg/pg.c
+++ b/gcc/testsuite/gcc.dg/pg.c
@@ -1,6 +1,6 @@
 /* Test -fprofile override */
 /* { dg-do compile } */
-/* { dg-options -fprofile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options -fprofile { target i?86-*-linux* x86_64-*-linux* } } */
 /* { dg-final { scan-assembler-not mcount } } */
 /* Origin: Andi Kleen */
 extern void foobar(const char *);
diff --git a/gcc/testsuite/gcc.target/i386/fentry-override.c 
b/gcc/testsuite/gcc.target/i386/fentry-override.c
index 3771f19..0464454 100644
--- a/gcc/testsuite/gcc.target/i386/fentry-override.c
+++ b/gcc/testsuite/gcc.target/i386/fentry-override.c
@@ -1,5 +1,5 @@
 /* Test -mfentry override */
-/* { dg-do compile } */
+/* { dg-do compile { target { *-*-linux* }  { nonpic || ! { ia32 } } } } */
 /* { dg-options -mfentry } */
 /* { dg-final { scan-assembler-not __fentry__ } } */
 /* Origin: Andi Kleen */
diff --git a/gcc/testsuite/gcc.target/i386/fentry.c 
b/gcc/testsuite/gcc.target/i386/fentry.c
index bd3db13..d0d70c6 100644
--- a/gcc/testsuite/gcc.target/i386/fentry.c
+++ b/gcc/testsuite/gcc.target/i386/fentry.c
@@ -1,5 +1,5 @@
 /* Test -mfentry */
-/* { dg-do compile } */
+/* { dg-do compile { target { *-*-linux* }  { nonpic || ! { ia32 } } } } */
 /* { dg-options -fprofile -mfentry } */
 /* { dg-final { scan-assembler __fentry__ } } */
 /* Origin: Andi Kleen */

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


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-17 Thread Dominique Dhumieres

On darwin I get

FAIL: gcc.target/i386/fentry-override.c (test for excess errors)
UNRESOLVED: gcc.target/i386/fentry-override.c scan-assembler-not __fentry__
FAIL: gcc.target/i386/fentry.c (test for excess errors)
UNRESOLVED: gcc.target/i386/fentry.c scan-assembler __fentry__

with -m32. The error is

sorry, unimplemented: -mfentry isn't supported for 32-bit in combination with 
-fpic

With -m64 I get

FAIL: gcc.target/i386/fentry.c scan-assembler __fentry__

with no string 'entry' in the fentry.s file.

TIA

Dominique


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-17 Thread Andi Kleen
On Wed, Sep 17, 2014 at 03:42:37PM +0200, Dominique Dhumieres wrote:
 
 On darwin I get
 
 FAIL: gcc.target/i386/fentry-override.c (test for excess errors)
 UNRESOLVED: gcc.target/i386/fentry-override.c scan-assembler-not __fentry__
 FAIL: gcc.target/i386/fentry.c (test for excess errors)
 UNRESOLVED: gcc.target/i386/fentry.c scan-assembler __fentry__
 
 with -m32. The error is
 
 sorry, unimplemented: -mfentry isn't supported for 32-bit in combination with 
 -fpic
 
 With -m64 I get
 
 FAIL: gcc.target/i386/fentry.c scan-assembler __fentry__
 
 with no string 'entry' in the fentry.s file.

__fentry__ doesn't exist on all x86 targets.
I'm not sure how to mark a test to be Linux only. I'll just remove it.

-Andi


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-17 Thread Andi Kleen
On Wed, Sep 17, 2014 at 04:32:21PM +0200, Andi Kleen wrote:
 On Wed, Sep 17, 2014 at 03:42:37PM +0200, Dominique Dhumieres wrote:
  
  On darwin I get
  
  FAIL: gcc.target/i386/fentry-override.c (test for excess errors)
  UNRESOLVED: gcc.target/i386/fentry-override.c scan-assembler-not __fentry__
  FAIL: gcc.target/i386/fentry.c (test for excess errors)
  UNRESOLVED: gcc.target/i386/fentry.c scan-assembler __fentry__
  
  with -m32. The error is
  
  sorry, unimplemented: -mfentry isn't supported for 32-bit in combination 
  with -fpic
  
  With -m64 I get
  
  FAIL: gcc.target/i386/fentry.c scan-assembler __fentry__
  
  with no string 'entry' in the fentry.s file.
 
 __fentry__ doesn't exist on all x86 targets.
 I'm not sure how to mark a test to be Linux only. I'll just remove it.

Ok, this should fix it:

I'll commit it as obvious after testing unless there are objections.

diff --git a/gcc/testsuite/gcc.target/i386/fentry-override.c 
b/gcc/testsuite/gcc.target/i386/fentry-override.c
index 3771f19..1b158b3 100644
--- a/gcc/testsuite/gcc.target/i386/fentry-override.c
+++ b/gcc/testsuite/gcc.target/i386/fentry-override.c
@@ -1,5 +1,5 @@
 /* Test -mfentry override */
-/* { dg-do compile } */
+/* { dg-do compile { target { *-*-linux* } } } */
 /* { dg-options -mfentry } */
 /* { dg-final { scan-assembler-not __fentry__ } } */
 /* Origin: Andi Kleen */
diff --git a/gcc/testsuite/gcc.target/i386/fentry.c 
b/gcc/testsuite/gcc.target/i386/fentry.c
index bd3db13..888 100644
--- a/gcc/testsuite/gcc.target/i386/fentry.c
+++ b/gcc/testsuite/gcc.target/i386/fentry.c
@@ -1,5 +1,5 @@
 /* Test -mfentry */
-/* { dg-do compile } */
+/* { dg-do compile { target { *-*-linux* } } } */
 /* { dg-options -fprofile -mfentry } */
 /* { dg-final { scan-assembler __fentry__ } } */
 /* Origin: Andi Kleen */


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


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-17 Thread Jakub Jelinek
On Wed, Sep 17, 2014 at 04:39:00PM +0200, Andi Kleen wrote:
 Ok, this should fix it:
 
 I'll commit it as obvious after testing unless there are objections.

This isn't sufficient.
If -mfentry isn't compatible with -m32 -fpic, supposedly you need
something like (untested):
/* { dg-do compile { target { { *-*-linux* }  { nonpic || ! { ia32 } } } } } 
*/
or similar (dunno about -mx32 -fpic, whether it is supposed to work or not).
Otherwise, if somebody tests (and some people do) with
make check-gcc 
RUNTESTFLAGS='--target_board=unix\{-m32,-m32/-fpic,-m64,-m64/-fpic\}'
or similar, there could be failures.
Just test your patch with
make check-gcc 
RUNTESTFLAGS='--target_board=unix\{-m32,-m32/-fpic,-m64,-m64/-fpic\} 
i386.exp=fentry*.c'
in addition to normal testing...

 --- a/gcc/testsuite/gcc.target/i386/fentry-override.c
 +++ b/gcc/testsuite/gcc.target/i386/fentry-override.c
 @@ -1,5 +1,5 @@
  /* Test -mfentry override */
 -/* { dg-do compile } */
 +/* { dg-do compile { target { *-*-linux* } } } */
  /* { dg-options -mfentry } */
  /* { dg-final { scan-assembler-not __fentry__ } } */
  /* Origin: Andi Kleen */
 diff --git a/gcc/testsuite/gcc.target/i386/fentry.c 
 b/gcc/testsuite/gcc.target/i386/fentry.c
 index bd3db13..888 100644
 --- a/gcc/testsuite/gcc.target/i386/fentry.c
 +++ b/gcc/testsuite/gcc.target/i386/fentry.c
 @@ -1,5 +1,5 @@
  /* Test -mfentry */
 -/* { dg-do compile } */
 +/* { dg-do compile { target { *-*-linux* } } } */
  /* { dg-options -fprofile -mfentry } */
  /* { dg-final { scan-assembler __fentry__ } } */
  /* Origin: Andi Kleen */
 
 
 -- 
 a...@linux.intel.com -- Speaking for myself only.

Jakub


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-17 Thread Andi Kleen
On Wed, Sep 17, 2014 at 04:51:33PM +0200, Jakub Jelinek wrote:
 On Wed, Sep 17, 2014 at 04:39:00PM +0200, Andi Kleen wrote:
  Ok, this should fix it:
  
  I'll commit it as obvious after testing unless there are objections.
 
 This isn't sufficient.
 If -mfentry isn't compatible with -m32 -fpic, supposedly you need

-mfentry works fine with -m32 -fpic as far as I know.

[my recent pending patch adding some extensions didn't support it
though, but that's not tested here]

-Andi


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-17 Thread Jakub Jelinek
On Wed, Sep 17, 2014 at 05:46:45PM +0200, Andi Kleen wrote:
 On Wed, Sep 17, 2014 at 04:51:33PM +0200, Jakub Jelinek wrote:
  On Wed, Sep 17, 2014 at 04:39:00PM +0200, Andi Kleen wrote:
   Ok, this should fix it:
   
   I'll commit it as obvious after testing unless there are objections.
  
  This isn't sufficient.
  If -mfentry isn't compatible with -m32 -fpic, supposedly you need
 
 -mfentry works fine with -m32 -fpic as far as I know.
 
 [my recent pending patch adding some extensions didn't support it
 though, but that's not tested here]

Well, so why does
make -k check-gcc 
RUNTESTFLAGS='--target_board=unix\{-m32,-m32/-fpic,-m64,-m64/-fpic\} 
i386.exp=fentry*.c'
fail for -m32/-fpic then on x86_64-linux (current trunk)?

/usr/src/gcc/gcc/testsuite/gcc.target/i386/fentry-override.c:1:0: sorry, 
unimplemented: -mfentry isn't supported for 32-bit in combination with -fpic
/usr/src/gcc/gcc/testsuite/gcc.target/i386/fentry.c:1:0: sorry, unimplemented: 
-mfentry isn't supported for 32-bit in combination with -fpic

Jakub


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-17 Thread Andi Kleen
 Well, so why does

Yo're right. It's actually not supported. I'll use the method you
suggested earlier.

-Andi


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-16 Thread H.J. Lu
On Mon, Sep 15, 2014 at 8:59 AM, Andi Kleen a...@linux.intel.com wrote:
 On Mon, Sep 15, 2014 at 11:29:50AM +0200, Richard Biener wrote:
 On Fri, Sep 12, 2014 at 4:32 PM, Andi Kleen a...@firstfloor.org wrote:
  From: Andi Kleen a...@linux.intel.com
 
  Test fentry and no_instrument_function overriding.
 
  No test cases for the LTO test for now, as the LTO
  harness doesn't seem to support different flags for the final
  link.

 Sure it does - via dg-extra-ld-options (you have to negate compile-time
 opts to remove them).

 Ok. I'll add test cases for that too then.


 Are you sure the tests are target independent enough?  That is,
 'mcount' is really 'mcount' on all targets?

 I'm not. I'll make them x86 only.

 Thanks,

 -Andi

Tested on Linux/x86-64.  I checked in this to fix:

https://gcc.gnu.org/ml/gcc-regression/2014-09/msg00084.html

-- 
H.J.
---
Index: ChangeLog
===
--- ChangeLog (revision 215300)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2014-09-16  H.J. Lu  hongjiu...@intel.com
+
+ * gcc.dg/pg.c: Fix a typo.
+
 2014-09-16  Richard Biener  rguent...@suse.de

  PR testsuite/63258
Index: gcc.dg/pg.c
===
--- gcc.dg/pg.c (revision 215300)
+++ gcc.dg/pg.c (working copy)
@@ -1,6 +1,6 @@
 /* Test -fprofile override */
 /* { dg-do compile } */
-/* { dg-options -fprofile { target { { i686-*-* x86_64-*-* } } } } */
+/* { dg-options -fprofile { target i?86-*-* x86_64-*-* } } */
 /* { dg-final { scan-assembler-not mcount } } */
 /* Origin: Andi Kleen */
 extern void foobar(const char *);


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-16 Thread H.J. Lu
On Tue, Sep 16, 2014 at 8:36 AM, H.J. Lu hjl.to...@gmail.com wrote:
 On Mon, Sep 15, 2014 at 8:59 AM, Andi Kleen a...@linux.intel.com wrote:
 On Mon, Sep 15, 2014 at 11:29:50AM +0200, Richard Biener wrote:
 On Fri, Sep 12, 2014 at 4:32 PM, Andi Kleen a...@firstfloor.org wrote:
  From: Andi Kleen a...@linux.intel.com
 
  Test fentry and no_instrument_function overriding.
 
  No test cases for the LTO test for now, as the LTO
  harness doesn't seem to support different flags for the final
  link.

 Sure it does - via dg-extra-ld-options (you have to negate compile-time
 opts to remove them).

 Ok. I'll add test cases for that too then.


 Are you sure the tests are target independent enough?  That is,
 'mcount' is really 'mcount' on all targets?

 I'm not. I'll make them x86 only.

 Thanks,

 -Andi

 Tested on Linux/x86-64.  I checked in this to fix:

 https://gcc.gnu.org/ml/gcc-regression/2014-09/msg00084.html

 --
 H.J.
 ---
 Index: ChangeLog
 ===
 --- ChangeLog (revision 215300)
 +++ ChangeLog (working copy)
 @@ -1,3 +1,7 @@
 +2014-09-16  H.J. Lu  hongjiu...@intel.com
 +
 + * gcc.dg/pg.c: Fix a typo.
 +
  2014-09-16  Richard Biener  rguent...@suse.de

   PR testsuite/63258
 Index: gcc.dg/pg.c
 ===
 --- gcc.dg/pg.c (revision 215300)
 +++ gcc.dg/pg.c (working copy)
 @@ -1,6 +1,6 @@
  /* Test -fprofile override */
  /* { dg-do compile } */
 -/* { dg-options -fprofile { target { { i686-*-* x86_64-*-* } } } } */
 +/* { dg-options -fprofile { target i?86-*-* x86_64-*-* } } */
  /* { dg-final { scan-assembler-not mcount } } */
  /* Origin: Andi Kleen */
  extern void foobar(const char *);

Here is another one:

Index: ChangeLog
===
--- ChangeLog (revision 215303)
+++ ChangeLog (working copy)
@@ -1,5 +1,9 @@
 2014-09-16  H.J. Lu  hongjiu...@intel.com

+ * gcc.dg/pg-override.c: Fix a typo.
+
+2014-09-16  H.J. Lu  hongjiu...@intel.com
+
  * gcc.dg/pg.c: Fix a typo.

 2014-09-16  Richard Biener  rguent...@suse.de
Index: gcc.dg/pg-override.c
===
--- gcc.dg/pg-override.c (revision 215303)
+++ gcc.dg/pg-override.c (working copy)
@@ -1,6 +1,6 @@
 /* Test -fprofile override */
 /* { dg-do compile } */
-/* { dg-options -fprofile { target { { i686-*-* x86_64-*-* } } } } */
+/* { dg-options -fprofile { target i?86-*-* x86_64-*-* } } */
 /* { dg-final { scan-assembler-not mcount } } */
 /* Origin: Andi Kleen */
 extern void foobar(const char *);



-- 
H.J.


Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-15 Thread Richard Biener
On Fri, Sep 12, 2014 at 4:32 PM, Andi Kleen a...@firstfloor.org wrote:
 From: Andi Kleen a...@linux.intel.com

 Test fentry and no_instrument_function overriding.

 No test cases for the LTO test for now, as the LTO
 harness doesn't seem to support different flags for the final
 link.

Sure it does - via dg-extra-ld-options (you have to negate compile-time
opts to remove them).

Are you sure the tests are target independent enough?  That is,
'mcount' is really 'mcount' on all targets?

Ok.

Thanks,
Richard.

 gcc/testsuite/:

 2014-09-11  Andi Kleen  a...@linux.intel.com

 * gcc.dg/pg-override.c: New test.
 * gcc.dg/pg.c: New test.
 * gcc.target/i386/fentry-override.c: New test.
 * gcc.target/i386/fentry.c: New test.
 ---
  gcc/testsuite/gcc.dg/pg-override.c  | 18 ++
  gcc/testsuite/gcc.dg/pg.c   | 18 ++
  gcc/testsuite/gcc.target/i386/fentry-override.c | 18 ++
  gcc/testsuite/gcc.target/i386/fentry.c  | 18 ++
  4 files changed, 72 insertions(+)
  create mode 100644 gcc/testsuite/gcc.dg/pg-override.c
  create mode 100644 gcc/testsuite/gcc.dg/pg.c
  create mode 100644 gcc/testsuite/gcc.target/i386/fentry-override.c
  create mode 100644 gcc/testsuite/gcc.target/i386/fentry.c

 diff --git a/gcc/testsuite/gcc.dg/pg-override.c 
 b/gcc/testsuite/gcc.dg/pg-override.c
 new file mode 100644
 index 000..7cd6680
 --- /dev/null
 +++ b/gcc/testsuite/gcc.dg/pg-override.c
 @@ -0,0 +1,18 @@
 +/* Test -fprofile override */
 +/* { dg-do compile } */
 +/* { dg-options -fprofile } */
 +/* { dg-final { scan-assembler-not mcount } } */
 +/* Origin: Andi Kleen */
 +extern void foobar(const char *);
 +
 +__attribute__((no_instrument_function)) void func(void)
 +{
 +  foobar (Hello world\n);
 +}
 +
 +__attribute__((no_instrument_function)) void func2(void)
 +{
 +  int i;
 +  for (i = 0; i  10; i++)
 +foobar (Hello world);
 +}
 diff --git a/gcc/testsuite/gcc.dg/pg.c b/gcc/testsuite/gcc.dg/pg.c
 new file mode 100644
 index 000..7cd6680
 --- /dev/null
 +++ b/gcc/testsuite/gcc.dg/pg.c
 @@ -0,0 +1,18 @@
 +/* Test -fprofile override */
 +/* { dg-do compile } */
 +/* { dg-options -fprofile } */
 +/* { dg-final { scan-assembler-not mcount } } */
 +/* Origin: Andi Kleen */
 +extern void foobar(const char *);
 +
 +__attribute__((no_instrument_function)) void func(void)
 +{
 +  foobar (Hello world\n);
 +}
 +
 +__attribute__((no_instrument_function)) void func2(void)
 +{
 +  int i;
 +  for (i = 0; i  10; i++)
 +foobar (Hello world);
 +}
 diff --git a/gcc/testsuite/gcc.target/i386/fentry-override.c 
 b/gcc/testsuite/gcc.target/i386/fentry-override.c
 new file mode 100644
 index 000..3771f19
 --- /dev/null
 +++ b/gcc/testsuite/gcc.target/i386/fentry-override.c
 @@ -0,0 +1,18 @@
 +/* Test -mfentry override */
 +/* { dg-do compile } */
 +/* { dg-options -mfentry } */
 +/* { dg-final { scan-assembler-not __fentry__ } } */
 +/* Origin: Andi Kleen */
 +extern void foobar(const char *);
 +
 +void __attribute__((no_instrument_function)) func(void)
 +{
 +  foobar (Hello world\n);
 +}
 +
 +void __attribute__((no_instrument_function)) func2(void)
 +{
 +  int i;
 +  for (i = 0; i  10; i++)
 +foobar (Hello world);
 +}
 diff --git a/gcc/testsuite/gcc.target/i386/fentry.c 
 b/gcc/testsuite/gcc.target/i386/fentry.c
 new file mode 100644
 index 000..bd3db13
 --- /dev/null
 +++ b/gcc/testsuite/gcc.target/i386/fentry.c
 @@ -0,0 +1,18 @@
 +/* Test -mfentry */
 +/* { dg-do compile } */
 +/* { dg-options -fprofile -mfentry } */
 +/* { dg-final { scan-assembler __fentry__ } } */
 +/* 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);
 +}
 --
 2.1.0



Re: [PATCH 2/2] Add some more test cases for fentry and pg

2014-09-15 Thread Andi Kleen
On Mon, Sep 15, 2014 at 11:29:50AM +0200, Richard Biener wrote:
 On Fri, Sep 12, 2014 at 4:32 PM, Andi Kleen a...@firstfloor.org wrote:
  From: Andi Kleen a...@linux.intel.com
 
  Test fentry and no_instrument_function overriding.
 
  No test cases for the LTO test for now, as the LTO
  harness doesn't seem to support different flags for the final
  link.
 
 Sure it does - via dg-extra-ld-options (you have to negate compile-time
 opts to remove them).

Ok. I'll add test cases for that too then.

 
 Are you sure the tests are target independent enough?  That is,
 'mcount' is really 'mcount' on all targets?

I'm not. I'll make them x86 only.

Thanks,

-Andi


[PATCH 2/2] Add some more test cases for fentry and pg

2014-09-12 Thread Andi Kleen
From: Andi Kleen a...@linux.intel.com

Test fentry and no_instrument_function overriding.

No test cases for the LTO test for now, as the LTO
harness doesn't seem to support different flags for the final
link.

gcc/testsuite/:

2014-09-11  Andi Kleen  a...@linux.intel.com

* gcc.dg/pg-override.c: New test.
* gcc.dg/pg.c: New test.
* gcc.target/i386/fentry-override.c: New test.
* gcc.target/i386/fentry.c: New test.
---
 gcc/testsuite/gcc.dg/pg-override.c  | 18 ++
 gcc/testsuite/gcc.dg/pg.c   | 18 ++
 gcc/testsuite/gcc.target/i386/fentry-override.c | 18 ++
 gcc/testsuite/gcc.target/i386/fentry.c  | 18 ++
 4 files changed, 72 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/pg-override.c
 create mode 100644 gcc/testsuite/gcc.dg/pg.c
 create mode 100644 gcc/testsuite/gcc.target/i386/fentry-override.c
 create mode 100644 gcc/testsuite/gcc.target/i386/fentry.c

diff --git a/gcc/testsuite/gcc.dg/pg-override.c 
b/gcc/testsuite/gcc.dg/pg-override.c
new file mode 100644
index 000..7cd6680
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pg-override.c
@@ -0,0 +1,18 @@
+/* Test -fprofile override */
+/* { dg-do compile } */
+/* { dg-options -fprofile } */
+/* { dg-final { scan-assembler-not mcount } } */
+/* Origin: Andi Kleen */
+extern void foobar(const char *);
+
+__attribute__((no_instrument_function)) void func(void)
+{
+  foobar (Hello world\n);
+}
+
+__attribute__((no_instrument_function)) void func2(void)
+{
+  int i;
+  for (i = 0; i  10; i++)
+foobar (Hello world);
+}
diff --git a/gcc/testsuite/gcc.dg/pg.c b/gcc/testsuite/gcc.dg/pg.c
new file mode 100644
index 000..7cd6680
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pg.c
@@ -0,0 +1,18 @@
+/* Test -fprofile override */
+/* { dg-do compile } */
+/* { dg-options -fprofile } */
+/* { dg-final { scan-assembler-not mcount } } */
+/* Origin: Andi Kleen */
+extern void foobar(const char *);
+
+__attribute__((no_instrument_function)) void func(void)
+{
+  foobar (Hello world\n);
+}
+
+__attribute__((no_instrument_function)) void func2(void)
+{
+  int i;
+  for (i = 0; i  10; i++)
+foobar (Hello world);
+}
diff --git a/gcc/testsuite/gcc.target/i386/fentry-override.c 
b/gcc/testsuite/gcc.target/i386/fentry-override.c
new file mode 100644
index 000..3771f19
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/fentry-override.c
@@ -0,0 +1,18 @@
+/* Test -mfentry override */
+/* { dg-do compile } */
+/* { dg-options -mfentry } */
+/* { dg-final { scan-assembler-not __fentry__ } } */
+/* Origin: Andi Kleen */
+extern void foobar(const char *);
+
+void __attribute__((no_instrument_function)) func(void)
+{
+  foobar (Hello world\n);
+}
+
+void __attribute__((no_instrument_function)) func2(void)
+{
+  int i;
+  for (i = 0; i  10; i++)
+foobar (Hello world);
+}
diff --git a/gcc/testsuite/gcc.target/i386/fentry.c 
b/gcc/testsuite/gcc.target/i386/fentry.c
new file mode 100644
index 000..bd3db13
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/fentry.c
@@ -0,0 +1,18 @@
+/* Test -mfentry */
+/* { dg-do compile } */
+/* { dg-options -fprofile -mfentry } */
+/* { dg-final { scan-assembler __fentry__ } } */
+/* 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);
+}
-- 
2.1.0