[llvm-dev] Unaligned Stack Pointer
Krzysztof Parzyszek via llvm-dev
llvm-dev at lists.llvm.org
Thu Sep 17 09:27:45 PDT 2020
The answer may be architecture-specific. Typically such things are done to avoid some unnecessary cost, whether it is stack space, or extra instructions to ensure proper alignment. For example, on architectures/ABIs that have red zones on the stack, leaf functions may not bother allocating any space at all (i.e. leaving the stack pointer unmodified) if the local data fits in the red zone.
--
Krzysztof Parzyszek kparzysz at quicinc.com<mailto:kparzysz at quicinc.com> AI tools development
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Przemyslaw Ossowski via llvm-dev
Sent: Thursday, September 17, 2020 10:39 AM
To: David Jones <david.jones at metrics.ca>
Cc: llvm-dev <llvm-dev at lists.llvm.org>
Subject: [EXT] Re: [llvm-dev] Unaligned Stack Pointer
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<mailto: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<mailto: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<mailto: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/ed9173d0/attachment.html>
More information about the llvm-dev
mailing list