[PATCH] Use 16 byte stack alignment for NaCl on ARM, and fix a varargs bug

Stepan Dyatkovskiy stpworld at narod.ru
Tue Feb 4 01:50:14 PST 2014


Hi Renato,

 > Though, it would be good to know what stopped you in the past
That was just a misgiving, I think. But look:
unsigned Padding =
   ((ArgRegsSize + AFI->getArgRegsSaveSize() + Align - 1) & ~(Align-1)) -
   (ArgRegsSize + AFI->getArgRegsSaveSize());

It works only if Align is power of 2. It fails for Align == 24 for 
example. So we need to check it then..

I have even created small program to deal with that formulae :-)

-Stepan

Renato Golin wrote:
> On 4 February 2014 08:20, Stepan Dyatkovskiy <stpworld at narod.ru
> <mailto:stpworld at narod.ru>> wrote:
>
>     What strategy should be used here? "Align > 4" or "(Align == 8 ||
>     Align == 16)"? Too small point details of course..
>
>
> Hi Stepan,
>
> I think this issue is generic to the alignment, as you said (K*Align -
> 1), so it should be safe to say (Align > 4) and subtract the current
> stack size from it for the pad.
>
> I can't see why the alignment would be bigger than 16, but then again, I
> couldn't see why the alignment would be bigger than 8, so... ;)
>
> Finally, (Align > 4) is more expressive than the alternative, and leaves
> it clear on which class of conditions the pad must be inserted, rather
> than on which examples of the class of conditions we know it should.
>
> Though, it would be good to know what stopped you in the past, as we may
> be overlooking it again...
>
> cheers,
> --renato

-------------- next part --------------
A non-text attachment was scrubbed...
Name: padding-test.c
Type: text/x-csrc
Size: 376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140204/be63002a/attachment.c>


More information about the llvm-commits mailing list