I've been working on this to introduce myself to the compiler code base, and I think I understand most of the changes to make. I'd like to take it.
Specifically, my plan so far:
Add a MustCompile flag for Func. (I considered calling this NoSkipCompile because a "MustCompile" function might still not be compiled, e.g. if there are errors.)
Possibly type checking (phase 1): set MustCompile on exported functions.
Probably type checking (phase 1): set MustCompile on functions used as values. I suspect there might be somewhere in the SSA passes where it would be better to do this, to exclude such uses in dead code and to more easily find uses as values, but it would require a different compilation check than I'm planning and would save less work.
In inlnode (phase 5): set MustCompile if it's an ODEFER or OGO node (not clear yet on whether OCLOSURE and OCALLMETH should also set it) or if it's NoInline at the end.
In genfun (between phases 7 and 8): set MustCompile for each concrete method that matches an interface method.
In funccompile (phase 8): return early if the function is not marked MustCompile and inlining is enabled.
I'll be working on this assuming that plan is fine, but I'll probably be slow about it.
One particular case of this has been addressed by CL 282892: if a function-scoped function literal is no longer needed as a function literal (e.g., all of its uses have been inlined or removed by dead-code removal) then we don't separately compile it anymore.