@@ -575,16 +575,23 @@ check_cfg(cfg_builder *g) {
575575 return SUCCESS ;
576576}
577577
578- /* Calculate the actual jump target from the target_label */
579578static int
580- translate_jump_labels_to_targets (basicblock * entryblock )
579+ get_max_label (basicblock * entryblock )
581580{
582- int max_label = -1 ;
581+ int lbl = -1 ;
583582 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 ;
586585 }
587586 }
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 );
588595 size_t mapsize = sizeof (basicblock * ) * (max_label + 1 );
589596 basicblock * * label2block = (basicblock * * )PyMem_Malloc (mapsize );
590597 if (!label2block ) {
@@ -2229,6 +2236,7 @@ is_exit_without_lineno(basicblock *b) {
22292236 return true;
22302237}
22312238
2239+
22322240/* PEP 626 mandates that the f_lineno of a frame is correct
22332241 * after a frame terminates. It would be prohibitively expensive
22342242 * to continuously update the f_lineno field at runtime,
@@ -2242,6 +2250,9 @@ static int
22422250duplicate_exits_without_lineno (cfg_builder * g )
22432251{
22442252 assert (no_empty_basic_blocks (g ));
2253+
2254+ int next_lbl = get_max_label (g -> g_entryblock ) + 1 ;
2255+
22452256 /* Copy all exit blocks without line number that are targets of a jump.
22462257 */
22472258 basicblock * entryblock = g -> g_entryblock ;
@@ -2260,6 +2271,7 @@ duplicate_exits_without_lineno(cfg_builder *g)
22602271 target -> b_predecessors -- ;
22612272 new_target -> b_predecessors = 1 ;
22622273 new_target -> b_next = target -> b_next ;
2274+ new_target -> b_label .id = next_lbl ++ ;
22632275 target -> b_next = new_target ;
22642276 }
22652277 }
0 commit comments