diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-05-07 10:21:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-07 10:21:16 +0100 |
| commit | 90a30a145af7a8f75f95fe38817667efb00452db (patch) | |
| tree | b35da071ab68e811fd7b34ffd5d4061873792061 /src/llvm_backend_stmt.cpp | |
| parent | 7c1a9f1e7a769f17fcd74699b0f4ea89a077b50b (diff) | |
| parent | 46e0c7ad74d0868d473dfd95a455dbe8a64bacbf (diff) | |
Merge pull request #5122 from Lperlind/asan-allocators
Add asan support for various allocators and stack unpoisoning
Diffstat (limited to 'src/llvm_backend_stmt.cpp')
| -rw-r--r-- | src/llvm_backend_stmt.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index 96a5d0db1..89737a454 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -2917,6 +2917,18 @@ gb_internal void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlo } defer (p->branch_location_pos = prev_token_pos); + // TODO(lucas): In LLVM 21 use the 'use-after-scope' asan option which does this for us. + if (kind == lbDeferExit_Return) { + for_array(i, p->asan_stack_locals) { + lbValue local = p->asan_stack_locals[i]; + + auto args = array_make<lbValue>(temporary_allocator(), 2); + args[0] = lb_emit_conv(p, local, t_rawptr); + args[1] = lb_const_int(p->module, t_int, type_size_of(local.type->Pointer.elem)); + lb_emit_runtime_call(p, "__asan_unpoison_memory_region", args); + } + } + isize count = p->defer_stmts.count; isize i = count; while (i --> 0) { |