-
Notifications
You must be signed in to change notification settings - Fork 237
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
Fixes https://github.com/sampsyo/bril/issues/342 #343
Conversation
Seems like brilift also has this issue. The slight wrinkle is that jumps in cranelift take arguments. I've used a trap instead with an arbitrarily chosen trap code... which is maybe a more principled solution anyways. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're the best, thanks!
// This block did not have a terminating instruction | ||
// Returning void is ill-typed for this function | ||
// This code should be unreachable in well-formed Bril | ||
// Let's just arbitrarily jump to avoid needing to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣
@@ -1294,28 +1294,29 @@ pub fn create_module_from_program<'a>( | |||
} | |||
}); | |||
|
|||
(llvm_func, instrs, block, heap) | |||
(llvm_func, instrs, block, heap, return_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could preserve original function here instead of instrs and return_type
That, or do a zip later with the original functions and the llvm ones
Awesome; good thinking here!! And trapping in the generated CLIF seems like a good idea. I'll poke around in the Cranelift docs to see if there's something else obvious to use here, just in case. |
Unterminated, non-void basic_blocks weren't handled in brillvm. I think this is only ever an issue of dead code(for if this was reachable, then the Bril code would not be well-formed).
The simplest solution may actually be to insert a jump to some arbitrary block instead of trying to craft a well-typed return.