[Bug tree-optimization/34563] noinline function call being removed

jkenisto at us dot ibm dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 17 19:11:00 GMT 2008



------- Comment #9 from jkenisto at us dot ibm dot com  2008-01-17 18:52 -------
(In reply to comment #8)
> (In reply to comment #7)
> > Testing of stuff like kprobes in Linux would be a lot easier if nolinline
> > worked reliably.  See this thread, for example:
> > http://marc.info/?l=linux-kernel&m=119991179332571&w=2
> 
> This function is not being inlined, the call to it is just being removed as the
> function is const in this case. ...

It seems to me that omitting the call to the function and instead executing the
function's code (in this case, nothing) in the caller is the very essence of
inlining.  But let's not quibble about that.  The gcc manual doesn't address
this distinction, as far as I can tell.

Here's my concern.  For certain types of kprobes tests, we insert a kprobe
(essentially a non-interactive breakpoint) at the entry to a function* and then
verify that the number of probe hits matches the number of calls to the
function.  The probed function doesn't have to do anything but get called and
return, so an empty function is ideal.  If the function never gets called, the
test is useless.  gcc emitting an out-of-line copy that doesn't get called is
no help.  (*Because of the availability of symbol information and the
differences in code generation between compiler versions and between
architectures, function entry points are by far the most easily specified
probepoints.)

Since this topic came up, I've seen various suggestions for how to guarantee
that a function gets inlined -- e.g., make it a varargs function, or include an
empty asm statement.  The obvious danger there (aside from the apparent lack of
clarity as to what constitutes inlining) is that such guarantees are not
explicit and so may go away the next time gcc developers get ambitious about
inlining.

Also -- while I'm asking :-) -- I'd prefer the issue be addressed in a language
construct (e.g., the noinline attribute) rather than a command-line option
because it's tricky to build kprobes test modules with different options from
the rest of the kernel build.

FWIW, specifying noinline for an empty function used to work for me,  but that
was an older version of gcc.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34563



More information about the Gcc-bugs mailing list