@@ -3591,8 +3591,19 @@ duplicate_exits_without_lineno(cfg_builder *g)
3591
3591
* Also reduces the size of the line number table,
3592
3592
* but has no impact on the generated line number events.
3593
3593
*/
3594
+
3595
+ static inline void
3596
+ maybe_propagate_location (basicblock * b , int i , location loc )
3597
+ {
3598
+ assert (b -> b_iused > i );
3599
+ if (b -> b_instr [i ].i_loc .lineno == NO_LOCATION .lineno ) {
3600
+ b -> b_instr [i ].i_loc = loc ;
3601
+ }
3602
+ }
3603
+
3594
3604
static void
3595
- propagate_line_numbers (basicblock * entryblock ) {
3605
+ propagate_line_numbers (basicblock * entryblock )
3606
+ {
3596
3607
for (basicblock * b = entryblock ; b != NULL ; b = b -> b_next ) {
3597
3608
cfg_instr * last = basicblock_last_instr (b );
3598
3609
if (last == NULL ) {
@@ -3601,26 +3612,21 @@ propagate_line_numbers(basicblock *entryblock) {
3601
3612
3602
3613
location prev_location = NO_LOCATION ;
3603
3614
for (int i = 0 ; i < b -> b_iused ; i ++ ) {
3604
- if (b -> b_instr [i ].i_loc .lineno == NO_LOCATION .lineno ) {
3605
- b -> b_instr [i ].i_loc = prev_location ;
3606
- }
3607
- else {
3608
- prev_location = b -> b_instr [i ].i_loc ;
3609
- }
3615
+ maybe_propagate_location (b , i , prev_location );
3616
+ prev_location = b -> b_instr [i ].i_loc ;
3610
3617
}
3611
3618
if (BB_HAS_FALLTHROUGH (b ) && b -> b_next -> b_predecessors == 1 ) {
3612
3619
if (b -> b_next -> b_iused > 0 ) {
3613
- if (b -> b_next -> b_instr [0 ].i_loc .lineno == NO_LOCATION .lineno ) {
3614
- b -> b_next -> b_instr [0 ].i_loc = prev_location ;
3615
- }
3620
+ maybe_propagate_location (b -> b_next , 0 , prev_location );
3616
3621
}
3617
3622
}
3618
3623
if (is_jump (last )) {
3619
3624
basicblock * target = last -> i_target ;
3625
+ while (target -> b_iused == 0 && target -> b_predecessors == 1 ) {
3626
+ target = target -> b_next ;
3627
+ }
3620
3628
if (target -> b_predecessors == 1 ) {
3621
- if (target -> b_instr [0 ].i_loc .lineno == NO_LOCATION .lineno ) {
3622
- target -> b_instr [0 ].i_loc = prev_location ;
3623
- }
3629
+ maybe_propagate_location (target , 0 , prev_location );
3624
3630
}
3625
3631
}
3626
3632
}
0 commit comments