From 1d517d4e09abedeb5c90b56d32ebb444550275f9 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Fri, 10 Oct 2025 12:28:45 +0530 Subject: [PATCH] Add double_alloc in alloc_mem --- pythonbpf/functions/functions_pass.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pythonbpf/functions/functions_pass.py b/pythonbpf/functions/functions_pass.py index 6c2de1a..a1414ea 100644 --- a/pythonbpf/functions/functions_pass.py +++ b/pythonbpf/functions/functions_pass.py @@ -386,6 +386,7 @@ def process_stmt( def allocate_mem( module, builder, body, func, ret_type, map_sym_tab, local_sym_tab, structs_sym_tab ): + double_alloc = False for stmt in body: has_metadata = False if isinstance(stmt, ast.If): @@ -462,6 +463,7 @@ def allocate_mem( # declare an intermediate ptr type for map lookup ir_type = ir.IntType(64) var_tmp = builder.alloca(ir_type, name=f"{var_name}_tmp") + double_alloc = True # var.align = ir_type.width // 8 logger.info( f"Pre-allocated variable {var_name} and {var_name}_tmp for map" @@ -504,7 +506,7 @@ def allocate_mem( else: local_sym_tab[var_name] = LocalSymbol(var, ir_type) - if var_tmp: + if double_alloc: local_sym_tab[f"{var_name}_tmp"] = LocalSymbol(var_tmp, ir_type) return local_sym_tab