Øyvind Harboe wrote:
Is there an existing technique to figure out the difference between the frame address and the stack pointer during code generation ofYou can get the current offset through INITIAL_ELIMINATION_OFFSET. But this offset is not final until reload pass is finished. The offset can become bigger on reload pass becase some pseudo-registers will be put into memory (stack). In general case even frame to hard frame pointer offset (or offset between other virtual registers) is not final until reload is finished because some pseudo-registers can get call saved hard-registers and these hard registers can be saved/restored on stack during prologue/epilogue.
arbitary instructions?
Elimination itself can require additional hard register allocation because not all displacements are permitted for many architectures.
Therefore reload make elimination in a loop untill the process is stabilized (no new hard-registers or stack memory is needed).
One reason why elimination is not done is because of alloca (stack pointer is changed by unknown value during function execution). There are other more complicated reasons too.This is kinda related to frame pointer -> stack pointer elimination, but available during code generation.
I'm not quite sure, but I think frame ointer to stack pointer
elimination can fail. If this is the case, is it because the difference
between frame pointer and stack pointer is not a constant or some other
reason?
I'm just curious and would like to read more.