Skip to content

Commit cf6d362

Browse files
committed
remove unused variable and redundant NULL check
1 parent 73a6398 commit cf6d362

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

Python/compile.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7364,7 +7364,7 @@ mark_cold(basicblock *entryblock) {
73647364
for (int i = 0; i < b->b_iused; i++) {
73657365
struct instr *instr = &b->b_instr[i];
73667366
if (is_jump(instr)) {
7367-
assert(i == b->b_iused-1);
7367+
assert(i == b->b_iused - 1);
73687368
basicblock *target = b->b_instr[i].i_target;
73697369
if (!target->b_warm && !target->b_visited) {
73707370
*sp++ = target;
@@ -8322,7 +8322,7 @@ insert_instruction(basicblock *block, int pos, struct instr *instr) {
83228322
if (basicblock_next_instr(block) < 0) {
83238323
return -1;
83248324
}
8325-
for (int i = block->b_iused-1; i > pos; i--) {
8325+
for (int i = block->b_iused - 1; i > pos; i--) {
83268326
block->b_instr[i] = block->b_instr[i-1];
83278327
}
83288328
block->b_instr[pos] = *instr;
@@ -8520,21 +8520,19 @@ remove_redundant_jumps(cfg_builder *g) {
85208520
* of that jump. If it is, then the jump instruction is redundant and
85218521
* can be deleted.
85228522
*/
8523-
int removed = 0;
8523+
assert(no_empty_basic_blocks(g));
85248524
for (basicblock *b = g->g_entryblock; b != NULL; b = b->b_next) {
85258525
struct instr *last = basicblock_last_instr(b);
8526-
if (last != NULL) {
8527-
assert(!IS_ASSEMBLER_OPCODE(last->i_opcode));
8528-
if (IS_UNCONDITIONAL_JUMP_OPCODE(last->i_opcode)) {
8529-
if (last->i_target == NULL) {
8530-
PyErr_SetString(PyExc_SystemError, "jump with NULL target");
8531-
return -1;
8532-
}
8533-
if (last->i_target == b->b_next) {
8534-
assert(b->b_next->b_iused);
8535-
last->i_opcode = NOP;
8536-
removed++;
8537-
}
8526+
assert(last != NULL);
8527+
assert(!IS_ASSEMBLER_OPCODE(last->i_opcode));
8528+
if (IS_UNCONDITIONAL_JUMP_OPCODE(last->i_opcode)) {
8529+
if (last->i_target == NULL) {
8530+
PyErr_SetString(PyExc_SystemError, "jump with NULL target");
8531+
return -1;
8532+
}
8533+
if (last->i_target == b->b_next) {
8534+
assert(b->b_next->b_iused);
8535+
last->i_opcode = NOP;
85388536
}
85398537
}
85408538
}
@@ -9317,7 +9315,7 @@ check_cfg(cfg_builder *g) {
93179315
int opcode = b->b_instr[i].i_opcode;
93189316
assert(!IS_ASSEMBLER_OPCODE(opcode));
93199317
if (IS_TERMINATOR_OPCODE(opcode)) {
9320-
if (i != b->b_iused-1) {
9318+
if (i != b->b_iused - 1) {
93219319
PyErr_SetString(PyExc_SystemError, "malformed control flow graph.");
93229320
return -1;
93239321
}

0 commit comments

Comments
 (0)