Adopt preserve_none attribute for MUST_TAIL optimization #636
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Despite using attribute((musttail)), the compiler may still emit full stack frames and spill callee-saved registers in complex handlers (e.g., do_lw), undermining the benefits of the threaded interpreter.
Integrate Clang's attribute((preserve_none)) (available since Clang 19.1.0) into the MUST_TAIL macro. This attribute modifies the calling convention to avoid preserving registers, thereby minimizing stack setup and register pressure during instruction dispatch.
This ensures more consistent tail call optimization and reduces overhead in the interpreter loop.
Closes: #601
Summary by cubic
Extend MUST_TAIL to include preserve_none when available, so tail-call dispatch avoids stack frames and callee-saved spills. This makes tail calls more reliable and reduces interpreter loop overhead, especially in complex handlers.
Written for commit d8382ab. Summary will update automatically on new commits.