Skip to content

Commit 055a81b

Browse files
r41k0uclaude
andcommitted
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>
1 parent ce4908a commit 055a81b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎pythonbpf/functions/functions_pass.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ def update_max_temps_for_stmt(stmt):
147147
elif isinstance(stmt, ast.Assign):
148148
handle_assign_allocation(compilation_context, builder, stmt, local_sym_tab)
149149

150+
# TODO: allocate_mem is re-entered for every if body (handle_if_allocation),
151+
# and each level allocates a pool of its own even though the top-level count
152+
# already covers nested statements. The duplicates are unreferenced and LLVM
153+
# deletes them (verified: the BPF frame is identical with and without the
154+
# nesting), so this costs nothing at runtime; it is IR noise and a trap,
155+
# since only the last-allocated pool stays in local_sym_tab. Fix: count
156+
# recursively, allocate once at the top level.
150157
allocate_temp_pool(builder, max_temps_needed, local_sym_tab)
151158

152159
return local_sym_tab

0 commit comments

Comments
 (0)