diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 3781f9bbfd1241..2fc90b8877b475 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -263,9 +263,8 @@ dump_instr(cfg_instr *i) if (HAS_TARGET(i->i_opcode)) { sprintf(arg, "target: %p [%d] ", i->i_target, i->i_oparg); } - fprintf(stderr, "line: %d%s, %s (%d) %s%s\n", - i->i_loc.lineno, i->i_loc_propagated ? "(<-)" : "", - _PyOpcode_OpName[i->i_opcode], i->i_opcode, arg, jump); + fprintf(stderr, "line: %d, %s (%d) %s%s\n", + i->i_loc.lineno, _PyOpcode_OpName[i->i_opcode], i->i_opcode, arg, jump); } static inline int @@ -939,15 +938,6 @@ label_exception_targets(basicblock *entryblock) { PyMem_Free(except_stack); } } - - for (basicblock *b = entryblock; b != NULL; b = b->b_next) { - for (int i = 0; i < b->b_iused; i++) { - cfg_instr *instr = &b->b_instr[i]; - if (instr->i_opcode == POP_BLOCK) { - INSTR_SET_OP0(instr, NOP); - } - } - } #ifdef Py_DEBUG for (basicblock *b = entryblock; b != NULL; b = b->b_next) { assert(b->b_exceptstack == NULL); @@ -1016,9 +1006,8 @@ basicblock_remove_redundant_nops(basicblock *bb) { int dest = 0; int prev_lineno = -1; for (int src = 0; src < bb->b_iused; src++) { - cfg_instr *src_instr = &bb->b_instr[src]; - int lineno = src_instr->i_loc.lineno; - if (src_instr->i_opcode == NOP) { + int lineno = bb->b_instr[src].i_loc.lineno; + if (bb->b_instr[src].i_opcode == NOP) { /* Eliminate no-op if it doesn't have a line number */ if (lineno < 0) { continue; @@ -1029,35 +1018,30 @@ basicblock_remove_redundant_nops(basicblock *bb) { } /* or, if the next instruction has same line number or no line number */ if (src < bb->b_iused - 1) { - cfg_instr *next_instr = &bb->b_instr[src + 1]; - int next_lineno = next_instr->i_loc.lineno; + int next_lineno = bb->b_instr[src+1].i_loc.lineno; if (next_lineno == lineno) { - next_instr->i_loc_propagated = src_instr->i_loc_propagated; continue; } if (next_lineno < 0) { - next_instr->i_loc = src_instr->i_loc; - next_instr->i_loc_propagated = src_instr->i_loc_propagated; + bb->b_instr[src+1].i_loc = bb->b_instr[src].i_loc; continue; } } else { - /* or if last instruction in BB and next BB has same line number */ basicblock *next = next_nonempty_block(bb->b_next); + /* or if last instruction in BB and next BB has same line number */ if (next) { - cfg_instr *next_instr = NULL; + location next_loc = NO_LOCATION; for (int next_i=0; next_i < next->b_iused; next_i++) { - next_instr = &next->b_instr[next_i]; - if (next_instr->i_opcode == NOP && - next_instr->i_loc.lineno == NO_LOCATION.lineno) - { + cfg_instr *instr = &next->b_instr[next_i]; + if (instr->i_opcode == NOP && instr->i_loc.lineno == NO_LOCATION.lineno) { /* Skip over NOPs without location, they will be removed */ continue; } + next_loc = instr->i_loc; break; } - if (next_instr && lineno == next_instr->i_loc.lineno) { - next_instr->i_loc_propagated = src_instr->i_loc_propagated; + if (lineno == next_loc.lineno) { continue; } } @@ -2320,7 +2304,7 @@ convert_pseudo_ops(cfg_builder *g) for (basicblock *b = entryblock; b != NULL; b = b->b_next) { for (int i = 0; i < b->b_iused; i++) { cfg_instr *instr = &b->b_instr[i]; - if (is_block_push(instr)) { + if (is_block_push(instr) || instr->i_opcode == POP_BLOCK) { INSTR_SET_OP0(instr, NOP); } else if (instr->i_opcode == LOAD_CLOSURE) {