Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7953 Discussions

Inlining of instrumented functions

Weiss__Christian
936 Views

I have a question concerning the inlining of instrumented functions:

 

void __cyg_profile_func_enter (void *, void *) __attribute__((no_instrument_function));

void __cyg_profile_func_exit (void *, void *) __attribute__((no_instrument_function));

void __cyg_profile_func_enter (void *func, void *caller) {
  printf ("ENTER\n");
}

void __cyg_profile_func_exit (void *func, void *caller) {
  printf ("EXIT\n");
}

int func_1 (int x) {
  return x * x;
}

int main (int argc, char *argv[]) {
  printf ("Check 1\n");
  int foo = func_1(1);
  printf ("Check 2: %d\n", foo); // Print out foo to avoid func_1 from being optimized away
}

 

I compile with "icc -finstrument-functions -finline-functions -qopt-report=5 test.c -o test.x". The passage of the optimization report concerning inlining is

 

INLINE REPORT: (main(int, char **)) [1/5=20.0%] test.c(22,35)
  -> INLINE: (22,35) __cyg_profile_func_exit(void *, void *) (isz = 1) (sz = 8)
    -> EXTERN: (15,3) printf(const char *__restrict__, ...)
  -> INLINE: (22,35) __cyg_profile_func_enter(void *, void *) (isz = 1) (sz = 8)
    -> EXTERN: (11,3) printf(const char *__restrict__, ...)
  -> EXTERN: (22,35) _ReturnAddress
  -> EXTERN: (23,3) printf(const char *__restrict__, ...)
  -> CP_CLONE (24,19) func_1..0(int) (isz = 10) (sz = 17)
     [[ Unable to inline callsite  <1>]]
  -> EXTERN: (25,3) printf(const char *__restrict__, ...)

 

Note the message "unable to inline callsite <1>" for the function func_1. The remark <1> states that "Inlining the function will lead to incorrect program behavior". Note that it is inlined fine when I do not instrument the code.

 

My question is: Why is it not possible to inline in this case? Shouldn't it be possible to inline the function and put calls to both hooks in front of and behind its body? This should not interfere with the behavior of the function.

0 Kudos
3 Replies
RahulV_intel
Moderator
907 Views

Hi,


As per the documentation, If you specify -finstrument-functions (Linux) or /Qinstrument-functions (Windows), function inlining is disabled.


https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/profile-guided-optimization-pgo-options/finstrument-functions-qinstrument-functions.html


However, I'd encourage you to try it out by manually inlining your function "func_1" (just add the "inline" keyword at the beginning of your function) and see if it helps.


Thanks,

Rahul


0 Kudos
RahulV_intel
Moderator
871 Views

Hi,


Do you have any updates on this? Let us know if you face any issues.


Thanks,

Rahul


0 Kudos
RahulV_intel
Moderator
845 Views

Hi,


We are assuming that the solution provided helped and would no longer be monitoring this issue. Please raise a new thread if you have further issues.


Thanks,

Rahul


0 Kudos
Reply