diff --git a/src/compiler.jl b/src/compiler.jl index 55b67ae92f..6c98ef5a35 100644 --- a/src/compiler.jl +++ b/src/compiler.jl @@ -2458,7 +2458,14 @@ function julia_allocator(B, LLVMType, Count, AlignedSize, IsDefault, ZI) needs_dynamic_size_workaround = !isa(Size, LLVM.ConstantInt) || convert(Int, Size) != 1 end - obj = emit_allocobj!(B, tag, Size, needs_dynamic_size_workaround) + T_size_t = convert(LLVM.LLVMType, Int) + allocSize = if value_type(Size) != T_size_t + trunc!(B, Size, T_size_t) + else + Size + end + + obj = emit_allocobj!(B, tag, allocSize, needs_dynamic_size_workaround) if ZI != C_NULL unsafe_store!(ZI, zero_allocation(B, TT, LLVMType, obj, AlignedSize, Size, #=ZeroAll=#false))