- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As per the documentation, If you specify -finstrument-functions (Linux) or /Qinstrument-functions (Windows), function inlining is disabled.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Do you have any updates on this? Let us know if you face any issues.
Thanks,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page