I've been thinking about possible solutions. My first idea was going with source filters. Use source filter to find place where subroutine is called, find source code of the subroutine, replace subroutine call with source code of the subroutine. However it is hard to do properly. Inlined subrotine should preserve context in which it have been defined (current package, closures, etc). After more thoughts on this subject I started to think that proper solution should operate not on the level of source code but on the level of OP trees. I.e. find in OP tree place where subroutine called, find OP tree of the subroutine, insert subroutine call with copy of subroutine OP tree. Sounds easy but how can I do it in Perl? I haven't programmed in C for very long time and I have relatively limited knoledge of Perl internals. So I suspended this project for some time.
But recently Simon Cozens published his article Where Wizards Fear To Tread. "Wow!" - I though after reading that article - "B::Utils and B::Generate is all I need. Give me couple of hours and this project will be done." How could I be so naive? I've downloaded these modules and as first excerise tried to write code which finds calls to one subroutine and replaces them with calls to another. Sounds easy but it took me several hours. Damn, to finish with this I had to recall C, reread 'perldoc perlguts/xs/api/hack' and even patch XS in B::Generate.
Well, outcome is following: I have slighly better understanding of Perl internals now and I have some idea how I can write Perl module for subroutine inlining support. Given some free time there are some chances I will finish with this project.
P.S. Self-reminder. Do not forget to send patch for B::Generate.