Hello, Execution of the example program below shows that when a nested function is called by way of a stack trampoline, the -finstrument-functions hooks receive the address of the trampoline as the "this function" parameter.
Receiving the actual function address would seem more useful for function-instrumentation purposes, and this patch adjusts the compiler to do that instead. On x86_64-linux, without the patch, the code below compiled with -finstrument-functions outputs something like entering function at 0x4005a1 entering function at 0x7fffae4acc34 And with the patch, we get instead: entering function at 0x400583 entering function at 0x400557 where the second address corresponds to the bump_by symbol address. Bootstrapped and regression tested on x86_64-linux. Ok to commit ? Thanks in advance, With Kind Regards, 2018-06-22 Olivier Hainque <hain...@adacore.com> * gimplify.c (gimplify_function_tree): Prevent creation of a trampoline for the address of the current function passed to entry/exit instrumentation hooks. --- int main () { volatile int count = 0; void bump_by (int x) { count += x; } { void (* bumper)(int) = &bump_by; (*bumper)(5); } return 0; } #include <stdio.h> __attribute__((no_instrument_function)) void __cyg_profile_func_exit (void * this_fn, void * call_site) { } __attribute__((no_instrument_function)) void __cyg_profile_func_enter (void * this_fn, void * call_site) { printf ("entering function at %p\n", this_fn); }