/*****************************************************************************
* Is this type promotable? */
-void Compiler::lvaCanPromoteStructType(CORINFO_CLASS_HANDLE typeHnd,
- lvaStructPromotionInfo* StructPromotionInfo,
- bool sortFields)
+void Compiler::lvaCanPromoteStructType(CORINFO_CLASS_HANDLE typeHnd, lvaStructPromotionInfo* structPromotionInfo)
{
assert(eeIsValueClass(typeHnd));
- if (typeHnd != StructPromotionInfo->typeHnd)
+ if (typeHnd != structPromotionInfo->typeHnd)
{
// sizeof(double) represents the size of the largest primitive type that we can struct promote.
// In the future this may be changing to XMM_REGSIZE_BYTES.
bool customLayout = false;
bool containsGCpointers = false;
- StructPromotionInfo->typeHnd = typeHnd;
- StructPromotionInfo->canPromote = false;
+ structPromotionInfo->typeHnd = typeHnd;
+ structPromotionInfo->canPromote = false;
unsigned structSize = info.compCompHnd->getClassSize(typeHnd);
if (structSize > MaxOffset)
return; // struct must have between 1 and MAX_NumOfFieldsInPromotableStruct fields
}
- StructPromotionInfo->fieldCnt = (BYTE)fieldCnt;
+ structPromotionInfo->fieldCnt = (BYTE)fieldCnt;
DWORD typeFlags = info.compCompHnd->getClassAttribs(typeHnd);
- bool treatAsOverlapping = StructHasOverlappingFields(typeFlags);
-
-#if 1 // TODO-Cleanup: Consider removing this entire #if block in the future
-
- // This method has two callers. The one in Importer.cpp passes `sortFields == false` and the other passes
- // `sortFields == true`. This is a workaround that leaves the inlining behavior the same as before while still
- // performing extra struct promotion when compiling the method.
- if (!sortFields) // the condition "!sortFields" really means "we are inlining"
- {
- treatAsOverlapping = StructHasCustomLayout(typeFlags);
- }
-#endif
-
- if (treatAsOverlapping)
+ bool overlappingFields = StructHasOverlappingFields(typeFlags);
+ if (overlappingFields)
{
return;
}
for (BYTE ordinal = 0; ordinal < fieldCnt; ++ordinal)
{
- lvaStructFieldInfo* pFieldInfo = &StructPromotionInfo->fields[ordinal];
+ lvaStructFieldInfo* pFieldInfo = &structPromotionInfo->fields[ordinal];
pFieldInfo->fldHnd = info.compCompHnd->getFieldInClass(typeHnd, ordinal);
unsigned fldOffset = info.compCompHnd->getFieldOffset(pFieldInfo->fldHnd);
}
// Cool, this struct is promotable.
- StructPromotionInfo->canPromote = true;
- StructPromotionInfo->requiresScratchVar = requiresScratchVar;
- StructPromotionInfo->containsHoles = containsHoles;
- StructPromotionInfo->customLayout = customLayout;
+ structPromotionInfo->canPromote = true;
+ structPromotionInfo->requiresScratchVar = requiresScratchVar;
+ structPromotionInfo->containsHoles = containsHoles;
+ structPromotionInfo->customLayout = customLayout;
- if (sortFields)
- {
- // Sort the fields according to the increasing order of the field offset.
- // This is needed because the fields need to be pushed on stack (when referenced
- // as a struct) in order.
- qsort(StructPromotionInfo->fields, StructPromotionInfo->fieldCnt, sizeof(*StructPromotionInfo->fields),
- lvaFieldOffsetCmp);
- }
+ // Sort the fields according to the increasing order of the field offset.
+ // This is needed because the fields need to be pushed on stack (when referenced
+ // as a struct) in order.
+ qsort(structPromotionInfo->fields, structPromotionInfo->fieldCnt, sizeof(*structPromotionInfo->fields),
+ lvaFieldOffsetCmp);
}
else
{
/*****************************************************************************
* Is this struct type local variable promotable? */
-void Compiler::lvaCanPromoteStructVar(unsigned lclNum, lvaStructPromotionInfo* StructPromotionInfo)
+void Compiler::lvaCanPromoteStructVar(unsigned lclNum, lvaStructPromotionInfo* structPromotionInfo)
{
noway_assert(lclNum < lvaCount);
if (varDsc->lvIsUsedInSIMDIntrinsic())
{
JITDUMP(" struct promotion of V%02u is disabled because lvIsUsedInSIMDIntrinsic()\n", lclNum);
- StructPromotionInfo->canPromote = false;
+ structPromotionInfo->canPromote = false;
return;
}
if (varDsc->lvIsParam && compGSReorderStackLayout)
{
JITDUMP(" struct promotion of V%02u is disabled because lvIsParam and compGSReorderStackLayout\n", lclNum);
- StructPromotionInfo->canPromote = false;
+ structPromotionInfo->canPromote = false;
return;
}
if (varDsc->lvIsHfaRegArg())
{
JITDUMP(" struct promotion of V%02u is disabled because lvIsHfaRegArg()\n", lclNum);
- StructPromotionInfo->canPromote = false;
+ structPromotionInfo->canPromote = false;
return;
}
if (varDsc->lvIsMultiRegArg)
{
JITDUMP(" struct promotion of V%02u is disabled because lvIsMultiRegArg\n", lclNum);
- StructPromotionInfo->canPromote = false;
+ structPromotionInfo->canPromote = false;
return;
}
#endif
if (varDsc->lvIsMultiRegRet)
{
JITDUMP(" struct promotion of V%02u is disabled because lvIsMultiRegRet\n", lclNum);
- StructPromotionInfo->canPromote = false;
+ structPromotionInfo->canPromote = false;
return;
}
CORINFO_CLASS_HANDLE typeHnd = varDsc->lvVerTypeInfo.GetClassHandle();
- lvaCanPromoteStructType(typeHnd, StructPromotionInfo, true);
+ lvaCanPromoteStructType(typeHnd, structPromotionInfo);
}
//--------------------------------------------------------------------------------------------
/*****************************************************************************
* Promote a struct type local */
-void Compiler::lvaPromoteStructVar(unsigned lclNum, lvaStructPromotionInfo* StructPromotionInfo)
+void Compiler::lvaPromoteStructVar(unsigned lclNum, lvaStructPromotionInfo* structPromotionInfo)
{
LclVarDsc* varDsc = &lvaTable[lclNum];
// We should never see a reg-sized non-field-addressed struct here.
noway_assert(!varDsc->lvRegStruct);
- noway_assert(StructPromotionInfo->canPromote);
- noway_assert(StructPromotionInfo->typeHnd == varDsc->lvVerTypeInfo.GetClassHandle());
+ noway_assert(structPromotionInfo->canPromote);
+ noway_assert(structPromotionInfo->typeHnd == varDsc->lvVerTypeInfo.GetClassHandle());
- varDsc->lvFieldCnt = StructPromotionInfo->fieldCnt;
+ varDsc->lvFieldCnt = structPromotionInfo->fieldCnt;
varDsc->lvFieldLclStart = lvaCount;
varDsc->lvPromoted = true;
- varDsc->lvContainsHoles = StructPromotionInfo->containsHoles;
- varDsc->lvCustomLayout = StructPromotionInfo->customLayout;
+ varDsc->lvContainsHoles = structPromotionInfo->containsHoles;
+ varDsc->lvCustomLayout = structPromotionInfo->customLayout;
#ifdef DEBUG
// Don't change the source to a TYP_BLK either.
#ifdef DEBUG
if (verbose)
{
- printf("\nPromoting struct local V%02u (%s):", lclNum, eeGetClassName(StructPromotionInfo->typeHnd));
+ printf("\nPromoting struct local V%02u (%s):", lclNum, eeGetClassName(structPromotionInfo->typeHnd));
}
#endif
- for (unsigned index = 0; index < StructPromotionInfo->fieldCnt; ++index)
+ for (unsigned index = 0; index < structPromotionInfo->fieldCnt; ++index)
{
- lvaStructFieldInfo* pFieldInfo = &StructPromotionInfo->fields[index];
+ lvaStructFieldInfo* pFieldInfo = &structPromotionInfo->fields[index];
if (varTypeIsFloating(pFieldInfo->fldType) || varTypeIsSIMD(pFieldInfo->fldType))
{