Skip to content
Snippets Groups Projects
Commit c8befeea authored by clc5q's avatar clc5q
Browse files

Bug fix: Retain original byte width for normalized stack operands.

Former-commit-id: 49e1dbbf61159acd2919f55c0198b38cb29493e9
parent a7a94176
No related branches found
No related tags found
No related merge requests found
......@@ -4607,6 +4607,7 @@ bool SMPInstr::MDComputeNormalizedDataFlowOp(bool UseFP, STARS_sval_t FPDelta, S
// Now, we simply convert the memory operand from EBP to ESP and replace the SignedOffset with the
// NormalizedDelta just computed.
DefOp->SetReg(MD_STACK_POINTER_REG);
DefOp->SetByteWidth(OldOp->GetByteWidth()); // undo possible width change in SetReg()
this->SetFPNormalizedToSP();
// Add the stack pointer to the USE set for the instruction.
this->MDAddRegUse(MD_STACK_POINTER_REG, false);
......@@ -4869,6 +4870,7 @@ void SMPInstr::MDGetUnnormalizedOp(STARSOpndTypePtr &NormOp) {
bool UseFP = this->GetBlock()->GetFunc()->UsesFramePointer();
if (this->AreDefsNormalized() && (0 != this->GetStackPtrOffset()) && MDIsStackAccessOpnd(NormOp, UseFP)) {
if (this->HasFPNormalizedToSP()) {
size_t NormOpByteWidth = NormOp->GetByteWidth();
// Need to convert NormOp back to frame-pointer-relative address.
if (NormOp->HasSIBByte()) {
// Convert base register from stack pointer back to frame pointer.
......@@ -4877,6 +4879,7 @@ void SMPInstr::MDGetUnnormalizedOp(STARSOpndTypePtr &NormOp) {
}
else {
NormOp->SetReg(MD_FRAME_POINTER_REG);
NormOp->SetByteWidth(NormOpByteWidth); // undo possible width change in SetReg()
}
SignedOffset = (STARS_sval_t) NormOp->GetAddr();
SignedOffset -= this->GetBlock()->GetFunc()->GetFramePtrStackDelta();
......@@ -14059,9 +14062,11 @@ bool SMPInstr::BuildMultiplyDivideRTL(SMPoperator BinaryOp) {
SMPRegTransfer *EDXRightRT = new SMPRegTransfer;
EDXRightRT->SetParentInst(this);
STARSOpndTypePtr EDXOp = TempRT->GetLeftOperand()->clone();
size_t SourceByteWidth = EDXOp->GetByteWidth();
EDXRT->SetOperator(SMP_ASSIGN);
assert(EDXOp->MatchesReg(STARS_x86_R_ax));
EDXOp->SetReg(STARS_x86_R_dx);
EDXOp->SetByteWidth(SourceByteWidth); // undo possible width change in SetReg()
EDXRT->SetLeftOperand(EDXOp);
STARSOpndTypePtr SourceOp = RightRT->GetLeftOperand();
if ((STARS_NN_div == this->GetIDAOpcode()) || (STARS_NN_idiv == this->GetIDAOpcode())) {
......
5ed023069117f30d8e40a0cd1e96c1918b2059cc
\ No newline at end of file
cc0231bd87f595a3cbb8158cd581363bb6e25cff
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment