diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 7eb66c6..62dfc57 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -967,6 +967,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 80867ca..fe957ab 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -7875,6 +7875,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/doc/invoke.texi b/gcc/doc/invoke.texi
index 15ecaf1..dbabc72 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -174,7 +174,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}
@@ -1858,6 +1858,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..b15cd94
--- /dev/null
+++ b/gcc/testsuite/g++.dg/fno-instrument-function.C
@@ -0,0 +1,18 @@
+/* Test -fno-instrument-function */
+/* { dg-do compile } */
+/* { dg-options "-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..4fafe4f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fno-instrument-function.c
@@ -0,0 +1,24 @@
+/* Test -fno-instrument-function */
+/* { dg-do compile } */
+/* { dg-options "-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");
+}
