diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-09-28 19:33:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-28 19:33:28 (GMT) |
commit | f580edcc6a4c528020afe46c753db713474acad6 (patch) | |
tree | ccc20e518bdb608d352ee87cfbd0c610c1973011 /Python | |
parent | b14f0ab51cb4851b25935279617e388456dcf716 (diff) | |
download | cpython-f580edcc6a4c528020afe46c753db713474acad6.zip cpython-f580edcc6a4c528020afe46c753db713474acad6.tar.gz cpython-f580edcc6a4c528020afe46c753db713474acad6.tar.bz2 |
gh-109889: fix compiler's redundant NOP detection to look past NOPs with no lineno when looking for the next instruction's lineno (#109987)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/flowgraph.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 9fe387c..e89ad39 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -1017,7 +1017,17 @@ remove_redundant_nops(basicblock *bb) { } /* or if last instruction in BB and next BB has same line number */ if (next) { - if (lineno == next->b_instr[0].i_loc.lineno) { + location next_loc = NO_LOCATION; + for (int next_i=0; next_i < next->b_iused; next_i++) { + 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 (lineno == next_loc.lineno) { continue; } } |