From 2054ea0fd8169eb778d112592392bbb727768df5 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sun, 6 Feb 2022 11:57:40 -0500 Subject: [PATCH] Fixed backend indirect float const storage issue --- IDEHelper/Backend/BeMCContext.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/IDEHelper/Backend/BeMCContext.cpp b/IDEHelper/Backend/BeMCContext.cpp index 248746a3..2d6af7ce 100644 --- a/IDEHelper/Backend/BeMCContext.cpp +++ b/IDEHelper/Backend/BeMCContext.cpp @@ -10650,11 +10650,25 @@ bool BeMCContext::DoLegalization() CheckForce(vregInfo); } - BeMCOperand castedVReg = AllocVirtualReg(mModule->mContext->GetPrimitiveType(BeTypeCode_Int64), 2, false); - CreateDefineVReg(castedVReg, instIdx++); - auto castedVRegInfo = GetVRegInfo(castedVReg); - castedVRegInfo->mIsExpr = true; - castedVRegInfo->mRelTo = inst->mArg0; + BeMCOperand castedVReg; + if (inst->mArg0.mKind == BeMCOperandKind_VRegLoad) + { + // Maintain the load-ness (don't wrap a load) + castedVReg = AllocVirtualReg(mModule->mContext->GetPointerTo(mModule->mContext->GetPrimitiveType(BeTypeCode_Int64)), 2, false); + CreateDefineVReg(castedVReg, instIdx++); + auto castedVRegInfo = GetVRegInfo(castedVReg); + castedVRegInfo->mIsExpr = true; + castedVRegInfo->mRelTo = BeMCOperand::FromVReg(inst->mArg0.mVRegIdx); + castedVReg.mKind = BeMCOperandKind_VRegLoad; + } + else + { + castedVReg = AllocVirtualReg(mModule->mContext->GetPrimitiveType(BeTypeCode_Int64), 2, false); + CreateDefineVReg(castedVReg, instIdx++); + auto castedVRegInfo = GetVRegInfo(castedVReg); + castedVRegInfo->mIsExpr = true; + castedVRegInfo->mRelTo = inst->mArg0; + } BeMCOperand scratchReg = AllocVirtualReg(mModule->mContext->GetPrimitiveType(BeTypeCode_Int64), 2, true); CreateDefineVReg(scratchReg, instIdx++);