mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Pass function pointer directly rather than load/store into alloca
This commit is contained in:
parent
a123820b2b
commit
6ba6b04a17
2 changed files with 3 additions and 14 deletions
|
@ -1143,9 +1143,7 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
|||
}
|
||||
|
||||
FunctionPointer { lambda_name } => {
|
||||
let function_ptr_type =
|
||||
fn_ptr::pointer_type_expecting_layout(env, layout_interner, layout);
|
||||
let alloca = fn_ptr::build(env, *lambda_name, function_ptr_type);
|
||||
let alloca = fn_ptr::build(env, *lambda_name);
|
||||
alloca.into()
|
||||
}
|
||||
ErasedMake { value, callee } => {
|
||||
|
|
|
@ -63,19 +63,10 @@ pub fn pointer_type_expecting_layout<'a, 'ctx>(
|
|||
pointer_type(env, layout_interner, function_pointer)
|
||||
}
|
||||
|
||||
pub fn build<'a, 'ctx>(
|
||||
env: &Env<'a, 'ctx, '_>,
|
||||
lambda_name: LambdaName<'a>,
|
||||
function_ptr_type: PointerType<'ctx>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
let alloca = env
|
||||
.builder
|
||||
.build_alloca(function_ptr_type, "function_pointer_alloca");
|
||||
pub fn build<'a, 'ctx>(env: &Env<'a, 'ctx, '_>, lambda_name: LambdaName<'a>) -> PointerValue<'ctx> {
|
||||
let func_value: FunctionValue<'ctx> =
|
||||
function_value_by_func_spec(env, FuncBorrowSpec::Erased, lambda_name.name());
|
||||
env.builder
|
||||
.build_store(alloca, func_value.as_global_value().as_pointer_value());
|
||||
alloca.into()
|
||||
func_value.as_global_value().as_pointer_value()
|
||||
}
|
||||
|
||||
pub fn cast_to_function_ptr_type<'ctx>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue