From 5e2950e9fbe794f34589c8c2b67d1ed1dd48a241 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 13 Jul 2021 18:35:23 +0100 Subject: Move asserts around --- src/llvm_backend.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/llvm_backend.cpp') diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index ef6a816e2..6a08cc9fd 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -6368,7 +6368,9 @@ LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, BigInt const * } size_t sz = cast(size_t)type_size_of(original_type); - u8 rop[64] = {}; + u64 rop64[4] = {}; // 2 u64 is the maximum we will ever need, so doubling it will be fine :P + u8 *rop = cast(u8 *)rop64; + size_t max_count = 0; size_t written = 0; size_t size = 1; @@ -6376,7 +6378,8 @@ LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, BigInt const * mp_endian endian = MP_LITTLE_ENDIAN; max_count = mp_pack_count(a, nails, size); - GB_ASSERT(max_count <= sz); + GB_ASSERT_MSG(sz >= max_count, "max_count: %tu, sz: %tu, written: %tu", max_count, sz, written); + GB_ASSERT(gb_size_of(rop64) >= sz); mp_err err = mp_pack(rop, sz, &written, MP_LSB_FIRST, @@ -6385,7 +6388,6 @@ LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, BigInt const * GB_ASSERT(err == MP_OKAY); if (!is_type_endian_little(original_type)) { - GB_ASSERT_MSG(sz >= max_count, "max_count: %tu, sz: %tu, written: %tu", max_count, sz, written); for (size_t i = 0; i < sz/2; i++) { u8 tmp = rop[i]; rop[i] = rop[sz-1-i]; -- cgit v1.2.3