Skip to content

Commit 2bcf0f7

Browse files
Delete lvVerTypeInfo (#71597)
1 parent cbfc549 commit 2bcf0f7

File tree

7 files changed

+42
-68
lines changed

7 files changed

+42
-68
lines changed

src/coreclr/jit/codegencommon.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,8 +3377,7 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere
33773377
{
33783378
// This must be a SIMD type that's fully enregistered, but is passed as an HFA.
33793379
// Each field will be inserted into the same destination register.
3380-
assert(varTypeIsSIMD(varDsc) &&
3381-
!compiler->isOpaqueSIMDType(varDsc->lvVerTypeInfo.GetClassHandle()));
3380+
assert(varTypeIsSIMD(varDsc) && !compiler->isOpaqueSIMDType(varDsc->GetStructHnd()));
33823381
assert(regArgTab[argNum].slot <= (int)varDsc->lvHfaSlots());
33833382
assert(argNum > 0);
33843383
assert(regArgTab[argNum - 1].varNum == varNum);

src/coreclr/jit/compiler.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,6 @@ class LclVarDsc
10011001

10021002
unsigned lvSlotNum; // original slot # (if remapped)
10031003

1004-
typeInfo lvVerTypeInfo; // type info needed for verification
1005-
10061004
// class handle for the local or null if not known or not a class,
10071005
// for a struct handle use `GetStructHnd()`.
10081006
CORINFO_CLASS_HANDLE lvClassHnd;
@@ -3297,7 +3295,7 @@ class Compiler
32973295

32983296
// If the local is a TYP_STRUCT, get/set a class handle describing it
32993297
CORINFO_CLASS_HANDLE lvaGetStruct(unsigned varNum);
3300-
void lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd, bool unsafeValueClsCheck, bool setTypeInfo = true);
3298+
void lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd, bool unsafeValueClsCheck);
33013299
void lvaSetStructUsedAsVarArg(unsigned varNum);
33023300

33033301
// If the local is TYP_REF, set or update the associated class information.
@@ -4112,11 +4110,7 @@ class Compiler
41124110

41134111
void impPushVar(GenTree* op, typeInfo tiRetVal);
41144112
GenTreeLclVar* impCreateLocalNode(unsigned lclNum DEBUGARG(IL_OFFSET offset));
4115-
void impLoadVar(unsigned lclNum, IL_OFFSET offset, const typeInfo& tiRetVal);
4116-
void impLoadVar(unsigned lclNum, IL_OFFSET offset)
4117-
{
4118-
impLoadVar(lclNum, offset, lvaGetDesc(lclNum)->lvVerTypeInfo);
4119-
}
4113+
void impLoadVar(unsigned lclNum, IL_OFFSET offset);
41204114
void impLoadArg(unsigned ilArgNum, IL_OFFSET offset);
41214115
void impLoadLoc(unsigned ilLclNum, IL_OFFSET offset);
41224116
bool impReturnInstruction(int prefixFlags, OPCODE& opcode);
@@ -10227,6 +10221,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1022710221

1022810222
void verConvertBBToThrowVerificationException(BasicBlock* block DEBUGARG(bool logMsg));
1022910223
void verHandleVerificationFailure(BasicBlock* block DEBUGARG(bool logMsg));
10224+
typeInfo verMakeTypeInfoForLocal(unsigned lclNum);
1023010225
typeInfo verMakeTypeInfo(CORINFO_CLASS_HANDLE clsHnd,
1023110226
bool bashStructToRef = false); // converts from jit type representation to typeInfo
1023210227
typeInfo verMakeTypeInfo(CorInfoType ciType,

src/coreclr/jit/fgbasic.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,7 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
889889
const BYTE* codeBegp = codeAddr;
890890
const BYTE* codeEndp = codeAddr + codeSize;
891891
unsigned varNum;
892-
var_types varType = DUMMY_INIT(TYP_UNDEF); // TYP_ type
893-
typeInfo ti; // Verifier type.
892+
var_types varType = DUMMY_INIT(TYP_UNDEF); // TYP_ type
894893
bool typeIsNormed = false;
895894
FgStack pushedStack;
896895
const bool isForceInline = (info.compFlags & CORINFO_FLG_FORCEINLINE) != 0;
@@ -1901,7 +1900,6 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
19011900
if (opcode == CEE_LDLOCA || opcode == CEE_LDLOCA_S)
19021901
{
19031902
varType = impInlineInfo->lclVarInfo[varNum + impInlineInfo->argCnt].lclTypeInfo;
1904-
ti = impInlineInfo->lclVarInfo[varNum + impInlineInfo->argCnt].lclVerTypeInfo;
19051903

19061904
impInlineInfo->lclVarInfo[varNum + impInlineInfo->argCnt].lclHasLdlocaOp = true;
19071905
}
@@ -1910,7 +1908,6 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
19101908
noway_assert(opcode == CEE_LDARGA || opcode == CEE_LDARGA_S);
19111909

19121910
varType = impInlineInfo->lclVarInfo[varNum].lclTypeInfo;
1913-
ti = impInlineInfo->lclVarInfo[varNum].lclVerTypeInfo;
19141911

19151912
impInlineInfo->inlArgInfo[varNum].argHasLdargaOp = true;
19161913

@@ -1942,7 +1939,6 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
19421939
}
19431940

19441941
varType = (var_types)lvaTable[varNum].lvType;
1945-
ti = lvaTable[varNum].lvVerTypeInfo;
19461942

19471943
// Determine if the next instruction will consume
19481944
// the address. If so we won't mark this var as
@@ -1982,7 +1978,7 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
19821978
}
19831979
} // isInlining
19841980

1985-
typeIsNormed = ti.IsValueClass() && !varTypeIsStruct(varType);
1981+
typeIsNormed = !varTypeIsGC(varType) && !varTypeIsStruct(varType);
19861982
}
19871983
break;
19881984

@@ -2241,13 +2237,8 @@ void Compiler::fgAdjustForAddressExposedOrWrittenThis()
22412237
arg0varDsc->SetDoNotEnregReason(thisVarDsc->GetDoNotEnregReason());
22422238
#endif
22432239
arg0varDsc->lvHasILStoreOp = thisVarDsc->lvHasILStoreOp;
2244-
arg0varDsc->lvVerTypeInfo = thisVarDsc->lvVerTypeInfo;
22452240

2246-
// Clear the TI_FLAG_THIS_PTR in the original 'this' pointer.
2247-
noway_assert(arg0varDsc->lvVerTypeInfo.IsThisPtr());
2248-
thisVarDsc->lvVerTypeInfo.ClearThisPtr();
2249-
// Note that here we don't clear `m_doNotEnregReason` and it stays
2250-
// `doNotEnreg` with `AddrExposed` reason.
2241+
// Note that here we don't clear `m_doNotEnregReason` and it stays `doNotEnreg` with `AddrExposed` reason.
22512242
thisVarDsc->CleanAddressExposed();
22522243
thisVarDsc->lvHasILStoreOp = false;
22532244
}

src/coreclr/jit/gschecks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void Compiler::gsParamsToShadows()
422422
#ifdef DEBUG
423423
shadowVarDsc->SetDoNotEnregReason(varDsc->GetDoNotEnregReason());
424424
#endif
425-
shadowVarDsc->lvVerTypeInfo = varDsc->lvVerTypeInfo;
425+
426426
if (varTypeIsStruct(type))
427427
{
428428
// We don't need unsafe value cls check here since we are copying the params and this flag

src/coreclr/jit/importer.cpp

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6609,7 +6609,27 @@ void Compiler::verHandleVerificationFailure(BasicBlock* block DEBUGARG(bool logM
66096609
#endif // DEBUG
66106610
}
66116611

6612-
/******************************************************************************/
6612+
typeInfo Compiler::verMakeTypeInfoForLocal(unsigned lclNum)
6613+
{
6614+
LclVarDsc* varDsc = lvaGetDesc(lclNum);
6615+
6616+
if ((varDsc->TypeGet() == TYP_BLK) || (varDsc->TypeGet() == TYP_LCLBLK))
6617+
{
6618+
return typeInfo();
6619+
}
6620+
if (varDsc->TypeGet() == TYP_BYREF)
6621+
{
6622+
// Pretend all byrefs are pointing to bytes.
6623+
return typeInfo(TI_BYTE).MakeByRef();
6624+
}
6625+
if (varTypeIsStruct(varDsc))
6626+
{
6627+
return typeInfo(TI_STRUCT, varDsc->GetStructHnd());
6628+
}
6629+
6630+
return typeInfo(varDsc->TypeGet());
6631+
}
6632+
66136633
typeInfo Compiler::verMakeTypeInfo(CorInfoType ciType, CORINFO_CLASS_HANDLE clsHnd)
66146634
{
66156635
assert(ciType < CORINFO_TYPE_COUNT);
@@ -10770,9 +10790,9 @@ var_types Compiler::impImportCall(OPCODE opcode,
1077010790
assert(IsTargetAbi(CORINFO_NATIVEAOT_ABI));
1077110791
if (call->OperGet() != GT_LCL_VAR) // can be already converted by impFixupCallStructReturn.
1077210792
{
10773-
unsigned calliSlot = lvaGrabTemp(true DEBUGARG("calli"));
10774-
LclVarDsc* varDsc = lvaGetDesc(calliSlot);
10775-
varDsc->lvVerTypeInfo = tiRetVal;
10793+
unsigned calliSlot = lvaGrabTemp(true DEBUGARG("calli"));
10794+
LclVarDsc* varDsc = lvaGetDesc(calliSlot);
10795+
1077610796
impAssignTempGen(calliSlot, call, tiRetVal.GetClassHandle(), (unsigned)CHECK_SPILL_NONE);
1077710797
// impAssignTempGen can change src arg list and return type for call that returns struct.
1077810798
var_types type = genActualType(lvaTable[calliSlot].TypeGet());
@@ -13610,8 +13630,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1361013630
// &aliasedVar doesnt need GTF_GLOB_REF, though alisasedVar does
1361113631
assert((op1->gtFlags & GTF_GLOB_REF) == 0);
1361213632

13613-
tiRetVal = lvaTable[lclNum].lvVerTypeInfo;
13614-
13633+
tiRetVal = typeInfo(TI_BYTE).MakeByRef();
1361513634
impPushOnStack(op1, tiRetVal);
1361613635
break;
1361713636

@@ -17665,9 +17684,9 @@ GenTreeLclVar* Compiler::impCreateLocalNode(unsigned lclNum DEBUGARG(IL_OFFSET o
1766517684

1766617685
// Load a local/argument on the operand stack
1766717686
// lclNum is an index into lvaTable *NOT* the arg/lcl index in the IL
17668-
void Compiler::impLoadVar(unsigned lclNum, IL_OFFSET offset, const typeInfo& tiRetVal)
17687+
void Compiler::impLoadVar(unsigned lclNum, IL_OFFSET offset)
1766917688
{
17670-
impPushVar(impCreateLocalNode(lclNum DEBUGARG(offset)), tiRetVal);
17689+
impPushVar(impCreateLocalNode(lclNum DEBUGARG(offset)), verMakeTypeInfoForLocal(lclNum));
1767117690
}
1767217691

1767317692
// Load an argument on the operand stack
@@ -20743,11 +20762,6 @@ unsigned Compiler::impInlineFetchLocal(unsigned lclNum DEBUGARG(const char* reas
2074320762
{
2074420763
lvaSetStruct(tmpNum, inlineeLocal.lclVerTypeInfo.GetClassHandle(), true /* unsafe value cls check */);
2074520764
}
20746-
else
20747-
{
20748-
// This is a wrapped primitive. Make sure the verstate knows that
20749-
lvaTable[tmpNum].lvVerTypeInfo = inlineeLocal.lclVerTypeInfo;
20750-
}
2075120765
}
2075220766

2075320767
#ifdef DEBUG
@@ -20960,11 +20974,6 @@ GenTree* Compiler::impInlineFetchArg(unsigned lclNum, InlArgInfo* inlArgInfo, In
2096020974
lvaSetStructUsedAsVarArg(tmpNum);
2096120975
}
2096220976
}
20963-
else
20964-
{
20965-
// This is a wrapped primitive. Make sure the verstate knows that
20966-
lvaTable[tmpNum].lvVerTypeInfo = lclInfo.lclVerTypeInfo;
20967-
}
2096820977
}
2096920978

2097020979
argInfo.argHasTmp = true;

src/coreclr/jit/lclvars.cpp

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,6 @@ void Compiler::lvaInitThisPtr(InitVarDscInfo* varDscInfo)
509509
lvaSetClass(varDscInfo->varNum, info.compClassHnd);
510510
}
511511

512-
varDsc->lvVerTypeInfo = typeInfo();
513-
514-
// Mark the 'this' pointer for the method
515-
varDsc->lvVerTypeInfo.SetIsThisPtr();
516-
517512
varDsc->lvIsRegArg = 1;
518513
noway_assert(varDscInfo->intRegArgNum == 0);
519514

@@ -1479,19 +1474,9 @@ void Compiler::lvaInitVarDsc(LclVarDsc* varDsc,
14791474
compFloatingPointUsed = true;
14801475
}
14811476

1482-
if (typeHnd)
1477+
if (typeHnd != NO_CLASS_HANDLE)
14831478
{
1484-
unsigned cFlags = info.compCompHnd->getClassAttribs(typeHnd);
1485-
1486-
// We can get typeHnds for primitive types, these are value types which only contain
1487-
// a primitive. We will need the typeHnd to distinguish them, so we store it here.
1488-
if ((cFlags & CORINFO_FLG_VALUECLASS) && !varTypeIsStruct(type))
1489-
{
1490-
// printf("This is a struct that the JIT will treat as a primitive\n");
1491-
varDsc->lvVerTypeInfo = verMakeTypeInfo(typeHnd);
1492-
}
1493-
1494-
varDsc->lvOverlappingFields = StructHasOverlappingFields(cFlags);
1479+
varDsc->lvOverlappingFields = StructHasOverlappingFields(info.compCompHnd->getClassAttribs(typeHnd));
14951480
}
14961481

14971482
#if FEATURE_IMPLICIT_BYREFS
@@ -1511,7 +1496,7 @@ void Compiler::lvaInitVarDsc(LclVarDsc* varDsc,
15111496
}
15121497
if ((varTypeIsStruct(type)))
15131498
{
1514-
lvaSetStruct(varNum, typeHnd, typeHnd != nullptr, true);
1499+
lvaSetStruct(varNum, typeHnd, typeHnd != NO_CLASS_HANDLE);
15151500
if (info.compIsVarArgs)
15161501
{
15171502
lvaSetStructUsedAsVarArg(varNum);
@@ -2596,7 +2581,7 @@ void Compiler::StructPromotionHelper::PromoteStructVar(unsigned lclNum)
25962581
{
25972582
// Set size to zero so that lvaSetStruct will appropriately set the SIMD-relevant fields.
25982583
fieldVarDsc->lvExactSize = 0;
2599-
compiler->lvaSetStruct(varNum, pFieldInfo->fldTypeHnd, false, true);
2584+
compiler->lvaSetStruct(varNum, pFieldInfo->fldTypeHnd, false);
26002585
// We will not recursively promote this, so mark it as 'lvRegStruct' (note that we wouldn't
26012586
// be promoting this if we didn't think it could be enregistered.
26022587
fieldVarDsc->lvRegStruct = true;
@@ -2977,13 +2962,9 @@ bool Compiler::lvaIsMultiregStruct(LclVarDsc* varDsc, bool isVarArg)
29772962
/*****************************************************************************
29782963
* Set the lvClass for a local variable of a struct type */
29792964

2980-
void Compiler::lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd, bool unsafeValueClsCheck, bool setTypeInfo)
2965+
void Compiler::lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd, bool unsafeValueClsCheck)
29812966
{
29822967
LclVarDsc* varDsc = lvaGetDesc(varNum);
2983-
if (setTypeInfo)
2984-
{
2985-
varDsc->lvVerTypeInfo = typeInfo(TI_STRUCT, typeHnd);
2986-
}
29872968

29882969
// Set the type and associated info if we haven't already set it.
29892970
if (varDsc->lvType == TYP_UNDEF)
@@ -7890,7 +7871,7 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r
78907871
{
78917872
printf(" ld-addr-op");
78927873
}
7893-
if (varDsc->lvVerTypeInfo.IsThisPtr())
7874+
if (lvaIsOriginalThisArg(lclNum))
78947875
{
78957876
printf(" this");
78967877
}

src/coreclr/jit/morph.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4043,8 +4043,7 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg)
40434043
FOREACH_HBV_BIT_SET(lclNum, fgOutgoingArgTemps)
40444044
{
40454045
LclVarDsc* varDsc = lvaGetDesc((unsigned)lclNum);
4046-
if (typeInfo::AreEquivalent(varDsc->lvVerTypeInfo, typeInfo(TI_STRUCT, copyBlkClass)) &&
4047-
!fgCurrentlyInUseArgTemps->testBit(lclNum))
4046+
if ((varDsc->GetStructHnd() == copyBlkClass) && !fgCurrentlyInUseArgTemps->testBit(lclNum))
40484047
{
40494048
tmp = (unsigned)lclNum;
40504049
found = true;

0 commit comments

Comments
 (0)