GH-128533: Add NOT_TAKEN instruction after bytecode optimization. (GH-128554)

This commit is contained in:
Mark Shannon 2025-01-06 22:01:07 +00:00 committed by GitHub
parent b6c919b674
commit 2434fd2d50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 127 additions and 139 deletions

View file

@ -522,14 +522,15 @@ no_redundant_jumps(cfg_builder *g) {
static int
normalize_jumps_in_block(cfg_builder *g, basicblock *b) {
cfg_instr *last = basicblock_last_instr(b);
if (last == NULL || !is_jump(last) ||
IS_UNCONDITIONAL_JUMP_OPCODE(last->i_opcode)) {
if (last == NULL || !IS_CONDITIONAL_JUMP_OPCODE(last->i_opcode)) {
return SUCCESS;
}
assert(!IS_ASSEMBLER_OPCODE(last->i_opcode));
bool is_forward = last->i_target->b_visited == 0;
if (is_forward) {
RETURN_IF_ERROR(
basicblock_addop(b, NOT_TAKEN, 0, last->i_loc));
return SUCCESS;
}
@ -557,10 +558,6 @@ normalize_jumps_in_block(cfg_builder *g, basicblock *b) {
if (backwards_jump == NULL) {
return ERROR;
}
assert(b->b_next->b_iused > 0);
assert(b->b_next->b_instr[0].i_opcode == NOT_TAKEN);
b->b_next->b_instr[0].i_opcode = NOP;
b->b_next->b_instr[0].i_loc = NO_LOCATION;
RETURN_IF_ERROR(
basicblock_addop(backwards_jump, NOT_TAKEN, 0, last->i_loc));
RETURN_IF_ERROR(