Skip to content

Commit 79f0949

Browse files
committed
Fix calling conventions changed by structs
1 parent a137169 commit 79f0949

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

pythonbpf/bpf_helper_handler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .expr_pass import eval_expr
44

55

6-
def bpf_ktime_get_ns_emitter(call, map_ptr, module, builder, func, local_sym_tab=None):
6+
def bpf_ktime_get_ns_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, local_var_metadata=None):
77
"""
88
Emit LLVM IR for bpf_ktime_get_ns helper function call.
99
"""
@@ -16,7 +16,7 @@ def bpf_ktime_get_ns_emitter(call, map_ptr, module, builder, func, local_sym_tab
1616
return result
1717

1818

19-
def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None):
19+
def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None, local_var_metadata=None):
2020
"""
2121
Emit LLVM IR for bpf_map_lookup_elem helper function call.
2222
"""
@@ -63,7 +63,7 @@ def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, func, local_sym_
6363
return result
6464

6565

66-
def bpf_printk_emitter(call, map_ptr, module, builder, func, local_sym_tab=None):
66+
def bpf_printk_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, local_var_metadata=None):
6767
if not hasattr(func, "_fmt_counter"):
6868
func._fmt_counter = 0
6969

@@ -172,7 +172,7 @@ def bpf_printk_emitter(call, map_ptr, module, builder, func, local_sym_tab=None)
172172
ir.IntType(32), len(fmt_str))], tail=True)
173173

174174

175-
def bpf_map_update_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None):
175+
def bpf_map_update_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None, local_var_metadata=None):
176176
"""
177177
Emit LLVM IR for bpf_map_update_elem helper function call.
178178
Expected call signature: map.update(key, value, flags=0)
@@ -268,7 +268,7 @@ def bpf_map_update_elem_emitter(call, map_ptr, module, builder, func, local_sym_
268268
return result
269269

270270

271-
def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None):
271+
def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None, local_var_metadata=None):
272272
"""
273273
Emit LLVM IR for bpf_map_delete_elem helper function call.
274274
Expected call signature: map.delete(key)
@@ -323,7 +323,7 @@ def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, func, local_sym_
323323
return result
324324

325325

326-
def bpf_get_current_pid_tgid_emitter(call, map_ptr, module, builder, func, local_sym_tab=None):
326+
def bpf_get_current_pid_tgid_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, local_var_metadata=None):
327327
"""
328328
Emit LLVM IR for bpf_get_current_pid_tgid helper function call.
329329
"""

pythonbpf/functions_pass.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def handle_cond(func, module, builder, cond, local_sym_tab, map_sym_tab):
222222
return None
223223

224224

225-
def handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab):
225+
def handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab, structs_sym_tab=None):
226226
"""Handle if statements in the function body."""
227227
print("Handling if statement")
228228
start = builder.block.parent
@@ -243,15 +243,15 @@ def handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab):
243243
builder.position_at_end(then_block)
244244
for s in stmt.body:
245245
process_stmt(func, module, builder, s,
246-
local_sym_tab, map_sym_tab, False)
246+
local_sym_tab, map_sym_tab, structs_sym_tab, False)
247247
if not builder.block.is_terminated:
248248
builder.branch(merge_block)
249249

250250
if else_block:
251251
builder.position_at_end(else_block)
252252
for s in stmt.orelse:
253253
process_stmt(func, module, builder, s,
254-
local_sym_tab, map_sym_tab, False)
254+
local_sym_tab, map_sym_tab, structs_sym_tab, False)
255255
if not builder.block.is_terminated:
256256
builder.branch(merge_block)
257257

@@ -269,7 +269,8 @@ def process_stmt(func, module, builder, stmt, local_sym_tab, map_sym_tab, struct
269269
elif isinstance(stmt, ast.AugAssign):
270270
raise SyntaxError("Augmented assignment not supported")
271271
elif isinstance(stmt, ast.If):
272-
handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab)
272+
handle_if(func, module, builder, stmt, map_sym_tab,
273+
local_sym_tab, structs_sym_tab)
273274
elif isinstance(stmt, ast.Return):
274275
if stmt.value is None:
275276
builder.ret(ir.Constant(ir.IntType(32), 0))

0 commit comments

Comments
 (0)