gh-92619: Fix bug where the compiler duplicates exit blocks unnecessarily (GH-92620)

This commit is contained in:
Irit Katriel 2022-05-10 13:36:08 +01:00 committed by GitHub
parent eef47d5bc7
commit 7c6b7ade8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 16 deletions

View file

@ -9280,7 +9280,15 @@ trim_unused_consts(struct compiler *c, struct assembler *a, PyObject *consts)
static inline int
is_exit_without_lineno(basicblock *b) {
return b->b_exit && b->b_instr[0].i_lineno < 0;
if (!b->b_exit) {
return 0;
}
for (int i = 0; i < b->b_iused; i++) {
if (b->b_instr[i].i_lineno >= 0) {
return 0;
}
}
return 1;
}
/* PEP 626 mandates that the f_lineno of a frame is correct