diff options
author | Mark Shannon <mark@hotpy.org> | 2021-02-02 14:59:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 14:59:15 +0000 |
commit | 802b645e81a72399a7ef47ef000d468c775dcd3e (patch) | |
tree | 914f0e42d0231ae52caf1a436d269cff284631f5 /Python | |
parent | bpo-41748: Handles unquoted attributes with commas (#24072) (diff) | |
download | cpython-802b645e81a72399a7ef47ef000d468c775dcd3e.tar.gz cpython-802b645e81a72399a7ef47ef000d468c775dcd3e.tar.bz2 cpython-802b645e81a72399a7ef47ef000d468c775dcd3e.zip |
Only eliminate jumps to successor block if jump is unconditional. (GH-24417)
* Prevents elimination of the sole test of a value in statements like:
if x or True: ...
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/Python/compile.c b/Python/compile.c index 9927f5abfb9..a0a257fa6ba 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -6586,27 +6586,14 @@ optimize_cfg(struct assembler *a, PyObject *consts) for (basicblock *b = a->a_entry; b != NULL; b = b->b_next) { if (b->b_iused > 0) { struct instr *b_last_instr = &b->b_instr[b->b_iused - 1]; - if (b_last_instr->i_opcode == POP_JUMP_IF_FALSE || - b_last_instr->i_opcode == POP_JUMP_IF_TRUE || - b_last_instr->i_opcode == JUMP_ABSOLUTE || + if (b_last_instr->i_opcode == JUMP_ABSOLUTE || b_last_instr->i_opcode == JUMP_FORWARD) { if (b_last_instr->i_target == b->b_next) { assert(b->b_next->b_iused); b->b_nofallthrough = 0; - switch(b_last_instr->i_opcode) { - case POP_JUMP_IF_FALSE: - case POP_JUMP_IF_TRUE: - b_last_instr->i_opcode = POP_TOP; - b_last_instr->i_target = NULL; - b_last_instr->i_oparg = 0; - break; - case JUMP_ABSOLUTE: - case JUMP_FORWARD: - b_last_instr->i_opcode = NOP; - clean_basic_block(b, -1); - maybe_empty_blocks = 1; - break; - } + b_last_instr->i_opcode = NOP; + clean_basic_block(b, -1); + maybe_empty_blocks = 1; } } } |