[llvm-dev] LLVM AArch64 backend using stack pointer to reference local variables

Yonghae Kim via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 26 17:27:29 PST 2020


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


More information about the llvm-dev mailing list