Skip to content

Commit 1d517d4

Browse files
committed
Add double_alloc in alloc_mem
1 parent 047f361 commit 1d517d4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pythonbpf/functions/functions_pass.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def process_stmt(
386386
def allocate_mem(
387387
module, builder, body, func, ret_type, map_sym_tab, local_sym_tab, structs_sym_tab
388388
):
389+
double_alloc = False
389390
for stmt in body:
390391
has_metadata = False
391392
if isinstance(stmt, ast.If):
@@ -462,6 +463,7 @@ def allocate_mem(
462463
# declare an intermediate ptr type for map lookup
463464
ir_type = ir.IntType(64)
464465
var_tmp = builder.alloca(ir_type, name=f"{var_name}_tmp")
466+
double_alloc = True
465467
# var.align = ir_type.width // 8
466468
logger.info(
467469
f"Pre-allocated variable {var_name} and {var_name}_tmp for map"
@@ -504,7 +506,7 @@ def allocate_mem(
504506
else:
505507
local_sym_tab[var_name] = LocalSymbol(var, ir_type)
506508

507-
if var_tmp:
509+
if double_alloc:
508510
local_sym_tab[f"{var_name}_tmp"] = LocalSymbol(var_tmp, ir_type)
509511
return local_sym_tab
510512

0 commit comments

Comments
 (0)