On 10/23/2016 12:11 PM, Bernd Edlinger wrote:
Hi,
I don't know much about tilegx, but
I think the patch should work as is.
This is because the
Save r10 code is a bundle
{
addi sp, sp, -8
st sp, r10
}
which stores r10 at [sp] and subtracts 8 from sp.
The restore r10 code is actually two bundles:
Thanks for pointing that out! I totally missed the restore was two bundles.
addi sp, sp, 8
ld r10, sp
This just adds 8 to sp, and loads r10 from there.
Right. And with the restore as two bundles the semantics of the
save/restore seem consistent/correct.
I don't know how __mcount is implemented, it must
be some asm code, almost all functions save the
lr at [sp] when invoked, but I don't know if __mcount
does that at all, if it doesn't do that, then the
adjusting of sp might be unnecessary.
The only thing that might be a problem is that
the stack is always adjusted in multiples of 16
on the tilegx platform, see tilegx.h:
#define STACK_BOUNDARY 128
That is counted in bits, and means 16 bytes.
But your patch adjusts the stack only by 8.
Missed that. Without knowing the tile ports, I can't say with any
degree of confidence that it's safe to only adjust by 8 bytes.
Adjusting by 16 seems safer.
Furthermore, I don't see how the stack unwinding will work
with this stack adjustment when no .cfi directives
are emitted, but that is probably not a big problem.
I wouldn't be surprised if the tilegx isn't the only port with this
problem. I don't think we've ever been good about making sure the
unwinders are correct for targets where we profile before the prologue
and which emit the profiling bits directly rather than representing them
as RTL.
jeff