Skip to content

Conversation

airballonboy
Copy link

@airballonboy airballonboy commented Aug 25, 2025

if you returned at the end of a function you used to get an extra return 0 in gas_x86_64
for example the code

main () {
    return(0);
}

would generate

main:
    movq $0, %rax
    movq %rbp, %rsp
    popq %rbp
    ret
    movq $0, %rax
    movq %rbp, %rsp
    popq %rbp
    ret

to avoid a function exiting without a return but i made it check for if the function has returned in the last op and if not it will generate the code

now if you returned at the end of the function you won't get an extra
return 0 in gas_x86_64
@rexim
Copy link
Member

rexim commented Aug 26, 2025

I feel like this kinda of stuff should be the responsibility of the dead-code elimination when we implement it.

@airballonboy
Copy link
Author

airballonboy commented Aug 26, 2025

I feel like this kinda of stuff should be the responsibility of the dead-code elimination when we implement it.

Yeah makes sense, But maybe we should have this until the full feature is implemented.

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