8000 bpo-42615: Delete redundant jump instructions that only bypass empty blocks by OxyMagnesium · Pull Request #23733 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42615: Delete redundant jump instructions that only bypass empty blocks #23733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure b_nofallthrough and b_reachable are valid
  • Loading branch information
OxyMagnesium committed Dec 16, 2020
commit 6b81038b0e4d9b79beed44887190087964d9e5f2
9 changes: 7 additions & 2 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -6437,6 +6437,7 @@ optimize_cfg(struct assembler *a, PyObject *consts)
for (basicblock *b = a->a_entry; b != NULL; b = b->b_next) {
if (b->b_reachable == 0) {
b->b_iused = 0;
b->b_nofallthrough = 0;
}
}
/* Delete jump instructions made redundant by previous step. If a non-empty
Expand All @@ -6453,8 +6454,6 @@ optimize_cfg(struct assembler *a, PyObject *consts)
b_last_instr->i_opcode == JUMP_FORWARD) {
basicblock *b_next_act = b->b_next;
while (b_next_act != NULL && b_next_act->b_iused == 0) {
/* Next line reqd to prevent assertion failure in stackdepth() */
b_next_act->b_nofallthrough = 0;
b_next_act = b_next_act->b_next;
}
if (b_last_instr->i_target == b_next_act) {
Expand All @@ -6472,6 +6471,12 @@ optimize_cfg(struct assembler *a, PyObject *consts)
clean_basic_block(b);
break;
}
/* The blocks after this one are now reachable through it */
b_next_act = b->b_next;
while (b_next_act != NULL && b_next_act->b_iused == 0) {
b_next_act->b_reachable = 1;
b_next_act = b_next_act->b_next;
}
}
}
}
Expand Down
0