Skip to content

Commit d8497b6

Browse files
committed
Move insertion of NOT_TAKEN to normalize_jumps
1 parent e389d6c commit d8497b6

File tree

3 files changed

+32
-37
lines changed

3 files changed

+32
-37
lines changed

Programs/test_frozenmain.h

Lines changed: 28 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/codegen.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,6 @@ codegen_addop_j(instr_sequence *seq, location loc,
409409
if (_PyInstructionSequence_Addop(seq, opcode, target.id, loc) != SUCCESS) {
410410
return ERROR;
411411
}
412-
if (IS_CONDITIONAL_JUMP_OPCODE(opcode) || opcode == FOR_ITER) {
413-
return _PyInstructionSequence_Addop(seq, NOT_TAKEN, 0, NO_LOCATION);
414-
}
415412
return SUCCESS;
416413
}
417414

Python/flowgraph.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,15 @@ no_redundant_jumps(cfg_builder *g) {
522522
static int
523523
normalize_jumps_in_block(cfg_builder *g, basicblock *b) {
524524
cfg_instr *last = basicblock_last_instr(b);
525-
if (last == NULL || !is_jump(last) ||
526-
IS_UNCONDITIONAL_JUMP_OPCODE(last->i_opcode)) {
525+
if (last == NULL || !IS_CONDITIONAL_JUMP_OPCODE(last->i_opcode)) {
527526
return SUCCESS;
528527
}
529528
assert(!IS_ASSEMBLER_OPCODE(last->i_opcode));
530529

531530
bool is_forward = last->i_target->b_visited == 0;
532531
if (is_forward) {
532+
RETURN_IF_ERROR(
533+
basicblock_addop(b, NOT_TAKEN, 0, NO_LOCATION));
533534
return SUCCESS;
534535
}
535536

@@ -557,12 +558,8 @@ normalize_jumps_in_block(cfg_builder *g, basicblock *b) {
557558
if (backwards_jump == NULL) {
558559
return ERROR;
559560
}
560-
assert(b->b_next->b_iused > 0);
561-
assert(b->b_next->b_instr[0].i_opcode == NOT_TAKEN);
562-
b->b_next->b_instr[0].i_opcode = NOP;
563-
b->b_next->b_instr[0].i_loc = NO_LOCATION;
564561
RETURN_IF_ERROR(
565-
basicblock_addop(backwards_jump, NOT_TAKEN, 0, last->i_loc));
562+
basicblock_addop(backwards_jump, NOT_TAKEN, 0, NO_LOCATION));
566563
RETURN_IF_ERROR(
567564
basicblock_add_jump(backwards_jump, JUMP, target, last->i_loc));
568565
last->i_opcode = reversed_opcode;

0 commit comments

Comments
 (0)