Skip to content

Commit ba90af9

Browse files
committed
Allocate space for string consts
1 parent 35969c4 commit ba90af9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pythonbpf/functions_pass.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,14 @@ def allocate_mem(module, builder, body, func, ret_type, map_sym_tab, local_sym_t
370370
var.align = ir_type.width // 8
371371
print(
372372
f"Pre-allocated variable {var_name} of type c_int64")
373+
elif isinstance(rval.value, str):
374+
ir_type = ir.PointerType(ir.IntType(8))
375+
var = builder.alloca(ir_type, name=var_name)
376+
var.align = 8
377+
print(
378+
f"Pre-allocated variable {var_name} of type string")
373379
else:
374-
print("Unsupported constant type")
380+
print(f"Unsupported constant type")
375381
continue
376382
elif isinstance(rval, ast.BinOp):
377383
# Assume c_int64 for now

0 commit comments

Comments
 (0)