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

(cherry picked from commit 7c6b7ade8d)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-05-10 14:01:17 -07:00 committed by GitHub
parent 6546af31ee
commit 6a17cdebe9
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