From 05660d46b49a96aac356bde4d6d3b372772aa2e2 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Thu, 24 Sep 2026 16:44:44 +0530 Subject: [PATCH] Core: The pool-duplication TODO after #104: free with opt, 8 bytes without Co-Authored-By: Claude Fable 5.1 --- pythonbpf/functions/functions_pass.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pythonbpf/functions/functions_pass.py b/pythonbpf/functions/functions_pass.py index 56d9f86..7ed0bae 100644 --- a/pythonbpf/functions/functions_pass.py +++ b/pythonbpf/functions/functions_pass.py @@ -150,11 +150,10 @@ def allocate_mem(compilation_context, builder, body, func, ret_type, local_sym_t # 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. Only the last-allocated pool stays in - # local_sym_tab; the others are unreferenced, but llc does not delete - # unreferenced allocas before frame layout (opt -O2 would, and the pipeline - # is llc only), so each duplicated temp slot costs its size in BPF stack: - # measured 8 bytes per i64 temp per nesting level. Fix: count recursively, - # allocate once at the top level. + # local_sym_tab; the others are unreferenced. The opt -O2 step (#104) + # deletes them, so with opt on PATH this costs nothing; on the no-opt + # fallback llc keeps them through frame layout, measured 8 bytes per i64 + # temp per nesting level. Fix: count recursively, allocate once at the top. allocate_temp_pool(builder, max_temps_needed, local_sym_tab) return local_sym_tab