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

[SOL] Add return instructions for functions that end with unreachable #128

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

LucasSte
Copy link
Collaborator

In SBFv3, functions must end with either a JA or a return instructions. When that doesn't happen, program verification will fail.

LLVM does not emit returns or epilogues when a function terminates with a call that never returns, specifically, when the callee halts execution. This PR introduces a pre-emit phase peephole pass that adds a return to a basic block that ends with a call instruction and has no successors. Please, refer to the comment in the code for why I took this approach.

@LucasSte LucasSte requested review from dmakarov and Lichtso January 16, 2025 21:12
@LucasSte LucasSte marked this pull request as ready for review January 16, 2025 21:12
@LucasSte LucasSte merged commit 10a96aa into anza-xyz:solana-rustc/18.1-2024-05-19 Jan 18, 2025
17 checks passed
@LucasSte LucasSte deleted the return-v3 branch January 18, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants