Skip to content
Prev Previous commit
Next Next commit
make remove_redundant_nops_and_pairs safe
  • Loading branch information
iritkatriel committed Mar 22, 2023
commit ddb30038fa68d6af463be94960c2a1fc827694e6
6 changes: 5 additions & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -9326,6 +9326,10 @@ remove_redundant_nops_and_pairs(basicblock *entryblock)
struct cfg_instr *instr = NULL;
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
remove_redundant_nops(b);
if (IS_LABEL(b->b_label)) {
/* this block is a jump target, forget instr */
instr = NULL;
}
for (int i = 0; i < b->b_iused; i++) {
prev_instr = instr;
instr = &b->b_instr[i];
Expand All @@ -9347,7 +9351,7 @@ remove_redundant_nops_and_pairs(basicblock *entryblock)
done = false;
}
}
if (! BB_HAS_FALLTHROUGH(b)) {
if ((instr && is_jump(instr)) || !BB_HAS_FALLTHROUGH(b)) {
instr = NULL;
}
}
Expand Down