[llvm-dev] Unaligned Stack Pointer

David Jones via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 17 08:17:03 PDT 2020


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/549812db/attachment.html>


More information about the llvm-dev mailing list