On Sep 29, 2015, at 3:40 PM, H.J. Lu <hjl.to...@gmail.com> wrote:
> How about adding a "no_caller_saved_registers" attribute?

You can save all call clobbered registers with 3 instructions?  Really?  I’m 
skeptical.  Anyway, if you do this by turning off great swaths of registers, 
then, I guess that doesn’t surprise me.  I try and not turn any off in mine.

Now, if you turn off great swaths of registers, then you can’t actually make 
any calls to an abi that supports those registers as call clobbered:

> +  if (cfun->machine->is_interrupt)
> +    return ((df_regs_ever_live_p (regno)
> +          || (call_used_regs[regno] && cfun->machine->make_calls))
> +         && !fixed_regs[regno]
> +         && !STACK_REGNO_P (regno)
> +         && !MMX_REGNO_P (regno)
> +         && regno != BP_REG
> +         && regno != SP_REG
> +         && (regno <= ST7_REG || regno >= XMM0_REG));

So, any calls to a function that uses any excluded register won’t work, if that 
register is not fixed and is call clobbered.  If you call such a function, you 
_must_ save and restore all those registers.  Code like:

> +  if (cfun->machine->is_interrupt && VALID_MMX_REG_MODE (mode))
> +    {
> +      error ("MMX/3Dnow instructions aren't allowed in %s service routine",
> +          (cfun->machine->is_exception ? "exception" : "interrupt"));
> +      return;
> +    }

Does not save your from the obligation of saving such registers, if you support 
function calls inside an interrupt routine.  Once you add that support to make 
function calls work, then, you might as well lift this restriction, cause it 
would already just work?

If you really can save everything in 3 instructions, then there is no point to 
trying to enhance it more on your port.  3 instructions execute so fast as to 
not matter.

Now, if you ask me how I know all this, I had to debug a failure to save 1 
register class in the prologue from large multi core instruction trace, and 
that class was the second most important class for general code gen right after 
the gprs.  Turns out that I killed a live variable in that class from a packet 
handler interrupt routine cause it failed to save/restore.  After that, I 
tested every register class and fixed all the issues.

Reply via email to