@@ -34,6 +34,7 @@ def bpf_ktime_get_ns_emitter(
3434 func ,
3535 local_sym_tab = None ,
3636 struct_sym_tab = None ,
37+ map_sym_tab = None ,
3738):
3839 """
3940 Emit LLVM IR for bpf_ktime_get_ns helper function call.
@@ -56,6 +57,7 @@ def bpf_map_lookup_elem_emitter(
5657 func ,
5758 local_sym_tab = None ,
5859 struct_sym_tab = None ,
60+ map_sym_tab = None ,
5961):
6062 """
6163 Emit LLVM IR for bpf_map_lookup_elem helper function call.
@@ -65,12 +67,16 @@ def bpf_map_lookup_elem_emitter(
6567 f"Map lookup expects exactly one argument (key), got { len (call .args )} "
6668 )
6769 key_ptr = get_or_create_ptr_from_arg (
68- func , module , call .args [0 ], builder , local_sym_tab , struct_sym_tab
70+ func , module , call .args [0 ], builder , local_sym_tab , map_sym_tab , struct_sym_tab
6971 )
7072 map_void_ptr = builder .bitcast (map_ptr , ir .PointerType ())
7173
74+ # TODO: I have changed the return typr to i64*, as we are
75+ # allocating space for that type in allocate_mem. This is
76+ # temporary, and we will honour other widths later. But this
77+ # allows us to have cool binary ops on the returned value.
7278 fn_type = ir .FunctionType (
73- ir .PointerType (), # Return type: void*
79+ ir .PointerType (ir . IntType ( 64 ) ), # Return type: void*
7480 [ir .PointerType (), ir .PointerType ()], # Args: (void*, void*)
7581 var_arg = False ,
7682 )
@@ -93,6 +99,7 @@ def bpf_printk_emitter(
9399 func ,
94100 local_sym_tab = None ,
95101 struct_sym_tab = None ,
102+ map_sym_tab = None ,
96103):
97104 """Emit LLVM IR for bpf_printk helper function call."""
98105 if not hasattr (func , "_fmt_counter" ):
@@ -140,6 +147,7 @@ def bpf_map_update_elem_emitter(
140147 func ,
141148 local_sym_tab = None ,
142149 struct_sym_tab = None ,
150+ map_sym_tab = None ,
143151):
144152 """
145153 Emit LLVM IR for bpf_map_update_elem helper function call.
@@ -155,10 +163,10 @@ def bpf_map_update_elem_emitter(
155163 flags_arg = call .args [2 ] if len (call .args ) > 2 else None
156164
157165 key_ptr = get_or_create_ptr_from_arg (
158- func , module , key_arg , builder , local_sym_tab , struct_sym_tab
166+ func , module , key_arg , builder , local_sym_tab , map_sym_tab , struct_sym_tab
159167 )
160168 value_ptr = get_or_create_ptr_from_arg (
161- func , module , value_arg , builder , local_sym_tab , struct_sym_tab
169+ func , module , value_arg , builder , local_sym_tab , map_sym_tab , struct_sym_tab
162170 )
163171 flags_val = get_flags_val (flags_arg , builder , local_sym_tab )
164172
@@ -194,6 +202,7 @@ def bpf_map_delete_elem_emitter(
194202 func ,
195203 local_sym_tab = None ,
196204 struct_sym_tab = None ,
205+ map_sym_tab = None ,
197206):
198207 """
199208 Emit LLVM IR for bpf_map_delete_elem helper function call.
@@ -204,7 +213,7 @@ def bpf_map_delete_elem_emitter(
204213 f"Map delete expects exactly one argument (key), got { len (call .args )} "
205214 )
206215 key_ptr = get_or_create_ptr_from_arg (
207- func , module , call .args [0 ], builder , local_sym_tab , struct_sym_tab
216+ func , module , call .args [0 ], builder , local_sym_tab , map_sym_tab , struct_sym_tab
208217 )
209218 map_void_ptr = builder .bitcast (map_ptr , ir .PointerType ())
210219
@@ -233,6 +242,7 @@ def bpf_get_current_pid_tgid_emitter(
233242 func ,
234243 local_sym_tab = None ,
235244 struct_sym_tab = None ,
245+ map_sym_tab = None ,
236246):
237247 """
238248 Emit LLVM IR for bpf_get_current_pid_tgid helper function call.
@@ -259,6 +269,7 @@ def bpf_perf_event_output_handler(
259269 func ,
260270 local_sym_tab = None ,
261271 struct_sym_tab = None ,
272+ map_sym_tab = None ,
262273):
263274 if len (call .args ) != 1 :
264275 raise ValueError (
@@ -323,6 +334,7 @@ def invoke_helper(method_name, map_ptr=None):
323334 func ,
324335 local_sym_tab ,
325336 struct_sym_tab ,
337+ map_sym_tab ,
326338 )
327339
328340 # Handle direct function calls (e.g., print(), ktime())
0 commit comments