Skip to content

Commit

Permalink
Prevent overwritten const value
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfkda committed Nov 12, 2023
1 parent cf28c2c commit d20d5c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cc/arch/aarch64/ir_aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,9 @@ void tweak_irs(FuncBackend *fnbe) {
if (ir->opr2->flag & VRF_CONST) {
if (ir->opr2->fixnum < 0) {
ir->kind = IR_SUB;
ir->opr2->fixnum = -ir->opr2->fixnum;
VReg *old = ir->opr2;
ir->opr2 = reg_alloc_spawn_const(fnbe->ra, -old->fixnum, old->vsize);
ir->opr2->flag = old->flag;
}
if (ir->opr2->fixnum > 0x0fff)
insert_const_mov(&ir->opr2, ra, irs, j++);
Expand All @@ -949,7 +951,9 @@ void tweak_irs(FuncBackend *fnbe) {
if (ir->opr2->flag & VRF_CONST) {
if (ir->opr2->fixnum < 0) {
ir->kind = IR_ADD;
ir->opr2->fixnum = -ir->opr2->fixnum;
VReg *old = ir->opr2;
ir->opr2 = reg_alloc_spawn_const(fnbe->ra, -old->fixnum, old->vsize);
ir->opr2->flag = old->flag;
}
if (ir->opr2->fixnum > 0x0fff)
insert_const_mov(&ir->opr2, ra, irs, j++);
Expand Down

0 comments on commit d20d5c1

Please sign in to comment.