[llvm-dev] Unaligned Stack Pointer

Przemyslaw Ossowski via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 17 08:39:28 PDT 2020


Exactly, but for some architectures SP is not aligned for such case.
My questions is what for, apart of saving few bytes on stack just during
execution od leaf function?

Przemek

czw., 17 wrz 2020, 17:17 użytkownik David Jones <david.jones at metrics.ca>
napisał:

> Is this really "common"?
>
> I would expect many architectures to require stack pointer alignment at
> all times, as a signal/interrupt/fault can happen at any time.
>
> SPARC is a good example. If an interrupt occurs, the OS must flush all
> register windows out to the user stack.  This requires that the stack
> pointer be aligned.  Since you have no control over when an interrupt can
> occur. you must maintain alignment at all times.
>
>
> On Thu, Sep 17, 2020 at 10:42 AM Przemyslaw Ossowski via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> Hi all,
>>
>> my question is maybe not directly related with LLVM but general with
>> compilers.
>>
>>
>>
>> The common approach is that compilers often don't align stack pointer for
>> leaf functions if the function utilizes stack just for keeping variables of
>> small sizes.
>>
>> I’m wondering what is the benefit of such behavior.
>>
>>
>>
>> Is saving a few bytes of the stack just once worth of such approach?
>>
>> Or maybe something else stands behind it? Is there any other potential
>> benefit of unaligned Stack Pointer in Leaf Functions?
>>
>>
>>
>> Thanks,
>>
>> Przemek
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200917/e790350a/attachment.html>


More information about the llvm-dev mailing list