Skip to content

Commit 71d2911

Browse files
author
Sergey Andreenko
authored
A few small jit changes. (#31816)
* Small refactoring changes. * Additional checks and returns, no diffs. * Fix SPMI replay with JitDump enabled. * update the comment and do the same for arm.
2 parents f5d7130 + f2fcda7 commit 71d2911

File tree

11 files changed

+54
-44
lines changed

11 files changed

+54
-44
lines changed

src/coreclr/src/jit/codegenxarch.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4557,7 +4557,8 @@ void CodeGen::genCodeForLclVar(GenTreeLclVar* tree)
45574557
// lcl_vars are not defs
45584558
assert((tree->gtFlags & GTF_VAR_DEF) == 0);
45594559

4560-
bool isRegCandidate = compiler->lvaTable[tree->GetLclNum()].lvIsRegCandidate();
4560+
LclVarDsc* varDsc = compiler->lvaGetDesc(tree);
4561+
bool isRegCandidate = varDsc->lvIsRegCandidate();
45614562

45624563
// If this is a register candidate that has been spilled, genConsumeReg() will
45634564
// reload it at the point of use. Otherwise, if it's not in a register, we load it here.

src/coreclr/src/jit/eeinterface.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,24 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd)
102102
/* add length of methodName and opening bracket */
103103
length += strlen(methodName) + 1;
104104

105-
/* figure out the signature */
105+
PAL_TRY(FilterSuperPMIExceptionsParam_eeinterface*, pParam, &param)
106+
{
106107

107-
param.pThis->eeGetMethodSig(param.hnd, &param.sig);
108+
/* figure out the signature */
108109

109-
// allocate space to hold the class names for each of the parameters
110+
pParam->pThis->eeGetMethodSig(pParam->hnd, &pParam->sig);
110111

111-
if (param.sig.numArgs > 0)
112-
{
113-
param.pArgNames = getAllocator(CMK_DebugOnly).allocate<const char*>(param.sig.numArgs);
114-
}
115-
else
116-
{
117-
param.pArgNames = nullptr;
118-
}
112+
// allocate space to hold the class names for each of the parameters
113+
114+
if (pParam->sig.numArgs > 0)
115+
{
116+
pParam->pArgNames = pParam->pThis->getAllocator(CMK_DebugOnly).allocate<const char*>(pParam->sig.numArgs);
117+
}
118+
else
119+
{
120+
pParam->pArgNames = nullptr;
121+
}
119122

120-
PAL_TRY(FilterSuperPMIExceptionsParam_eeinterface*, pParam, &param)
121-
{
122123
unsigned i;
123124
pParam->argLst = pParam->sig.args;
124125

src/coreclr/src/jit/gentree.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16869,6 +16869,9 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleIfPresent(GenTree* tree)
1686916869
case GT_OBJ:
1687016870
structHnd = tree->AsObj()->GetLayout()->GetClassHandle();
1687116871
break;
16872+
case GT_BLK:
16873+
structHnd = tree->AsBlk()->GetLayout()->GetClassHandle();
16874+
break;
1687216875
case GT_CALL:
1687316876
structHnd = tree->AsCall()->gtRetClsHnd;
1687416877
break;
@@ -16944,6 +16947,10 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleIfPresent(GenTree* tree)
1694416947
}
1694516948
}
1694616949
}
16950+
else if (addr->OperGet() == GT_LCL_VAR)
16951+
{
16952+
structHnd = gtGetStructHandleIfPresent(addr);
16953+
}
1694716954
}
1694816955
}
1694916956
break;

src/coreclr/src/jit/importer.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,21 +1214,23 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr,
12141214
// If it is a multi-reg struct return, don't change the oper to GT_LCL_FLD.
12151215
// That is, the IR will be of the form lclVar = call for multi-reg return
12161216
//
1217-
GenTreeLclVar* lcl = destAddr->AsOp()->gtOp1->AsLclVar();
1217+
GenTreeLclVar* lcl = destAddr->AsOp()->gtOp1->AsLclVar();
1218+
unsigned lclNum = lcl->GetLclNum();
1219+
LclVarDsc* varDsc = lvaGetDesc(lclNum);
12181220
if (src->AsCall()->HasMultiRegRetVal())
12191221
{
12201222
// Mark the struct LclVar as used in a MultiReg return context
12211223
// which currently makes it non promotable.
12221224
// TODO-1stClassStructs: Eliminate this pessimization when we can more generally
12231225
// handle multireg returns.
12241226
lcl->gtFlags |= GTF_DONT_CSE;
1225-
lvaTable[lcl->AsLclVarCommon()->GetLclNum()].lvIsMultiRegRet = true;
1227+
varDsc->lvIsMultiRegRet = true;
12261228
}
12271229
else if (lcl->gtType != src->gtType)
12281230
{
12291231
// We change this to a GT_LCL_FLD (from a GT_ADDR of a GT_LCL_VAR)
12301232
lcl->ChangeOper(GT_LCL_FLD);
1231-
fgLclFldAssign(lcl->AsLclVarCommon()->GetLclNum());
1233+
fgLclFldAssign(lclNum);
12321234
lcl->gtType = src->gtType;
12331235
asgType = src->gtType;
12341236
}
@@ -1238,7 +1240,7 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr,
12381240
#if defined(TARGET_ARM)
12391241
// TODO-Cleanup: This should have been taken care of in the above HasMultiRegRetVal() case,
12401242
// but that method has not been updadted to include ARM.
1241-
impMarkLclDstNotPromotable(lcl->AsLclVarCommon()->GetLclNum(), src, structHnd);
1243+
impMarkLclDstNotPromotable(lclNum, src, structHnd);
12421244
lcl->gtFlags |= GTF_DONT_CSE;
12431245
#elif defined(UNIX_AMD64_ABI)
12441246
// Not allowed for FEATURE_CORCLR which is the only SKU available for System V OSs.
@@ -1250,7 +1252,7 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr,
12501252
// TODO-Cleanup: Why is this needed here? This seems that it will set this even for
12511253
// non-multireg returns.
12521254
lcl->gtFlags |= GTF_DONT_CSE;
1253-
lvaTable[lcl->AsLclVarCommon()->GetLclNum()].lvIsMultiRegRet = true;
1255+
varDsc->lvIsMultiRegRet = true;
12541256
#endif
12551257
}
12561258
else // we don't have a GT_ADDR of a GT_LCL_VAR
@@ -2558,7 +2560,7 @@ BasicBlock* Compiler::impPushCatchArgOnStack(BasicBlock* hndBlk, CORINFO_CLASS_H
25582560
#if defined(JIT32_GCENCODER)
25592561
const bool forceInsertNewBlock = isSingleBlockFilter || compStressCompile(STRESS_CATCH_ARG, 5);
25602562
#else
2561-
const bool forceInsertNewBlock = compStressCompile(STRESS_CATCH_ARG, 5);
2563+
const bool forceInsertNewBlock = compStressCompile(STRESS_CATCH_ARG, 5);
25622564
#endif // defined(JIT32_GCENCODER)
25632565

25642566
/* Spill GT_CATCH_ARG to a temp if there are jumps to the beginning of the handler */

src/coreclr/src/jit/instr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,7 @@ instruction CodeGenInterface::ins_Load(var_types srcType, bool aligned /*=false*
18171817
*/
18181818
instruction CodeGen::ins_Copy(var_types dstType)
18191819
{
1820+
assert(emitTypeActSz[dstType] != 0);
18201821
#if defined(TARGET_XARCH)
18211822
if (varTypeIsSIMD(dstType))
18221823
{

src/coreclr/src/jit/lower.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ GenTree* Lowering::LowerNode(GenTree* node)
190190
break;
191191

192192
case GT_RETURN:
193-
LowerRet(node);
193+
LowerRet(node->AsUnOp());
194194
break;
195195

196196
case GT_RETURNTRAP:
@@ -3084,7 +3084,7 @@ void Lowering::LowerJmpMethod(GenTree* jmp)
30843084
}
30853085

30863086
// Lower GT_RETURN node to insert PInvoke method epilog if required.
3087-
void Lowering::LowerRet(GenTree* ret)
3087+
void Lowering::LowerRet(GenTreeUnOp* ret)
30883088
{
30893089
assert(ret->OperGet() == GT_RETURN);
30903090

@@ -3097,7 +3097,7 @@ void Lowering::LowerRet(GenTree* ret)
30973097
(varTypeUsesFloatReg(ret) != varTypeUsesFloatReg(ret->gtGetOp1())))
30983098
{
30993099
GenTreeUnOp* bitcast = new (comp, GT_BITCAST) GenTreeOp(GT_BITCAST, ret->TypeGet(), ret->gtGetOp1(), nullptr);
3100-
ret->AsOp()->gtOp1 = bitcast;
3100+
ret->gtOp1 = bitcast;
31013101
BlockRange().InsertBefore(ret, bitcast);
31023102
ContainCheckBitCast(bitcast);
31033103
}
@@ -3107,7 +3107,7 @@ void Lowering::LowerRet(GenTree* ret)
31073107
{
31083108
InsertPInvokeMethodEpilog(comp->compCurBB DEBUGARG(ret));
31093109
}
3110-
ContainCheckRet(ret->AsOp());
3110+
ContainCheckRet(ret);
31113111
}
31123112

31133113
GenTree* Lowering::LowerDirectCall(GenTreeCall* call)
@@ -5764,7 +5764,7 @@ void Lowering::ContainCheckLclHeap(GenTreeOp* node)
57645764
// Arguments:
57655765
// node - pointer to the node
57665766
//
5767-
void Lowering::ContainCheckRet(GenTreeOp* ret)
5767+
void Lowering::ContainCheckRet(GenTreeUnOp* ret)
57685768
{
57695769
assert(ret->OperIs(GT_RETURN));
57705770

src/coreclr/src/jit/lower.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Lowering final : public Phase
8383
void ContainCheckReturnTrap(GenTreeOp* node);
8484
void ContainCheckArrOffset(GenTreeArrOffs* node);
8585
void ContainCheckLclHeap(GenTreeOp* node);
86-
void ContainCheckRet(GenTreeOp* node);
86+
void ContainCheckRet(GenTreeUnOp* ret);
8787
void ContainCheckJTrue(GenTreeOp* node);
8888

8989
void ContainCheckBitCast(GenTree* node);
@@ -133,7 +133,7 @@ class Lowering final : public Phase
133133
GenTree* LowerJTrue(GenTreeOp* jtrue);
134134
GenTreeCC* LowerNodeCC(GenTree* node, GenCondition condition);
135135
void LowerJmpMethod(GenTree* jmp);
136-
void LowerRet(GenTree* ret);
136+
void LowerRet(GenTreeUnOp* ret);
137137
GenTree* LowerDelegateInvoke(GenTreeCall* call);
138138
GenTree* LowerIndirectNonvirtCall(GenTreeCall* call);
139139
GenTree* LowerDirectCall(GenTreeCall* call);

src/coreclr/src/jit/lsraarmarch.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
3838
//
3939
int LinearScan::BuildIndir(GenTreeIndir* indirTree)
4040
{
41-
int srcCount = 0;
42-
// If this is the rhs of a block copy (i.e. non-enregisterable struct),
43-
// it has no register requirements.
44-
if (indirTree->TypeGet() == TYP_STRUCT)
45-
{
46-
return srcCount;
47-
}
41+
// struct typed indirs are expected only on rhs of a block copy,
42+
// but in this case they must be contained.
43+
assert(indirTree->TypeGet() != TYP_STRUCT);
4844

4945
GenTree* addr = indirTree->Addr();
5046
GenTree* index = nullptr;
@@ -109,7 +105,7 @@ int LinearScan::BuildIndir(GenTreeIndir* indirTree)
109105
}
110106
#endif // FEATURE_SIMD
111107

112-
srcCount = BuildIndirUses(indirTree);
108+
int srcCount = BuildIndirUses(indirTree);
113109
buildInternalRegisterUses();
114110

115111
if (indirTree->gtOper != GT_STOREIND)

src/coreclr/src/jit/lsrabuild.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,14 +2473,18 @@ void setTgtPref(Interval* interval, RefPosition* tgtPrefUse)
24732473
RefPosition* LinearScan::BuildDef(GenTree* tree, regMaskTP dstCandidates, int multiRegIdx)
24742474
{
24752475
assert(!tree->isContained());
2476-
RegisterType type = getDefType(tree);
24772476

24782477
if (dstCandidates != RBM_NONE)
24792478
{
24802479
assert((tree->GetRegNum() == REG_NA) || (dstCandidates == genRegMask(tree->GetRegByIndex(multiRegIdx))));
24812480
}
24822481

2483-
if (tree->IsMultiRegNode())
2482+
RegisterType type = getDefType(tree);
2483+
if (!tree->IsMultiRegNode())
2484+
{
2485+
type = getDefType(tree);
2486+
}
2487+
else
24842488
{
24852489
type = tree->GetRegTypeByIndex(multiRegIdx);
24862490
}

src/coreclr/src/jit/lsraxarch.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,12 +2751,9 @@ int LinearScan::BuildCast(GenTreeCast* cast)
27512751
//
27522752
int LinearScan::BuildIndir(GenTreeIndir* indirTree)
27532753
{
2754-
// If this is the rhs of a block copy (i.e. non-enregisterable struct),
2755-
// it has no register requirements.
2756-
if (indirTree->TypeGet() == TYP_STRUCT)
2757-
{
2758-
return 0;
2759-
}
2754+
// struct typed indirs are expected only on rhs of a block copy,
2755+
// but in this case they must be contained.
2756+
assert(indirTree->TypeGet() != TYP_STRUCT);
27602757

27612758
#ifdef FEATURE_SIMD
27622759
RefPosition* internalFloatDef = nullptr;

0 commit comments

Comments
 (0)