diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-13 18:35:23 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-13 18:35:23 +0100 |
| commit | 5e2950e9fbe794f34589c8c2b67d1ed1dd48a241 (patch) | |
| tree | b27adb4ec68634e1607c112f2cf67fff04408c92 /src/llvm_backend.cpp | |
| parent | 74c019f2717d4a885907a5833bed5028e02abc77 (diff) | |
Move asserts around
Diffstat (limited to 'src/llvm_backend.cpp')
| -rw-r--r-- | src/llvm_backend.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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]; |