aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_general.cpp
diff options
context:
space:
mode:
authorLucas Perlind <perlindluca@gmail.com>2025-04-30 19:21:00 +1000
committerLucas Perlind <perlindluca@gmail.com>2025-05-06 14:55:50 +1000
commit83bc2d3c4a186d6a8c362eed901acd6bc6363a8d (patch)
treeea5c4b6bccb6aa226e6a3ed8036ae3fd24a1915c /src/llvm_backend_general.cpp
parent8032db348411ae85397441de7f2ce9ebd1029112 (diff)
Add asan support for various allocators
Diffstat (limited to 'src/llvm_backend_general.cpp')
-rw-r--r--src/llvm_backend_general.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp
index 421720c4c..dad5d4dd5 100644
--- a/src/llvm_backend_general.cpp
+++ b/src/llvm_backend_general.cpp
@@ -3070,6 +3070,13 @@ gb_internal lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e, bool zero
if (e != nullptr) {
lb_add_entity(p->module, e, val);
lb_add_debug_local_variable(p, ptr, type, e->token);
+
+ // NOTE(lucas): In LLVM 20 and below we do not have the option to have asan cleanup poisoned stack
+ // locals ourselves. So we need to manually track and unpoison these locals on proc return.
+ // LLVM 21 adds the 'use-after-scope' asan option which does this for us.
+ if (build_context.sanitizer_flags & SanitizerFlag_Address && !p->entity->Procedure.no_sanitize_address) {
+ array_add(&p->asan_stack_locals, val);
+ }
}
if (zero_init) {