Hi there,
I'm wondering if anyone can provide me a quick tip on how to do dead function
elimination optimizations with gcc-2.95.2, without resorting to
-finline-functions?
The compiler can know that a function is unused if it is static, and there are
no references to it in the same file. Using -finline-functions (with the
default -fno-keep-inline-functions) will eliminate such functions as a side
effect of attempting to inline them, provided their complexity is below the
inline-limit. However, I don't necessarily want to force all functions below
the inline-limit to be inlined; I just want static functions that don't get
called to be eliminated.
Here's why: I'm attempting to cross-compile the Linux kernel for an embedded
system which has no need for the /proc filesystem. Hence, CONFIG_PROC_FS is
undefined. The kernel code contains files with constructs like:
blah.c:
static proc_blah_blah()
{
/* function dealing with /proc stuff */
}
#ifdef CONFIG_PROC_FS
struct with reference to proc_blah_blah
#endif
With CONFIG_PROC_FS undefined, I'd like to optimise away the function
proc_blah_blah automatically, without having to spray more
#ifdef CONFIG_PROC_FS's around all such functions. The compiler already has
enough information to eliminate them, but how do I get it to do so without
also asking it to try to inline _everything_?
Any suggestions?
Thanks,
Graham