@@ -6328,10 +6328,9 @@ optimize_basic_block(basicblock *bb, PyObject *consts)
6328
6328
6329
6329
6330
6330
static void
6331
- clean_basic_block (basicblock * bb ) {
6332
- /* Remove NOPs. */
6331
+ clean_basic_block (basicblock * bb , int prev_lineno ) {
6332
+ /* Remove NOPs when legal to do so . */
6333
6333
int dest = 0 ;
6334
- int prev_lineno = -1 ;
6335
6334
for (int src = 0 ; src < bb -> b_iused ; src ++ ) {
6336
6335
int lineno = bb -> b_instr [src ].i_lineno ;
6337
6336
if (bb -> b_instr [src ].i_opcode == NOP ) {
@@ -6531,7 +6530,7 @@ optimize_cfg(struct assembler *a, PyObject *consts)
6531
6530
if (optimize_basic_block (b , consts )) {
6532
6531
return -1 ;
6533
6532
}
6534
- clean_basic_block (b );
6533
+ clean_basic_block (b , -1 );
6535
6534
assert (b -> b_predecessors == 0 );
6536
6535
}
6537
6536
if (mark_reachable (a )) {
@@ -6544,6 +6543,15 @@ optimize_cfg(struct assembler *a, PyObject *consts)
6544
6543
b -> b_nofallthrough = 0 ;
6545
6544
}
6546
6545
}
6546
+ basicblock * pred = NULL ;
6547
+ for (basicblock * b = a -> a_entry ; b != NULL ; b = b -> b_next ) {
6548
+ int prev_lineno = -1 ;
6549
+ if (pred && pred -> b_iused ) {
6550
+ prev_lineno = pred -> b_instr [pred -> b_iused - 1 ].i_lineno ;
6551
+ }
6552
+ clean_basic_block (b , prev_lineno );
6553
+ pred = b -> b_nofallthrough ? NULL : b ;
6554
+ }
6547
6555
eliminate_empty_basic_blocks (a -> a_entry );
6548
6556
/* Delete jump instructions made redundant by previous step. If a non-empty
6549
6557
block ends with a jump instruction, check if the next non-empty block
@@ -6571,7 +6579,7 @@ optimize_cfg(struct assembler *a, PyObject *consts)
6571
6579
case JUMP_ABSOLUTE :
6572
6580
case JUMP_FORWARD :
6573
6581
b_last_instr -> i_opcode = NOP ;
6574
- clean_basic_block (b );
6582
+ clean_basic_block (b , -1 );
6575
6583
maybe_empty_blocks = 1 ;
6576
6584
break ;
6577
6585
}
0 commit comments