@@ -60,22 +60,30 @@ static void gather_exiting_nodes(LoopTree* lt, const CFNode* entry, const CFNode
60
60
}
61
61
}
62
62
63
- static void find_unbound_vars (const Node * node , struct Dict * bound_set , struct Dict * free_set , struct List * leaking ) {
63
+ static bool find_in_nodes (Nodes nodes , const Node * n ) {
64
+ for (size_t i = 0 ; i < nodes .count ; i ++ )
65
+ if (nodes .nodes [i ] == n )
66
+ return true;
67
+ return false;
68
+ }
69
+
70
+ static void find_unbound_vars (const Node * loop_header , const Node * exiting_node , struct Dict * bound_set , struct Dict * free_set , struct List * leaking ) {
64
71
const Node * free_post ;
65
72
size_t i = 0 ;
73
+ Nodes ignore = get_abstraction_params (loop_header );
66
74
while (dict_iter (free_set , & i , & free_post , NULL )) {
67
75
const Node * bound_pre ;
68
76
size_t j = 0 ;
69
77
while (dict_iter (bound_set , & j , & bound_pre , NULL )) {
70
- if (bound_pre == free_post ) {
78
+ if (bound_pre == free_post && ! find_in_nodes ( ignore , bound_pre ) ) {
71
79
goto next ;
72
80
}
73
81
}
74
82
75
83
log_string (DEBUGVV , "Found variable used outside it's control scope: " );
76
84
log_node (DEBUGVV , free_post );
77
85
log_string (DEBUGVV , " (original:" );
78
- log_node (DEBUGVV , node );
86
+ log_node (DEBUGVV , exiting_node );
79
87
log_string (DEBUGVV , " )\n" );
80
88
81
89
append_list (const Node * , leaking , free_post );
@@ -117,7 +125,7 @@ static const Node* process_abstraction(Context* ctx, const Node* node) {
117
125
gather_exiting_nodes (ctx -> current_looptree , current_node , current_node , exiting_nodes );
118
126
119
127
for (size_t i = 0 ; i < entries_count_list (exiting_nodes ); i ++ ) {
120
- debugv_print ("Node %s exits the loop headed at %s\n" , get_abstraction_name (read_list (CFNode * , exiting_nodes )[i ]-> node ), get_abstraction_name (node ));
128
+ debugv_print ("Node %s exits the loop headed at %s\n" , get_abstraction_name_safe (read_list (CFNode * , exiting_nodes )[i ]-> node ), get_abstraction_name_safe (node ));
121
129
}
122
130
123
131
BodyBuilder * outer_bb = begin_body (arena );
@@ -148,7 +156,7 @@ static const Node* process_abstraction(Context* ctx, const Node* node) {
148
156
CFNode * cf_post = cfg_lookup (ctx -> fwd_cfg , exiting_node -> node );
149
157
CFNodeVariables * post = * find_value_dict (CFNode * , CFNodeVariables * , ctx -> live_vars , cf_post );
150
158
leaking [i ] = new_list (const Type * );
151
- find_unbound_vars (exiting_node -> node , pre -> bound_set , post -> free_set , leaking [i ]);
159
+ find_unbound_vars (node , exiting_node -> node , pre -> bound_set , post -> free_set , leaking [i ]);
152
160
153
161
size_t leaking_count = entries_count_list (leaking [i ]);
154
162
LARRAY (const Node * , exit_fwd_allocas_tmp , leaking_count );
@@ -267,7 +275,7 @@ static const Node* process_abstraction(Context* ctx, const Node* node) {
267
275
268
276
destroy_dict (rewriter -> map );
269
277
rewriter -> map = old_map ;
270
- register_processed_list (rewriter , get_abstraction_params (node ), nparams );
278
+ // register_processed_list(rewriter, get_abstraction_params(node), nparams);
271
279
272
280
// restore the old context
273
281
for (size_t i = 0 ; i < exiting_nodes_count ; i ++ ) {
@@ -321,7 +329,7 @@ static const Node* process_abstraction(Context* ctx, const Node* node) {
321
329
recovered_args [j ] = gen_load (exit_recover_bb , exit_param_allocas [i ].nodes [j ]);
322
330
323
331
exit_numbers [i ] = int32_literal (arena , i );
324
- Node * exit_bb = basic_block (arena , fn , empty (arena ), format_string_arena (arena -> arena , "exit_recover_values_%s" , get_abstraction_name (exiting_node -> node )));
332
+ Node * exit_bb = basic_block (arena , fn , empty (arena ), format_string_arena (arena -> arena , "exit_recover_values_%s" , get_abstraction_name_safe (exiting_node -> node )));
325
333
if (recreated_exit -> tag == BasicBlock_TAG ) {
326
334
exit_bb -> payload .basic_block .body = finish_body (exit_recover_bb , jump (arena , (Jump ) {
327
335
.target = recreated_exit ,
@@ -502,7 +510,7 @@ static const Node* process_node(Context* ctx, const Node* node) {
502
510
.yield_types = yield_types
503
511
}), true), "jp_postdom" );
504
512
505
- Node * pre_join = basic_block (arena , fn , exit_args , format_string_arena (arena -> arena , "merge_%s_%s" , get_abstraction_name (ctx -> current_abstraction ) , get_abstraction_name (idom )));
513
+ Node * pre_join = basic_block (arena , fn , exit_args , format_string_arena (arena -> arena , "merge_%s_%s" , get_abstraction_name_safe (ctx -> current_abstraction ) , get_abstraction_name_safe (idom )));
506
514
pre_join -> payload .basic_block .body = join (arena , (Join ) {
507
515
.join_point = join_token ,
508
516
.args = exit_args
0 commit comments