diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-08-12 15:35:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-12 15:35:09 (GMT) |
commit | 41757bfabd26ef1d01dcde1d2bbf90e1a8d9d62c (patch) | |
tree | f69e98b693aebea38210d85be8e908e2c90cc89b /Python | |
parent | 7da4937748eb588bb0e977839061ce76cab1b252 (diff) | |
download | cpython-41757bfabd26ef1d01dcde1d2bbf90e1a8d9d62c.zip cpython-41757bfabd26ef1d01dcde1d2bbf90e1a8d9d62c.tar.gz cpython-41757bfabd26ef1d01dcde1d2bbf90e1a8d9d62c.tar.bz2 |
gh-95922: compiler's eliminate_empty_basic_blocks ignores the last block of the compilation unit (GH-95924)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Python/compile.c b/Python/compile.c index a971b09..3dec7b5 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -9349,17 +9349,13 @@ eliminate_empty_basic_blocks(basicblock *entryblock) { /* Eliminate empty blocks */ for (basicblock *b = entryblock; b != NULL; b = b->b_next) { basicblock *next = b->b_next; - if (next) { - while (next->b_iused == 0 && next->b_next) { - next = next->b_next; - } - b->b_next = next; + while (next && next->b_iused == 0) { + next = next->b_next; } + b->b_next = next; } for (basicblock *b = entryblock; b != NULL; b = b->b_next) { - if (b->b_iused == 0) { - continue; - } + assert(b->b_iused > 0); for (int i = 0; i < b->b_iused; i++) { struct instr *instr = &b->b_instr[i]; if (HAS_TARGET(instr->i_opcode)) { @@ -9368,6 +9364,7 @@ eliminate_empty_basic_blocks(basicblock *entryblock) { target = target->b_next; } instr->i_target = target; + assert(instr->i_target && instr->i_target->b_iused > 0); } } } |