From 321415fa283e2bdb44ff8c7b847e9b1164404383 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Sun, 12 Oct 2025 00:33:07 +0530 Subject: [PATCH] Add update_max_temps_for_stmt in allocate_mem --- pythonbpf/functions/functions_pass.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pythonbpf/functions/functions_pass.py b/pythonbpf/functions/functions_pass.py index 264ce93..07fc9d4 100644 --- a/pythonbpf/functions/functions_pass.py +++ b/pythonbpf/functions/functions_pass.py @@ -414,6 +414,16 @@ def allocate_mem( module, builder, body, func, ret_type, map_sym_tab, local_sym_tab, structs_sym_tab ): double_alloc = False + max_temps_needed = 0 + + def update_max_temps_for_stmt(stmt): + nonlocal max_temps_needed + + for node in ast.walk(stmt): + if isinstance(node, ast.Call): + temps_needed = count_temps_in_call(node) + max_temps_needed = max(max_temps_needed, temps_needed) + for stmt in body: has_metadata = False if isinstance(stmt, ast.If):