Browse Source

Keep `-sanitize:address` happy with `bit_field` loads

gingerBill 1 year ago
parent
commit
a935ade0d2
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/llvm_backend_general.cpp

+ 2 - 1
src/llvm_backend_general.cpp

@@ -791,6 +791,7 @@ gb_internal void lb_addr_store(lbProcedure *p, lbAddr addr, lbValue value) {
 			lb_emit_runtime_call(p, "__write_bits", args);
 		} else if ((addr.bitfield.bit_offset % 8) == 0 &&
 		           (addr.bitfield.bit_size   % 8) == 0) {
+			gb_printf_err("Here!\n");
 			lbValue src = lb_address_from_load_or_generate_local(p, value);
 
 			lbValue byte_offset = lb_const_int(p->module, t_uintptr, addr.bitfield.bit_offset/8);
@@ -1162,7 +1163,7 @@ gb_internal lbValue lb_addr_load(lbProcedure *p, lbAddr const &addr) {
 			lbValue copy_size = byte_size;
 			lbValue src_offset = lb_emit_conv(p, src, t_u8_ptr);
 			src_offset = lb_emit_ptr_offset(p, src_offset, byte_offset);
-			if (addr.bitfield.bit_offset + dst_byte_size <= total_bitfield_bit_size) {
+			if (addr.bitfield.bit_offset + 8*dst_byte_size <= total_bitfield_bit_size) {
 				do_mask = true;
 				copy_size = lb_const_int(p->module, t_uintptr, dst_byte_size);
 			}