Skip to content

codegen: improve codegen size layout of on-stack format for pointer-ful types#60388

Merged
vtjnash merged 2 commits intomasterfrom
jn/split-bits-layout
Dec 17, 2025
Merged

codegen: improve codegen size layout of on-stack format for pointer-ful types#60388
vtjnash merged 2 commits intomasterfrom
jn/split-bits-layout

Conversation

@vtjnash
Copy link
Copy Markdown
Member

@vtjnash vtjnash commented Dec 15, 2025

This makes a few related improvements to on-stack struct layout:

  • Declaring that the on-stack format is the same layout as the on-heap format, allowing more zero-copy uses (esp of arguments)
  • Removing trailing pointers from the on-stack format, since they don't change the pointer or layout
  • Lazily load roots from where they already live on the stack in some frame. This is particularly impactful when calling a method and just forwarding the arguments, as it avoids an intermediate stack copy.

Trim trailing pointers. Don't trim other pointers in the structure to
keep the layout unchanged.
Before we made eager loads of all roots, which forced eager copies in
many cases (e.g. of arguments) needlessly. By optionally tracking either
the pointer or the values, we can optimize for either case (while
avoiding llvm bugs from pushing non-integral pointers to the stack that
will be used in the same function).
@vtjnash vtjnash added compiler:codegen Generation of LLVM IR and native code needs nanosoldier run This PR should have benchmarks run on it labels Dec 15, 2025
@vtjnash
Copy link
Copy Markdown
Member Author

vtjnash commented Dec 16, 2025

@nanosoldier runbenchmarks(ALL, vs=":master")

@vtjnash vtjnash added merge me PR is reviewed. Merge when all tests are passing don't squash Don't squash merge and removed needs nanosoldier run This PR should have benchmarks run on it labels Dec 16, 2025
@gbaraldi
Copy link
Copy Markdown
Member

When you say on-stack here you mean when we don't have the split roots format?

@nanosoldier
Copy link
Copy Markdown
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@vtjnash vtjnash merged commit fadb159 into master Dec 17, 2025
10 of 15 checks passed
@vtjnash vtjnash deleted the jn/split-bits-layout branch December 17, 2025 15:22
@vtjnash
Copy link
Copy Markdown
Member Author

vtjnash commented Dec 17, 2025

Split-roots format is only implemented on-stack right now

@inkydragon inkydragon removed the merge me PR is reviewed. Merge when all tests are passing label Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:codegen Generation of LLVM IR and native code don't squash Don't squash merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants