On Wed, Nov 14, 2018 at 01:00:43PM +0100, Jakub Jelinek wrote:
> On Wed, Nov 14, 2018 at 05:50:39AM -0600, Segher Boessenkool wrote:
> > > You mean for all local hard register variables living across function
> > > calls
> > > save them into temporary and restore them around the calls?
> > > One issue is that those variables aren't in SSA form, so liveness analysis
> > > is harder. And, would we want to have an exception for the stack pointer?
> > > I mean there is no need for register void *sp __asm ("rsp"); to be
> > > saved/restored that way, it shouldn't change value across function calls.
> > > Plus, as has been mentioned, function calls aren't the only issue here,
> > > e.g. division/modulo etc. that require specific hard registers might
> > > clobber
> > > them too.
> >
> > I was thinking put them in pseudos always, just copy them to the hard reg
> > right before the asm statements that use them (and the other way around,
> > for outputs).
>
> Wouldn't that break all the code that does:
> void *
> retsp (void)
> {
> register void *sp __asm ("sp");
> return sp;
> }
> (or any other (usually fixed) reg, where the user code expects to just
> read the value of that register)?
It doesn't "break" anything because it currently isn't guaranteed to work
either. There is __builtin_frame_address(0) for this of course (well,
almost the same semantics, and it is actually well-defined and actually
works). Is there user code that tries to do this with a register var?
> Storing uninitialized value into it would break the program miserably.
There is no asm statement here.
Segher