@@ -575,16 +575,23 @@ check_cfg(cfg_builder *g) {
575
575
return SUCCESS ;
576
576
}
577
577
578
- /* Calculate the actual jump target from the target_label */
579
578
static int
580
- translate_jump_labels_to_targets (basicblock * entryblock )
579
+ get_max_label (basicblock * entryblock )
581
580
{
582
- int max_label = -1 ;
581
+ int lbl = -1 ;
583
582
for (basicblock * b = entryblock ; b != NULL ; b = b -> b_next ) {
584
- if (b -> b_label .id > max_label ) {
585
- max_label = b -> b_label .id ;
583
+ if (b -> b_label .id > lbl ) {
584
+ lbl = b -> b_label .id ;
586
585
}
587
586
}
587
+ return lbl ;
588
+ }
589
+
590
+ /* Calculate the actual jump target from the target_label */
591
+ static int
592
+ translate_jump_labels_to_targets (basicblock * entryblock )
593
+ {
594
+ int max_label = get_max_label (entryblock );
588
595
size_t mapsize = sizeof (basicblock * ) * (max_label + 1 );
589
596
basicblock * * label2block = (basicblock * * )PyMem_Malloc (mapsize );
590
597
if (!label2block ) {
@@ -2229,6 +2236,7 @@ is_exit_without_lineno(basicblock *b) {
2229
2236
return true;
2230
2237
}
2231
2238
2239
+
2232
2240
/* PEP 626 mandates that the f_lineno of a frame is correct
2233
2241
* after a frame terminates. It would be prohibitively expensive
2234
2242
* to continuously update the f_lineno field at runtime,
@@ -2242,6 +2250,9 @@ static int
2242
2250
duplicate_exits_without_lineno (cfg_builder * g )
2243
2251
{
2244
2252
assert (no_empty_basic_blocks (g ));
2253
+
2254
+ int next_lbl = get_max_label (g -> g_entryblock ) + 1 ;
2255
+
2245
2256
/* Copy all exit blocks without line number that are targets of a jump.
2246
2257
*/
2247
2258
basicblock * entryblock = g -> g_entryblock ;
@@ -2260,6 +2271,7 @@ duplicate_exits_without_lineno(cfg_builder *g)
2260
2271
target -> b_predecessors -- ;
2261
2272
new_target -> b_predecessors = 1 ;
2262
2273
new_target -> b_next = target -> b_next ;
2274
+ new_target -> b_label .id = next_lbl ++ ;
2263
2275
target -> b_next = new_target ;
2264
2276
}
2265
2277
}
0 commit comments