don't store function arguments in alloca

This commit is contained in:
Folkert 2021-01-26 22:01:04 +01:00
parent a49a959362
commit 53e56e275d
3 changed files with 21 additions and 80 deletions

View file

@ -1,5 +1,5 @@
use crate::llvm::build::{
call_bitcode_fn, call_void_bitcode_fn, ptr_from_symbol, Env, InPlace, Scope,
call_bitcode_fn, call_void_bitcode_fn, complex_bitcast, Env, InPlace, Scope,
};
use crate::llvm::build_list::{allocate_list, store_list};
use crate::llvm::convert::collection;
@ -61,20 +61,11 @@ fn str_symbol_to_i128<'a, 'ctx, 'env>(
scope: &Scope<'a, 'ctx>,
symbol: Symbol,
) -> IntValue<'ctx> {
let str_ptr = ptr_from_symbol(scope, symbol);
let string = load_symbol(env, scope, &symbol);
let i128_ptr = env
.builder
.build_bitcast(
*str_ptr,
env.context.i128_type().ptr_type(AddressSpace::Generic),
"cast",
)
.into_pointer_value();
let i128_type = env.context.i128_type().into();
env.builder
.build_load(i128_ptr, "load_as_i128")
.into_int_value()
complex_bitcast(&env.builder, string, i128_type, "str_to_i128").into_int_value()
}
fn str_to_i128<'a, 'ctx, 'env>(