From b643cc6ddbb163ea7f61d8779e8f04156cfd86d8 Mon Sep 17 00:00:00 2001 From: qiaopengcheng Date: Thu, 28 Jul 2022 19:56:52 +0800 Subject: [PATCH] amend the GCTypes for CRs round-5. --- src/coreclr/jit/codegenloongarch64.cpp | 3 +- src/coreclr/jit/morph.cpp | 43 ++++---------------------- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/src/coreclr/jit/codegenloongarch64.cpp b/src/coreclr/jit/codegenloongarch64.cpp index 21264199cfc1f..ef3ffa0f67267 100644 --- a/src/coreclr/jit/codegenloongarch64.cpp +++ b/src/coreclr/jit/codegenloongarch64.cpp @@ -7142,13 +7142,14 @@ void CodeGen::genCall(GenTreeCall* call) regNumber argReg = abiInfo.GetRegNum(); regNumber allocReg = argNode->AsPutArgSplit()->GetRegNumByIdx(0); + var_types regType = argNode->AsPutArgSplit()->GetRegType(0); // For LA64's ABI, the split is only using the A7 and stack for passing arg. assert(emitter::isGeneralRegister(argReg)); assert(emitter::isGeneralRegister(allocReg)); assert(abiInfo.NumRegs == 1); - inst_Mov(abiInfo.StructFloatFieldType[0], argReg, allocReg, /* canSkip */ true); + inst_Mov(regType, argReg, allocReg, /* canSkip */ true); } else { diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 644e86b2bf9c3..3a4fdd223d937 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -2785,7 +2785,6 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call // Increment intArgRegNum by 'size' registers if (nonStdRegNum == REG_NA) { - bool isGCTypes = false; if ((size > 1) && ((intArgRegNum + 1) == maxRegArgs) && (nextOtherRegNum == REG_STK)) { // This indicates a partial enregistration of a struct type @@ -2794,11 +2793,9 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call unsigned numRegsPartial = MAX_REG_ARG - intArgRegNum; assert((unsigned char)numRegsPartial == numRegsPartial); SplitArg(&arg, numRegsPartial, size - numRegsPartial); - arg.AbiInfo.StructFloatFieldType[0] = TYP_I_IMPL; // maybe later will be GCType assert(!passUsingFloatRegs); assert(size == 2); intArgRegNum = maxRegArgs; - isGCTypes = true; } else if ((floatFieldFlags & STRUCT_HAS_FLOAT_FIELDS_MASK) == 0x0) { @@ -2823,17 +2820,15 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call intArgRegNum += 1; if ((floatFieldFlags & STRUCT_FLOAT_FIELD_FIRST) != 0) { - isGCTypes = (floatFieldFlags & STRUCT_SECOND_FIELD_SIZE_IS8) != 0; - arg.AbiInfo.StructFloatFieldType[0] = (floatFieldFlags & STRUCT_FIRST_FIELD_SIZE_IS8) ? TYP_DOUBLE : TYP_FLOAT; - arg.AbiInfo.StructFloatFieldType[1] = isGCTypes ? TYP_LONG : TYP_INT; + arg.AbiInfo.StructFloatFieldType[1] = + (floatFieldFlags & STRUCT_SECOND_FIELD_SIZE_IS8) ? TYP_LONG : TYP_INT; } else { - isGCTypes = (floatFieldFlags & STRUCT_FIRST_FIELD_SIZE_IS8) != 0; - - arg.AbiInfo.StructFloatFieldType[0] = isGCTypes ? TYP_LONG : TYP_INT; + arg.AbiInfo.StructFloatFieldType[0] = + (floatFieldFlags & STRUCT_FIRST_FIELD_SIZE_IS8) ? TYP_LONG : TYP_INT; arg.AbiInfo.StructFloatFieldType[1] = (floatFieldFlags & STRUCT_SECOND_FIELD_SIZE_IS8) ? TYP_DOUBLE : TYP_FLOAT; } @@ -2846,33 +2841,6 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call arg.AbiInfo.StructFloatFieldType[1] = (floatFieldFlags & STRUCT_SECOND_FIELD_SIZE_IS8) ? TYP_DOUBLE : TYP_FLOAT; } - - if (isGCTypes) - { - ClassLayout* layout = nullptr; - if (argx->OperGet() == GT_OBJ) - { - layout = argx->AsObj()->GetLayout(); - } - else - { - assert(argx->TypeIs(TYP_STRUCT)); - assert(argx->OperIsLocalRead()); - layout = argx->AsLclVarCommon()->GetLayout(comp); - } - - auto getSlotType = [layout](unsigned inx) { - return (layout != nullptr) ? layout->GetGCPtrType(inx) : TYP_I_IMPL; - }; - - var_types Type = getSlotType(0); - arg.AbiInfo.StructFloatFieldType[0] = - varTypeIsGC(Type) ? Type : arg.AbiInfo.StructFloatFieldType[0]; - - Type = getSlotType(1); - arg.AbiInfo.StructFloatFieldType[1] = - varTypeIsGC(Type) ? Type : arg.AbiInfo.StructFloatFieldType[1]; - } } #else @@ -3758,7 +3726,8 @@ GenTree* Compiler::fgMorphMultiregStructArg(CallArg* arg) } else #elif defined(TARGET_LOONGARCH64) - if (!varTypeIsGC(getSlotType(inx)) && (arg->AbiInfo.StructFloatFieldType[inx] != TYP_UNDEF)) + if ((arg->AbiInfo.StructFloatFieldType[inx] != TYP_UNDEF) && + !varTypeIsGC(getSlotType(offset / TARGET_POINTER_SIZE))) { elems[inx].Type = arg->AbiInfo.StructFloatFieldType[inx]; offset += (structSize > TARGET_POINTER_SIZE) ? 8 : 4;