mirror of https://github.com/python/cpython.git
gh-95922: compiler's eliminate_empty_basic_blocks ignores the last block of the compilation unit (GH-95924)
This commit is contained in:
parent
7da4937748
commit
41757bfabd
|
@ -0,0 +1,2 @@
|
||||||
|
Fixed bug where the compiler's ``eliminate_empty_basic_blocks`` function
|
||||||
|
ignores the last block of the code unit.
|
|
@ -9349,17 +9349,13 @@ eliminate_empty_basic_blocks(basicblock *entryblock) {
|
||||||
/* Eliminate empty blocks */
|
/* Eliminate empty blocks */
|
||||||
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
|
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
|
||||||
basicblock *next = b->b_next;
|
basicblock *next = b->b_next;
|
||||||
if (next) {
|
while (next && next->b_iused == 0) {
|
||||||
while (next->b_iused == 0 && next->b_next) {
|
|
||||||
next = next->b_next;
|
next = next->b_next;
|
||||||
}
|
}
|
||||||
b->b_next = next;
|
b->b_next = next;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
|
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
|
||||||
if (b->b_iused == 0) {
|
assert(b->b_iused > 0);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < b->b_iused; i++) {
|
for (int i = 0; i < b->b_iused; i++) {
|
||||||
struct instr *instr = &b->b_instr[i];
|
struct instr *instr = &b->b_instr[i];
|
||||||
if (HAS_TARGET(instr->i_opcode)) {
|
if (HAS_TARGET(instr->i_opcode)) {
|
||||||
|
@ -9368,6 +9364,7 @@ eliminate_empty_basic_blocks(basicblock *entryblock) {
|
||||||
target = target->b_next;
|
target = target->b_next;
|
||||||
}
|
}
|
||||||
instr->i_target = target;
|
instr->i_target = target;
|
||||||
|
assert(instr->i_target && instr->i_target->b_iused > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue