summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-10-02 15:43:16 (GMT)
committerGitHub <noreply@github.com>2023-10-02 15:43:16 (GMT)
commit2b96102f29d2634a69b04cc782236cb12d8e3e56 (patch)
tree8dfa490d0a0cd13194b951de58d3f3e029788cf7 /Python
parentc7941034171cd608a0235731832b7784200dec70 (diff)
downloadcpython-2b96102f29d2634a69b04cc782236cb12d8e3e56.zip
cpython-2b96102f29d2634a69b04cc782236cb12d8e3e56.tar.gz
cpython-2b96102f29d2634a69b04cc782236cb12d8e3e56.tar.bz2
[3.12] gh-109889: fix compiler's redundant NOP detection to look past NOPs with no lineno when looking for the next instruction's lineno (GH-109987) (#110048)
gh-109889: fix compiler's redundant NOP detection to look past NOPs with no lineno when looking for the next instruction's lineno (GH-109987) (cherry picked from commit f580edcc6a4c528020afe46c753db713474acad6) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/flowgraph.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Python/flowgraph.c b/Python/flowgraph.c
index f860631..afcae31 100644
--- a/Python/flowgraph.c
+++ b/Python/flowgraph.c
@@ -981,7 +981,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;
}
}