mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
gh-109823: Adjust labels in compiler when removing an empty basic block which is a jump target (#109839)
This commit is contained in:
parent
88a6137cdb
commit
d73c12b88c
3 changed files with 15 additions and 1 deletions
|
@ -960,6 +960,7 @@ eliminate_empty_basic_blocks(cfg_builder *g) {
|
|||
while(g->g_entryblock && g->g_entryblock->b_iused == 0) {
|
||||
g->g_entryblock = g->g_entryblock->b_next;
|
||||
}
|
||||
int next_lbl = get_max_label(g->g_entryblock) + 1;
|
||||
for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
|
||||
assert(b->b_iused > 0);
|
||||
for (int i = 0; i < b->b_iused; i++) {
|
||||
|
@ -969,7 +970,13 @@ eliminate_empty_basic_blocks(cfg_builder *g) {
|
|||
while (target->b_iused == 0) {
|
||||
target = target->b_next;
|
||||
}
|
||||
instr->i_target = target;
|
||||
if (instr->i_target != target) {
|
||||
if (!IS_LABEL(target->b_label)) {
|
||||
target->b_label.id = next_lbl++;
|
||||
}
|
||||
instr->i_target = target;
|
||||
instr->i_oparg = target->b_label.id;
|
||||
}
|
||||
assert(instr->i_target && instr->i_target->b_iused > 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue