mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Allocate twice for map lookups
This commit is contained in:
@ -455,10 +455,17 @@ def allocate_mem(
|
||||
f"Pre-allocated variable {var_name} for struct {call_type}"
|
||||
)
|
||||
elif isinstance(rval.func, ast.Attribute):
|
||||
# Map method call
|
||||
ir_type = ir.PointerType(ir.IntType(64))
|
||||
var = builder.alloca(ir_type, name=var_name)
|
||||
|
||||
# declare an intermediate ptr type for map lookup
|
||||
ir_type = ir.IntType(64)
|
||||
var_tmp = builder.alloca(ir_type, name=f"{var_name}_tmp")
|
||||
# var.align = ir_type.width // 8
|
||||
logger.info(f"Pre-allocated variable {var_name} for map")
|
||||
logger.info(
|
||||
f"Pre-allocated variable {var_name} and {var_name}_tmp for map"
|
||||
)
|
||||
else:
|
||||
logger.info("Unsupported assignment call function type")
|
||||
continue
|
||||
@ -496,6 +503,9 @@ def allocate_mem(
|
||||
local_sym_tab[var_name] = LocalSymbol(var, ir_type, call_type)
|
||||
else:
|
||||
local_sym_tab[var_name] = LocalSymbol(var, ir_type)
|
||||
|
||||
if var_tmp:
|
||||
local_sym_tab[f"{var_name}_tmp"] = LocalSymbol(var_tmp, ir_type)
|
||||
return local_sym_tab
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user