mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Add double_alloc in alloc_mem
This commit is contained in:
@ -386,6 +386,7 @@ def process_stmt(
|
|||||||
def allocate_mem(
|
def allocate_mem(
|
||||||
module, builder, body, func, ret_type, map_sym_tab, local_sym_tab, structs_sym_tab
|
module, builder, body, func, ret_type, map_sym_tab, local_sym_tab, structs_sym_tab
|
||||||
):
|
):
|
||||||
|
double_alloc = False
|
||||||
for stmt in body:
|
for stmt in body:
|
||||||
has_metadata = False
|
has_metadata = False
|
||||||
if isinstance(stmt, ast.If):
|
if isinstance(stmt, ast.If):
|
||||||
@ -462,6 +463,7 @@ def allocate_mem(
|
|||||||
# declare an intermediate ptr type for map lookup
|
# declare an intermediate ptr type for map lookup
|
||||||
ir_type = ir.IntType(64)
|
ir_type = ir.IntType(64)
|
||||||
var_tmp = builder.alloca(ir_type, name=f"{var_name}_tmp")
|
var_tmp = builder.alloca(ir_type, name=f"{var_name}_tmp")
|
||||||
|
double_alloc = True
|
||||||
# var.align = ir_type.width // 8
|
# var.align = ir_type.width // 8
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Pre-allocated variable {var_name} and {var_name}_tmp for map"
|
f"Pre-allocated variable {var_name} and {var_name}_tmp for map"
|
||||||
@ -504,7 +506,7 @@ def allocate_mem(
|
|||||||
else:
|
else:
|
||||||
local_sym_tab[var_name] = LocalSymbol(var, ir_type)
|
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)
|
local_sym_tab[f"{var_name}_tmp"] = LocalSymbol(var_tmp, ir_type)
|
||||||
return local_sym_tab
|
return local_sym_tab
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user