Skip to content

Commit 503271c

Browse files
committed
[MERGE #5301 @sigatrev] OS#17676093: (ARM) ensure indir hoisting legalization is postRegAlloc aware
Merge pull request #5301 from sigatrev:armlower using InsertAdd in the lowerer calls Legalize with the default value postRegAlloc (false). For HoistIndirOffsetAsAdd and HoistIndirIndexOpndAsAdd, this was causing newly inserted LDIMMs to not be legalized when inserted after regAlloc.
2 parents abd689c + 887bc92 commit 503271c

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

lib/Backend/Lower.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14877,7 +14877,7 @@ IR::RegOpnd *Lowerer::GenerateArrayTest(
1487714877

1487814878
///----------------------------------------------------------------------------
1487914879
///
14880-
/// Instr::HoistIndirOffset
14880+
/// Lowerer::HoistIndirOffset
1488114881
///
1488214882
/// Replace the offset of the given indir with a new symbol, which becomes the indir index.
1488314883
/// Assign the new symbol by creating an assignment from the constant offset.
@@ -14927,7 +14927,10 @@ IR::Instr *Lowerer::HoistIndirOffsetAsAdd(IR::Instr* instr, IR::IndirOpnd *orgOp
1492714927
IR::RegOpnd *newBaseOpnd = IR::RegOpnd::New(StackSym::New(TyMachPtr, instr->m_func), regNum, TyMachPtr, instr->m_func);
1492814928

1492914929
IR::IntConstOpnd *src2 = IR::IntConstOpnd::New(offset, TyInt32, instr->m_func);
14930-
IR::Instr * instrAdd = Lowerer::InsertAdd(false, newBaseOpnd, baseOpnd, src2, instr);
14930+
14931+
IR::Instr * instrAdd = IR::Instr::New(Js::OpCode::Add_A, newBaseOpnd, baseOpnd, src2, instr->m_func);
14932+
LowererMD::ChangeToAdd(instrAdd, false);
14933+
instr->InsertBefore(instrAdd);
1493114934

1493214935
orgOpnd->ReplaceBaseOpnd(newBaseOpnd);
1493314936
orgOpnd->SetOffset(0);
@@ -14939,7 +14942,9 @@ IR::Instr *Lowerer::HoistIndirIndexOpndAsAdd(IR::Instr* instr, IR::IndirOpnd *or
1493914942
{
1494014943
IR::RegOpnd *newBaseOpnd = IR::RegOpnd::New(StackSym::New(TyMachPtr, instr->m_func), regNum, TyMachPtr, instr->m_func);
1494114944

14942-
IR::Instr * instrAdd = Lowerer::InsertAdd(false, newBaseOpnd, baseOpnd, indexOpnd->UseWithNewType(TyMachPtr, instr->m_func), instr);
14945+
IR::Instr * instrAdd = IR::Instr::New(Js::OpCode::Add_A, newBaseOpnd, baseOpnd, indexOpnd->UseWithNewType(TyMachPtr, instr->m_func), instr->m_func);
14946+
LowererMD::ChangeToAdd(instrAdd, false);
14947+
instr->InsertBefore(instrAdd);
1494314948

1494414949
orgOpnd->ReplaceBaseOpnd(newBaseOpnd);
1494514950
orgOpnd->SetIndexOpnd(nullptr);
@@ -14949,7 +14954,7 @@ IR::Instr *Lowerer::HoistIndirIndexOpndAsAdd(IR::Instr* instr, IR::IndirOpnd *or
1494914954

1495014955
///----------------------------------------------------------------------------
1495114956
///
14952-
/// Instr::HoistSymOffset
14957+
/// Lowerer::HoistSymOffset
1495314958
///
1495414959
/// Replace the given sym with an indir using the given base and offset.
1495514960
/// (This is used, for instance, to hoist a sym offset that is too large to encode.)

lib/Backend/arm/LegalizeMD.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ void LegalizeMD::LegalizeIndirOpndForVFP(IR::Instr* insertInstr, IR::IndirOpnd *
621621
indexOpnd = newIndexOpnd;
622622
}
623623

624-
Lowerer::HoistIndirIndexOpndAsAdd(insertInstr, indirOpnd, baseOpnd, indexOpnd, fPostRegAlloc? SCRATCH_REG : RegNOREG);
624+
IR::Instr * instrAdd = Lowerer::HoistIndirIndexOpndAsAdd(insertInstr, indirOpnd, baseOpnd, indexOpnd, fPostRegAlloc? SCRATCH_REG : RegNOREG);
625+
LegalizeMD::LegalizeInstr(instrAdd, fPostRegAlloc);
625626
}
626627

627628
if (IS_CONST_UINT10((offset < 0? -offset: offset)))

lib/Backend/arm64/LegalizeMD.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ void LegalizeMD::LegalizeIndirOffset(IR::Instr * instr, IR::IndirOpnd * indirOpn
373373
indexOpnd = newIndexOpnd;
374374
}
375375

376-
Lowerer::HoistIndirIndexOpndAsAdd(instr, indirOpnd, baseOpnd, indexOpnd, fPostRegAlloc ? SCRATCH_REG : RegNOREG);
376+
IR::Instr * instrAdd = Lowerer::HoistIndirIndexOpndAsAdd(instr, indirOpnd, baseOpnd, indexOpnd, fPostRegAlloc ? SCRATCH_REG : RegNOREG);
377+
LegalizeMD::LegalizeInstr(instrAdd, fPostRegAlloc);
377378
}
378379
}
379380
else if (indirOpnd->GetIndexOpnd() != nullptr && offset != 0)

0 commit comments

Comments
 (0)