@@ -9006,10 +9006,7 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts)
9006
9006
int oparg = inst -> i_oparg ;
9007
9007
int nextop = i + 1 < bb -> b_iused ? bb -> b_instr [i + 1 ].i_opcode : 0 ;
9008
9008
if (HAS_TARGET (inst -> i_opcode )) {
9009
- /* Skip over empty basic blocks. */
9010
- while (inst -> i_target -> b_iused == 0 ) {
9011
- inst -> i_target = inst -> i_target -> b_next ;
9012
- }
9009
+ assert (inst -> i_target -> b_iused > 0 );
9013
9010
target = & inst -> i_target -> b_instr [0 ];
9014
9011
assert (!IS_ASSEMBLER_OPCODE (target -> i_opcode ));
9015
9012
}
@@ -9233,22 +9230,12 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts)
9233
9230
return -1 ;
9234
9231
}
9235
9232
9236
- static bool
9237
- basicblock_has_lineno (const basicblock * bb ) {
9238
- for (int i = 0 ; i < bb -> b_iused ; i ++ ) {
9239
- if (bb -> b_instr [i ].i_loc .lineno > 0 ) {
9240
- return true;
9241
- }
9242
- }
9243
- return false;
9244
- }
9245
-
9246
- /* If this block ends with an unconditional jump to a small exit block that does
9247
- * not have linenos, then remove the jump and extend this block with the target.
9233
+ /* If this block ends with an unconditional jump to a small exit block, then
9234
+ * remove the jump and extend this block with the target.
9248
9235
* Returns 1 if extended, 0 if no change, and -1 on error.
9249
9236
*/
9250
9237
static int
9251
- extend_block (basicblock * bb ) {
9238
+ inline_small_exit_blocks (basicblock * bb ) {
9252
9239
struct instr * last = basicblock_last_instr (bb );
9253
9240
if (last == NULL ) {
9254
9241
return 0 ;
@@ -9258,10 +9245,6 @@ extend_block(basicblock *bb) {
9258
9245
}
9259
9246
basicblock * target = last -> i_target ;
9260
9247
if (basicblock_exits_scope (target ) && target -> b_iused <= MAX_COPY_SIZE ) {
9261
- if (basicblock_has_lineno (target )) {
9262
- /* copy only blocks without line number (like implicit 'return None's) */
9263
- return 0 ;
9264
- }
9265
9248
last -> i_opcode = NOP ;
9266
9249
for (int i = 0 ; i < target -> b_iused ; i ++ ) {
9267
9250
int index = basicblock_next_instr (bb );
@@ -9513,7 +9496,7 @@ optimize_cfg(cfg_builder *g, PyObject *consts, PyObject *const_cache)
9513
9496
}
9514
9497
eliminate_empty_basic_blocks (g );
9515
9498
for (basicblock * b = g -> g_entryblock ; b != NULL ; b = b -> b_next ) {
9516
- if (extend_block (b ) < 0 ) {
9499
+ if (inline_small_exit_blocks (b ) < 0 ) {
9517
9500
return -1 ;
9518
9501
}
9519
9502
}
@@ -9526,7 +9509,7 @@ optimize_cfg(cfg_builder *g, PyObject *consts, PyObject *const_cache)
9526
9509
assert (b -> b_predecessors == 0 );
9527
9510
}
9528
9511
for (basicblock * b = g -> g_entryblock ; b != NULL ; b = b -> b_next ) {
9529
- if (extend_block (b ) < 0 ) {
9512
+ if (inline_small_exit_blocks (b ) < 0 ) {
9530
9513
return -1 ;
9531
9514
}
9532
9515
}
0 commit comments