On Mon, 2015-10-05 at 10:41 +0200, Bernd Schmidt wrote: > On 10/02/2015 10:57 PM, Steve Ellcey wrote: > > I have spent some time trying to do dynamic stack alignment on MIPS and had > > considerable trouble. The problems are mainly due to the dwarf based stack > > unwinding and setjmp/longjmp usages where the code does not go through the > > normal function prologue and epilogue code. > [...] > > The main advantage to this approach over dynamically aligning the stack > > is that by not changing the real stack (or frame) pointer there is > > minimal chance of breaking the ABI and there are no changes needed to > > the dwarf unwind code. The main disadvantage is that I am padding each > > individual spill so I am wasting more space than absolutely required. > > It should be possible to address this by putting all the aligned spills > > together and sharing the padding but I would like to leave that for a > > future improvement. > > > > In the mean time I would like to get some comments on this approach and > > see what people think. Does this seem like a reasonable approach to > > allowing for aligned spills beyond what the stack supports? > > Personally I'm not a fan. Your description of it makes it sound > immensely wasteful, and I'm really not clear on why stack alignment > wouldn't work for MIPS when it's been shown to work elsewhere. I think > we'd want to see a clear demonstration of unfixable problems with stack > alignment before allowing something like this in. > > Vlad would have to comment on the LRA bits, probably. > > > Bernd
There probably is some way to get dynamic stack alignment to work on MIPS, but I am not sure I can do it. The only platform that I see that uses dynamic stack alignment is x86. I think the difficulties in getting this to work correctly is why no other platform has implemented it. The most common response I have gotten when asking around for help on dynamic stack alignment is usually "just break the ABI". My approach does waste some space, on MIPS I would be allocating 32 bytes of stack space to spill a 16 byte MSA register, but the hope/belief is that MSA registers would not get spilled very often. Steve Ellcey