diff mbox

[1/2] Always set DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT correctly

Message ID 1410532377-13147-1-git-send-email-andi@firstfloor.org
State New
Headers show

Commit Message

Andi Kleen Sept. 12, 2014, 2:32 p.m. UTC
From: Andi Kleen <ak@linux.intel.com>

When profiling is disabled force DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT
for each function to one. This information is then preserved
through LTO.

With this patch for LTO builds -pg needs to be set on both the
LTO final link and the original source build, to allow -pg
(or -pg -fentry) to be active for that source file. This allows
to build large projects mostly with -pg, except for a few files,
and still use LTO.

Originally suggested by Richard Biener
Passes bootstrap and testing on x86_64-linux.

gcc/:

2014-09-11  Andi Kleen  <ak@linux.intel.com>

	* function.c (allocate_struct_function): Force
	DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT to zero when
	profiling is disabled.
---
 gcc/function.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Richard Biener Sept. 15, 2014, 9:27 a.m. UTC | #1
On Fri, Sep 12, 2014 at 4:32 PM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> When profiling is disabled force DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT
> for each function to one. This information is then preserved
> through LTO.
>
> With this patch for LTO builds -pg needs to be set on both the
> LTO final link and the original source build, to allow -pg
> (or -pg -fentry) to be active for that source file. This allows
> to build large projects mostly with -pg, except for a few files,
> and still use LTO.
>
> Originally suggested by Richard Biener
> Passes bootstrap and testing on x86_64-linux.

Ok with...

> gcc/:
>
> 2014-09-11  Andi Kleen  <ak@linux.intel.com>
>
>         * function.c (allocate_struct_function): Force
>         DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT to zero when

to one.

Thanks,
Richard.

>         profiling is disabled.
> ---
>  gcc/function.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/gcc/function.c b/gcc/function.c
> index c8daf95..f07fdcf 100644
> --- a/gcc/function.c
> +++ b/gcc/function.c
> @@ -4555,6 +4555,9 @@ allocate_struct_function (tree fndecl, bool abstract_p)
>           but is this worth the hassle?  */
>        cfun->can_throw_non_call_exceptions = flag_non_call_exceptions;
>        cfun->can_delete_dead_exceptions = flag_delete_dead_exceptions;
> +
> +      if (!profile_flag && !flag_instrument_function_entry_exit)
> +       DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl) = 1;
>      }
>  }
>
> --
> 2.1.0
>
diff mbox

Patch

diff --git a/gcc/function.c b/gcc/function.c
index c8daf95..f07fdcf 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -4555,6 +4555,9 @@  allocate_struct_function (tree fndecl, bool abstract_p)
          but is this worth the hassle?  */
       cfun->can_throw_non_call_exceptions = flag_non_call_exceptions;
       cfun->can_delete_dead_exceptions = flag_delete_dead_exceptions;
+
+      if (!profile_flag && !flag_instrument_function_entry_exit)
+	DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl) = 1;
     }
 }