On 16 November 2016 at 10:35, Richard Biener <rguent...@suse.de> wrote:
>
> Since GCC 4.6 we aggressively prune bodies of GNU extern inline functions
> which means that instrumenting them via -finstrument-functions doesn't
> work because that takes the address of the function.  Fixed by not
> instrumenting those functions (we still instrument regular always-inline
> functions and that works as expected).
>
> In the PR this affects intrinsic header functions but it will also
> affect fortify wrappers and in both cases instrumenting is undesirable
> I think.
>
> Bootstrap / regtest in progress on x86_64-unknown-linux-gnu.
>
> Richard.
>
> 2016-11-16  Richard Biener  <rguent...@suse.de>
>
>         PR middle-end/78333
>         * gimplify.c (gimplify_function_tree): Do not instrument
>         GNU extern inline functions.
>
>         * gcc.dg/pr78333.c: New testcase.
>
> Index: gcc/gimplify.c
> ===================================================================
> --- gcc/gimplify.c      (revision 242408)
> +++ gcc/gimplify.c      (working copy)
> @@ -12547,6 +12559,10 @@ gimplify_function_tree (tree fndecl)
>    /* ??? Add some way to ignore exceptions for this TFE.  */
>    if (flag_instrument_function_entry_exit
>        && !DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl)
> +      /* Do not instrument extern inline functions.  */
> +      && !(DECL_DECLARED_INLINE_P (fndecl)
> +          && DECL_EXTERNAL (fndecl)
> +          && DECL_DISREGARD_INLINE_LIMITS (fndecl))
>        && !flag_instrument_functions_exclude_p (fndecl))
>      {
>        tree x;
> Index: gcc/testsuite/gcc.dg/pr78333.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/pr78333.c      (revision 0)
> +++ gcc/testsuite/gcc.dg/pr78333.c      (working copy)
> @@ -0,0 +1,9 @@
> +/* { dg-do link } */
> +/* { dg-options "-finstrument-functions" } */
> +
> +extern inline __attribute__((gnu_inline, always_inline)) int foo () { }
> +int main()
> +{
> +  foo ();
> +  return 0;
> +}

Hi Richard,

The new testcase fails to link on bare-metal targets (arm/aarch64):
/cc4ckSGA.o: In function `main':
pr78333.c:(.text+0x1c): undefined reference to `__cyg_profile_func_enter'
pr78333.c:(.text+0x34): undefined reference to `__cyg_profile_func_exit'
collect2: error: ld returned 1 exit status

I understand that we really want this test to have dg-do link unlike most
of the other tests using -finstrument-functions, so we do not want to
switch to dg-do compile.

Do we want to skip this test in bare-metal configs, or is it a new bug?

Thanks,

Christophe

Reply via email to