mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Handle Roc's return by pointer flowing into a C ABI return by pointer
This commit is contained in:
parent
6cada1ab6e
commit
b44d68aac5
1 changed files with 14 additions and 2 deletions
|
@ -3811,8 +3811,20 @@ fn expose_function_to_host_help_c_abi_v2<'a, 'ctx, 'env>(
|
|||
},
|
||||
CCReturn::ByPointer => {
|
||||
let out_ptr = c_function.get_nth_param(0).unwrap().into_pointer_value();
|
||||
|
||||
env.builder.build_store(out_ptr, value);
|
||||
match roc_return {
|
||||
RocReturn::Return => {
|
||||
env.builder.build_store(out_ptr, value);
|
||||
}
|
||||
RocReturn::ByPointer => {
|
||||
// TODO: ideally, in this case, we should pass the C return pointer directly
|
||||
// into the call_roc_function rather than forcing an extra alloca, load, and
|
||||
// store!
|
||||
let value = env
|
||||
.builder
|
||||
.build_load(value.into_pointer_value(), "load_roc_result");
|
||||
env.builder.build_store(out_ptr, value);
|
||||
}
|
||||
}
|
||||
env.builder.build_return(None);
|
||||
}
|
||||
CCReturn::Void => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue