core: fix __nac3_ndarray_calc_size crash due to incorrect typing

This commit is contained in:
lyken 2024-07-03 11:19:39 +08:00
parent 9808923258
commit dce5ee982d
2 changed files with 4 additions and 6 deletions

View File

@ -201,7 +201,7 @@ double __nac3_j0(double x) {
}
uint32_t __nac3_ndarray_calc_size(
const uint64_t *list_data,
const uint32_t *list_data,
uint32_t list_len,
uint32_t begin_idx,
uint32_t end_idx
@ -210,7 +210,7 @@ uint32_t __nac3_ndarray_calc_size(
uint32_t num_elems = 1;
for (uint32_t i = begin_idx; i < end_idx; ++i) {
uint64_t val = list_data[i];
uint32_t val = list_data[i];
__builtin_assume(val > 0);
num_elems *= val;
}

View File

@ -579,10 +579,8 @@ where
G: CodeGenerator + ?Sized,
Dims: ArrayLikeIndexer<'ctx>,
{
let llvm_i64 = ctx.ctx.i64_type();
let llvm_usize = generator.get_size_type(ctx.ctx);
let llvm_pi64 = llvm_i64.ptr_type(AddressSpace::default());
let llvm_pusize = llvm_usize.ptr_type(AddressSpace::default());
let ndarray_calc_size_fn_name = match llvm_usize.get_bit_width() {
32 => "__nac3_ndarray_calc_size",
@ -590,7 +588,7 @@ where
bw => unreachable!("Unsupported size type bit width: {}", bw),
};
let ndarray_calc_size_fn_t = llvm_usize.fn_type(
&[llvm_pi64.into(), llvm_usize.into(), llvm_usize.into(), llvm_usize.into()],
&[llvm_pusize.into(), llvm_usize.into(), llvm_usize.into(), llvm_usize.into()],
false,
);
let ndarray_calc_size_fn =