Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack reservation is not optimal #9

Open
kv-sc opened this issue Mar 28, 2024 · 0 comments
Open

Stack reservation is not optimal #9

kv-sc opened this issue Mar 28, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@kv-sc
Copy link
Collaborator

kv-sc commented Mar 28, 2024

reproduce on 1.0

snippy invocation line:

./llvm-snippy layout-stack.yaml -march=riscv64-linux-gnu -function-number=3 -function-layers=2 -num-instrs=100  -stack-size=10240 -num-instr-ancil=50 -model-plugin=None

layout-stack.yaml looks like this:

sections:
  - no:        1
    VMA:       0x210000
    SIZE:      0x100000
    LMA:       0x210000
    ACCESS:    rx
  - no:        2
    VMA:       0x100000
    SIZE:      0x100000
    LMA:       0x100000
    ACCESS:    rw

histogram:
    - [ADD, 1.0]
    - [ADDI, 1.0]
    - [SUB, 1.0]
    - [JAL, 0.1]
    - [JALR, 0.1]

You will see in generated binary:

000000000000043c <fun1>:
 43c:   ff010113                addi    sp,sp,-16
 440:   01813023                sd      s8,0(sp)
 444:   ff010113                addi    sp,sp,-16
 448:   01f13023                sd      t6,0(sp)
 44c:   ff010113                addi    sp,sp,-16
 450:   00c13023                sd      a2,0(sp)
 454:   ff010113                addi    sp,sp,-16
 458:   01a13023                sd      s10,0(sp)
 45c:   ff010113                addi    sp,sp,-16
 460:   00713023                sd      t2,0(sp)
 464:   ff010113                addi    sp,sp,-16
 468:   00e13023                sd      a4,0(sp)
....

Granted that there is only 2 layers of functions in call graph it is possible to statically assign space for each function on stack and calculate it from scratch in the prologue.

@kv-sc kv-sc added the enhancement New feature or request label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant