Yonghae Kim via llvm-dev
2020-Feb-27 01:27 UTC
[llvm-dev] LLVM AArch64 backend using stack pointer to reference local variables
Hi all, I am wondering whether there is any way (i.e., compile option or different version of backend code that can be referred to) to make the LLVM AArch64 backend use the frame pointer instead of the stack pointer when it references (or locates) local variables in a stack frame. When I generate assembly code using LLVM AArch64 backend, it seems to use a stack pointer to locate the local variables in a stack frame. For example, .... str wzr, [sp, #12] // e.g., local variable a str w8, [sp, #8] // e.g., local variable b str w9, [sp, #4] // e.g., local variable c str w10, [sp] … (It calculates offsets from a stack pointer and accesses the local variable using the stack pointer and the offsets.) The weird thing is all the other compiler tools are using a frame pointer rather than a stack pointer. I tried out "gcc", "clang", "LLVM x86 backend" and they are all referencing local variables using a frame pointer and its offsets. Is there any reasons that the only LLVM AArch64 uses a stack pointer? And, is there any way to make it use a frame pinter? I'd really appreciate for any comment or answer! :) Regards, Yonghae
David Spickett via llvm-dev
2020-Feb-28 09:49 UTC
[llvm-dev] LLVM AArch64 backend using stack pointer to reference local variables
Hi Yonghae, Could you provide a short example for this? Perhaps using https://godbolt.org/ (there is now a "ARM 64-BIT CLANG" compilers section) I see some details about the frame pointer in: llvm-project/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp Though I haven't read it properly yet, it seems like it's not a simple case of not using it at all. It depends on circumstance. Thanks, David Spickett. ________________________________ From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Yonghae Kim via llvm-dev <llvm-dev at lists.llvm.org> Sent: 27 February 2020 01:27 To: llvm-dev at lists.llvm.org <llvm-dev at lists.llvm.org> Subject: [llvm-dev] LLVM AArch64 backend using stack pointer to reference local variables Hi all, I am wondering whether there is any way (i.e., compile option or different version of backend code that can be referred to) to make the LLVM AArch64 backend use the frame pointer instead of the stack pointer when it references (or locates) local variables in a stack frame. When I generate assembly code using LLVM AArch64 backend, it seems to use a stack pointer to locate the local variables in a stack frame. For example, .... str wzr, [sp, #12] // e.g., local variable a str w8, [sp, #8] // e.g., local variable b str w9, [sp, #4] // e.g., local variable c str w10, [sp] … (It calculates offsets from a stack pointer and accesses the local variable using the stack pointer and the offsets.) The weird thing is all the other compiler tools are using a frame pointer rather than a stack pointer. I tried out "gcc", "clang", "LLVM x86 backend" and they are all referencing local variables using a frame pointer and its offsets. Is there any reasons that the only LLVM AArch64 uses a stack pointer? And, is there any way to make it use a frame pinter? I'd really appreciate for any comment or answer! :) Regards, Yonghae _______________________________________________ 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/20200228/ebb1c66a/attachment.html>
Momchil Velikov via llvm-dev
2020-Feb-28 10:39 UTC
[llvm-dev] LLVM AArch64 backend using stack pointer to reference local variables
On Fri, Feb 28, 2020 at 6:17 AM Yonghae Kim via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Is there any reasons that the only LLVM AArch64 uses a stack pointer? >Using the stack pointer frees up the register, which would have been used as a frame pointer, for general allocation. When accessing the stack frame, offsets from SP are positive, whereas offsets from a frame pointer are negative. When you use SP, you can use LDR with a scaled positive offset, with range from 0 up to 16380 (or 32760 for 64-bit accesses). If you use FP, you would use, LDUR with a negative offset, with a range just [-256, 255]. What downsides of using SP do you see? ~chill -- Compiler scrub, Arm -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200228/902220b7/attachment.html>