@@ -13,9 +13,9 @@ def emit_function(module: ir.Module, name: str):
1313 param .add_attribute ("nocapture" )
1414
1515 func .attributes .add ("nounwind" )
16- # func.attributes.add("\"frame-pointer\"=\"all\"")
17- # func.attributes.add("no-trapping-math", "true")
18- # func.attributes.add("stack-protector-buffer-size", "8")
16+ # func.attributes.add("\"frame-pointer\"=\"all\"")
17+ # func.attributes.add("no-trapping-math", "true")
18+ # func.attributes.add("stack-protector-buffer-size", "8")
1919
2020 block = func .append_basic_block (name = "entry" )
2121 builder = ir .IRBuilder (block )
@@ -70,17 +70,17 @@ def process_func_body(module, builder, func_node, func):
7070 # Handle print statement
7171 for arg in call .args :
7272 if isinstance (arg , ast .Constant ) and isinstance (arg .value , str ):
73- fmt_str = arg .value + "\n "
73+ fmt_str = arg .value + "\n " + " \0 "
7474 # Create a global variable for the format string
7575 fmt_gvar = ir .GlobalVariable (
7676 module , ir .ArrayType (ir .IntType (8 ), len (fmt_str )), name = f"{ func .name } ____fmt" )
7777 fmt_gvar .global_constant = True
78- fmt_gvar .initializer = ir .Constant (
78+ fmt_gvar .initializer = ir .Constant ( # type: ignore
7979 ir .ArrayType (ir .IntType (8 ), len (fmt_str )),
8080 bytearray (fmt_str .encode ("utf8" ))
8181 )
8282 fmt_gvar .linkage = "internal"
83- fmt_gvar .align = 1
83+ fmt_gvar .align = 1 # type: ignore
8484
8585 # Cast the global variable to i8*
8686 fmt_ptr = builder .bitcast (
@@ -129,6 +129,8 @@ def process_bpf_chunk(func_node, module):
129129
130130 func .linkage = "dso_local"
131131 func .attributes .add ("nounwind" )
132+ func .attributes .add ("noinline" )
133+ func .attributes .add ("optnone" )
132134
133135 if func_node .args .args :
134136 # Only look at the first argument for now
0 commit comments