Skip to content

Commit e84639d

Browse files
committed
ARM64: fix bailout problem from indir offset legalization
In ARM64 LEA is canonicalized into an ADD, and both operands of ADDs must be the same size, either 64 or 32. For LEAs with 64 bit bases and 32 bit offsets, this means converting the 32 bit offset to a 64 bit value with sign extention as needed. Calling UseWithNewType on an operand with the original 32 bit symbol resulted in the symbol's type changing as well, so the register allocator would not know that the symbol was supposed to be a tagged int, and it would not be retagged on bailout.
1 parent cd27b56 commit e84639d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Backend/arm64/LegalizeMD.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ void LegalizeMD::LegalizeIndirOffset(IR::Instr * instr, IR::IndirOpnd * indirOpn
333333
Assert(IRType_IsSignedInt(largerType) || IRType_IsUnsignedInt(largerType));
334334
IRType sourceType = baseOpnd->GetType();
335335
IRType targetType = IRType_IsSignedInt(sourceType) ? IRType_EnsureSigned(largerType) : IRType_EnsureUnsigned(largerType);
336-
IR::Instr* movInstr = Lowerer::InsertMove(baseOpnd->UseWithNewType(targetType, instr->m_func), baseOpnd, instr, false);
336+
IR::RegOpnd * tmpOpnd = IR::RegOpnd::New(sourceType, instr->m_func);
337+
Lowerer::InsertMove(tmpOpnd, baseOpnd, instr, false);
338+
IR::Instr* movInstr = Lowerer::InsertMove(tmpOpnd->UseWithNewType(targetType, instr->m_func), tmpOpnd, instr, false);
337339
indirOpnd->SetBaseOpnd(movInstr->GetDst()->AsRegOpnd());
338340
}
339341
else
@@ -343,7 +345,9 @@ void LegalizeMD::LegalizeIndirOffset(IR::Instr * instr, IR::IndirOpnd * indirOpn
343345
Assert(IRType_IsSignedInt(largerType) || IRType_IsUnsignedInt(largerType));
344346
IRType sourceType = indexOpnd->GetType();
345347
IRType targetType = IRType_IsSignedInt(sourceType) ? IRType_EnsureSigned(largerType) : IRType_EnsureUnsigned(largerType);
346-
IR::Instr* movInstr = Lowerer::InsertMove(indexOpnd->UseWithNewType(targetType, instr->m_func), indexOpnd, instr, false);
348+
IR::RegOpnd * tmpOpnd = IR::RegOpnd::New(sourceType, instr->m_func);
349+
Lowerer::InsertMove(tmpOpnd, indexOpnd, instr, false);
350+
IR::Instr* movInstr = Lowerer::InsertMove(tmpOpnd->UseWithNewType(targetType, instr->m_func), tmpOpnd, instr, false);
347351
indirOpnd->SetIndexOpnd(movInstr->GetDst()->AsRegOpnd());
348352
}
349353
}

0 commit comments

Comments
 (0)