diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-09-26 00:37:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-26 00:37:52 (GMT) |
commit | 538f505a3744ab1dd29861a859ab81ab65436144 (patch) | |
tree | 99bbda46c48539fcf8774af2e1b8131a8817c8cd /Python/flowgraph.c | |
parent | a19251764a3d0bd85e5217879a6b1cb1a649c25d (diff) | |
download | cpython-538f505a3744ab1dd29861a859ab81ab65436144.zip cpython-538f505a3744ab1dd29861a859ab81ab65436144.tar.gz cpython-538f505a3744ab1dd29861a859ab81ab65436144.tar.bz2 |
[3.12] gh-109823: Adjust labels in compiler when removing an empty basic block which is a jump target (GH-109839) (#109865)
gh-109823: Adjust labels in compiler when removing an empty basic block which is a jump target (GH-109839)
(cherry picked from commit d73c12b88c2275fd44e27c91c24f3ac85419d2b8)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Python/flowgraph.c')
-rw-r--r-- | Python/flowgraph.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Python/flowgraph.c b/Python/flowgraph.c index d19fe68..ccf078c 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -922,6 +922,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++) { @@ -931,7 +932,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); } } |