RFC: Patch to allow spill slot alignment greater than the stack alignment

H.J. Lu hjl.tools@gmail.com
Mon Oct 5 16:21:00 GMT 2015


On Mon, Oct 5, 2015 at 9:10 AM, Steve Ellcey <sellcey@imgtec.com> wrote:
> 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.

We keep track stack frame information precisely in x86 backend,
including unwind info, and we fixed DWARF unwind info generation to
support it.  We used gcc_assert to verify that everything is in
sync.

I don't know what is missing to support MIPS dynamic stack alignment.
Unless DWARF unwind info isn't sufficient for MIPS, I don't see why
dynamic stack alignment can't be done for MIPS.  If you get the wrong
DWARF unwind info, you can add assert to GCC source to track down
its origin and fix assert to generate the correct DWARF unwind info.

-- 
H.J.



More information about the Gcc-patches mailing list