Benjamin Titzer wrote:
Sounds to me like the design of GCC and the constraints of a particular
calling convention do not allow it to do something smart here. I think
the
solution that would satisfy most everyone involved would be for the
compiler to generate code that only saves the state of registers that it
uses (and overwrites) and then restore them upon exit. This is a simple
use-def analysis on the registers and would be simple enough to
implement.
I think that gcc optimizer does that, provided that it can get all the
information when compiling. If the
interrupt handler calls an external function (external to the source
file), then the compiler is not able
to know what to save and what not to save, so it saves everything.
That's a big problem with the usual way of building code, with functions
or set of related functions in
different files. When the compiler groks the files, it does not have all
the information that would help it build a much better optimized code.