Skip to content

Commit 83937dc

Browse files
Remove debug prints and add @bpfglobal support
1 parent 627ee92 commit 83937dc

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

pythonbpf/functions_pass.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ def process_bpf_chunk(func_node, module, return_type):
8484

8585
process_func_body(module, builder, func_node, func, ret_type)
8686

87-
print(func)
88-
print(module)
8987
return func
9088

9189

pythonbpf/globals_pass.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ def emit_globals(module: ir.Module, names: list[str]):
1616
g = module.get_global(name)
1717
else:
1818
g = ir.GlobalValue(module, ptr_ty, name)
19-
print("global emitted:", name)
20-
print(isinstance(g, ir.GlobalVariable))
21-
print(isinstance(g, ir.Function))
2219
elems.append(g.bitcast(ptr_ty))
2320

2421
gv = ir.GlobalVariable(module, used_array_ty, "llvm.compiler.used")
@@ -31,16 +28,19 @@ def globals_processing(tree, module: ir.Module):
3128
collected = ["LICENSE"]
3229

3330
for node in tree.body:
34-
if isinstance(node, ast.FunctionDef) and len(node.decorator_list) == 2:
35-
dec = node.decorator_list[1]
36-
if (
37-
isinstance(dec, ast.Call)
38-
and isinstance(dec.func, ast.Name)
39-
and dec.func.id == "section"
40-
and len(dec.args) == 1
41-
and isinstance(dec.args[0], ast.Constant)
42-
and isinstance(dec.args[0].value, str)
43-
):
44-
collected.append(node.name)
31+
if isinstance(node, ast.FunctionDef):
32+
for dec in node.decorator_list:
33+
if (
34+
isinstance(dec, ast.Call)
35+
and isinstance(dec.func, ast.Name)
36+
and dec.func.id == "section"
37+
and len(dec.args) == 1
38+
and isinstance(dec.args[0], ast.Constant)
39+
and isinstance(dec.args[0].value, str)
40+
):
41+
collected.append(node.name)
42+
43+
elif isinstance(dec, ast.Name) and dec.id == "bpfglobal":
44+
collected.append(node.name)
4545

4646
emit_globals(module, collected)

0 commit comments

Comments
 (0)