Core: Note the per-nesting-level pool allocation as a TODO

Verified against the emitted BPF: the duplicate allocas never reach the
frame, so there is no runtime cost. Left as a TODO by agreement.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Pragyansh Chaturvedi
2026-09-19 15:29:53 +05:30
parent ce4908a1c1
commit 055a81b395

View File

@ -147,6 +147,13 @@ def allocate_mem(compilation_context, builder, body, func, ret_type, local_sym_t
elif isinstance(stmt, ast.Assign):
handle_assign_allocation(compilation_context, builder, stmt, local_sym_tab)
# TODO: allocate_mem is re-entered for every if body (handle_if_allocation),
# and each level allocates a pool of its own even though the top-level count
# already covers nested statements. The duplicates are unreferenced and LLVM
# deletes them (verified: the BPF frame is identical with and without the
# nesting), so this costs nothing at runtime; it is IR noise and a trap,
# since only the last-allocated pool stays in local_sym_tab. Fix: count
# recursively, allocate once at the top level.
allocate_temp_pool(builder, max_temps_needed, local_sym_tab)
return local_sym_tab