2

I'm working with LLVM and somewhat new to it.

I'm having trouble figuring out what LLVM means by stack frame lowering. Can someone explain what it is?

Any help is appreciated

Praxeolitic
  • 22,455
  • 16
  • 75
  • 126
flashburn
  • 4,180
  • 7
  • 54
  • 109

1 Answers1

10

When a function runs, it gets some amount of space on the stack to store stuff like stack variables and callee saved registers (CSR). Stack frame lowering is the process of calculating the amount of space and the layout required for this, and then emitting the required machine instructions in the prologue and epilogue (beginning and end) of the function.

When variables on the stack are referred to before the prologue-epilogue insertion (PEI) step, they are addressed using "frame indexes", an arbitrary name for a location that will eventually resolve to a stack-pointer relative offset. Note that PEI happens fairly late (after register allocation).

Cheng Sun
  • 1,025
  • 6
  • 9