Messages in this thread | | | Date | Mon, 10 Jul 2000 05:27:00 -0700 | From | Mitchell Blank Jr <> | Subject | Re: empty function optimizations |
| |
Geert Uytterhoeven wrote: > My idea was to replace empty and most simple functions by predefined dummy(), > dummy_zeros(), dummy_ones() and dummy_einval() functions, so they appear only > once in a kernel image. But is it worth the effort?
I've often thought about the same thing.
One problem would be to get it to compile without warnings, since these functions have all different prototypes. Unfortunately ANSI won't let you say:
void dummy(...) {}
For filling in function pointers you can do:
void _dummy(void) {} #define dummy ((void *)_dummy)
But now you'll get an error if you try calling dummy directly (then again, why would you?)
I think a much neater solution would be to postulate that gcc will generally always produce identical code for these functions (is that true? I assume register state will alwaus be the same each time for a non-inlined function!). Then you could hack up the toolchain to make a md5sum of all the functions assembly code and then merge the duplicates. That way you might even pick up a couple slightly more complicated variants.
You can even get crazier than this. You could look for pieces of the tails of functions that match (with no jumps across) and then shorten functions by jumping into the middle of a function with the right ending. Note that this would be hard to get right and would likely screw up a modern CPUs ability to match call/return's, so probably not worth it :-)
It would be interesting to try to apply a similar merge on rodata sections... I wonder how much blood could be wrung from that stone.
Anyway, are there any students out there looking for a thesis project? ;-)
-Mitch
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |