@@ -130,35 +130,27 @@ def _create_graph_functions(self):
130130 self ._create_graph_cleanup ()
131131
132132 def _compare_strings (self , str1 , str2 , length ):
133- same_ptr = self .builder .icmp_signed ('==' , str1 , str2 )
134-
133+ entry_block = self .builder .block
134+ loop_block = self .builder .block .parent .append_basic_block (name = "str_cmp_loop" )
135+ check_block = self .builder .block .parent .append_basic_block (name = "str_cmp_check" )
135136 true_block = self .builder .block .parent .append_basic_block (name = "strings_equal" )
136137 false_block = self .builder .block .parent .append_basic_block (name = "strings_not_equal" )
137- compare_block = self .builder .block .parent .append_basic_block (name = "compare_bytes" )
138138 merge_block = self .builder .block .parent .append_basic_block (name = "string_cmp_merge" )
139139
140- self .builder .cbranch (same_ptr , true_block , compare_block )
141-
142- self .builder .position_at_end (compare_block )
143140 i = self .builder .alloca (self .int_type , name = "str_cmp_i" )
144141 self .builder .store (ir .Constant (self .int_type , 0 ), i )
145-
146- loop_block = self .builder .block .parent .append_basic_block (name = "str_cmp_loop" )
147- check_block = self .builder .block .parent .append_basic_block (name = "str_cmp_check" )
148-
149142 self .builder .branch (loop_block )
150143
151144 self .builder .position_at_end (loop_block )
152145 i_val = self .builder .load (i )
153- loop_condition = self .builder .icmp_signed ('<' , i_val , length )
154- self .builder .cbranch (loop_condition , check_block , true_block )
146+ loop_cond = self .builder .icmp_signed ('<' , i_val , length )
147+ self .builder .cbranch (loop_cond , check_block , true_block )
155148
156149 self .builder .position_at_end (check_block )
157150 char1_ptr = self .builder .gep (str1 , [i_val ])
158151 char2_ptr = self .builder .gep (str2 , [i_val ])
159152 char1 = self .builder .load (char1_ptr )
160153 char2 = self .builder .load (char2_ptr )
161-
162154 chars_equal = self .builder .icmp_signed ('==' , char1 , char2 )
163155
164156 next_char_block = self .builder .block .parent .append_basic_block (name = "next_char" )
@@ -247,7 +239,7 @@ def _create_hash_functions(self):
247239 self .builder .position_at_end (loop_block )
248240
249241 current_val = self .builder .load (current )
250- is_null = self .builder .icmp_signed ('==' , current_val , ir .Constant (self .void_ptr , None ))
242+ is_null = self .builder .icmp_unsigned ('==' , current_val , ir .Constant (self .void_ptr , None ))
251243 self .builder .cbranch (is_null , not_found_block , check_block )
252244
253245 self .builder .position_at_end (check_block )
@@ -257,7 +249,7 @@ def _create_hash_functions(self):
257249 entry_key_len_ptr = self .builder .gep (entry_ptr , [ir .Constant (self .int_type , 0 ), ir .Constant (self .int_type , 1 )])
258250 entry_key_len = self .builder .load (entry_key_len_ptr )
259251
260- len_match = self .builder .icmp_signed ('==' , entry_key_len , key_len )
252+ len_match = self .builder .icmp_unsigned ('==' , entry_key_len , key_len )
261253
262254 content_check_block = self .hash_lookup .append_basic_block (name = "content_check" )
263255 next_block = self .hash_lookup .append_basic_block (name = "next_entry" )
@@ -298,8 +290,14 @@ def _create_node_functions(self):
298290 id_ptr = self .builder .gep (node_ptr , [ir .Constant (self .int_type , 0 ), ir .Constant (self .int_type , 0 )])
299291 self .builder .store (node_id , id_ptr )
300292
293+ name_buf_size = self .builder .zext (name_len , self .int64_type )
294+ name_buf = self .builder .call (self .malloc_func , [name_buf_size ])
295+ name_dest = self .builder .bitcast (name_buf , self .char_ptr )
296+ name_len_64 = self .builder .zext (name_len , self .int64_type )
297+ self .builder .call (self .memcpy_func , [name_dest , name_ptr , name_len_64 ])
298+
301299 name_field_ptr = self .builder .gep (node_ptr , [ir .Constant (self .int_type , 0 ), ir .Constant (self .int_type , 1 )])
302- self .builder .store (name_ptr , name_field_ptr )
300+ self .builder .store (name_dest , name_field_ptr )
303301
304302 name_len_ptr = self .builder .gep (node_ptr , [ir .Constant (self .int_type , 0 ), ir .Constant (self .int_type , 2 )])
305303 self .builder .store (name_len , name_len_ptr )
@@ -703,7 +701,6 @@ def _create_is_adjacent(self):
703701 self .builder .position_at_end (adj_check_block )
704702 entry_ptr = self .builder .gep (adj_array_typed , [i_val ])
705703 adj_node = self .builder .load (entry_ptr )
706-
707704 nodes_match = self .builder .icmp_signed ('==' , adj_node , node2_ptr )
708705 self .builder .cbranch (nodes_match , true_block , adj_next_block )
709706
@@ -1319,7 +1316,6 @@ def _remove_vertex_from_node_adjacency(self, node_ptr, vertex_name, vertex_name_
13191316
13201317 def _string_contains_substring (self , haystack , haystack_len , needle , needle_len ):
13211318
1322- # Define all basic blocks upfront
13231319 entry_block = self .builder .block
13241320 false_block = self .builder .block .parent .append_basic_block (name = "substr_false" )
13251321 search_block = self .builder .block .parent .append_basic_block (name = "substr_search" )
0 commit comments