aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_utility.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-11-13 18:32:50 +0000
committergingerBill <bill@gingerbill.org>2024-11-13 18:32:50 +0000
commit89a5decc33e532eca4ae3739ae89db508a700a8d (patch)
tree3c5f86f7885c2287a8dd376dc3bf8f2287504142 /src/llvm_backend_utility.cpp
parent91bd5d44187cc8ad48452db665acf7eb8a5cb19b (diff)
Keep ASAN happy on type assertions
Diffstat (limited to 'src/llvm_backend_utility.cpp')
-rw-r--r--src/llvm_backend_utility.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp
index 6367d0118..e6049da84 100644
--- a/src/llvm_backend_utility.cpp
+++ b/src/llvm_backend_utility.cpp
@@ -124,8 +124,16 @@ gb_internal void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, u
switch (kind) {
case LLVMStructTypeKind:
case LLVMArrayTypeKind:
- // NOTE(bill): Enforce zeroing through memset to make sure padding is zeroed too
- lb_mem_zero_ptr_internal(p, ptr, lb_const_int(p->module, t_int, sz).value, alignment, false);
+ if (is_type_tuple(type)) {
+ // NOTE(bill): even though this should be safe, to keep ASAN happy, do not zero the implicit padding at the end
+ GB_ASSERT(type->kind == Type_Tuple);
+ i64 n = type->Tuple.variables.count-1;
+ i64 end_offset = type->Tuple.offsets[n] + type_size_of(type->Tuple.variables[n]->type);
+ lb_mem_zero_ptr_internal(p, ptr, lb_const_int(p->module, t_int, end_offset).value, alignment, false);
+ } else {
+ // NOTE(bill): Enforce zeroing through memset to make sure padding is zeroed too
+ lb_mem_zero_ptr_internal(p, ptr, lb_const_int(p->module, t_int, sz).value, alignment, false);
+ }
break;
default:
LLVMBuildStore(p->builder, LLVMConstNull(lb_type(p->module, type)), ptr);