mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-10 10:00:57 +09:00
Convert asserts in CEEInfo::getStaticFieldContent() to 'if' checks (#100320)
* Add additional checks to optimization of constant static field loads In `fgGetStaticFieldSeqAndAddress`, if we have a static field address altered by a tree of `ADD CNS_INS` nodes, we need to verify that the address is within the found field sequence. It might not be after shared constant CSE kicks in (e.g., under OptRepeat), where the sequence of ADDs might be the alter an arbitrary constant address from one type into the address of the static field of a different type. So we can't use the FieldSeq of the base address when considering the full offset. * Review feedback 1. Use `eeGetFieldName` / `eeGetClassName` return pointer 2. Only query extra metadata under `verbose || JitConfig.EnableExtraSuperPmiQueries()` * Convert asserts in CEEInfo::getStaticFieldContent() to 'if' checks * Make fgGetStaticFieldSeqAndAddress static * Code review feedback
This commit is contained in:
parent
2a846acb1a
commit
c4796a3626
6 changed files with 72 additions and 56 deletions
|
@ -10919,7 +10919,11 @@ void Compiler::fgValueNumberSsaVarDef(GenTreeLclVarCommon* lcl)
|
|||
// Return Value:
|
||||
// true if the given tree is a static field address
|
||||
//
|
||||
static bool GetStaticFieldSeqAndAddress(ValueNumStore* vnStore, GenTree* tree, ssize_t* byteOffset, FieldSeq** pFseq)
|
||||
/* static */
|
||||
bool Compiler::fgGetStaticFieldSeqAndAddress(ValueNumStore* vnStore,
|
||||
GenTree* tree,
|
||||
ssize_t* byteOffset,
|
||||
FieldSeq** pFseq)
|
||||
{
|
||||
VNFuncApp funcApp;
|
||||
if (vnStore->GetVNFunc(tree->gtVNPair.GetLiberal(), &funcApp) && (funcApp.m_func == VNF_PtrToStatic))
|
||||
|
@ -10934,7 +10938,6 @@ static bool GetStaticFieldSeqAndAddress(ValueNumStore* vnStore, GenTree* tree, s
|
|||
return true;
|
||||
}
|
||||
}
|
||||
ssize_t val = 0;
|
||||
|
||||
// Special cases for NativeAOT:
|
||||
// ADD(ICON_STATIC, CNS_INT) // nonGC-static base
|
||||
|
@ -10952,6 +10955,7 @@ static bool GetStaticFieldSeqAndAddress(ValueNumStore* vnStore, GenTree* tree, s
|
|||
}
|
||||
|
||||
// Accumulate final offset
|
||||
ssize_t val = 0;
|
||||
while (tree->OperIs(GT_ADD))
|
||||
{
|
||||
GenTree* op1 = tree->gtGetOp1();
|
||||
|
@ -10991,6 +10995,7 @@ static bool GetStaticFieldSeqAndAddress(ValueNumStore* vnStore, GenTree* tree, s
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -11074,7 +11079,7 @@ bool Compiler::fgValueNumberConstLoad(GenTreeIndir* tree)
|
|||
const int maxElementSize = sizeof(simd_t);
|
||||
|
||||
if (!tree->TypeIs(TYP_BYREF, TYP_STRUCT) &&
|
||||
GetStaticFieldSeqAndAddress(vnStore, tree->gtGetOp1(), &byteOffset, &fieldSeq))
|
||||
fgGetStaticFieldSeqAndAddress(vnStore, tree->gtGetOp1(), &byteOffset, &fieldSeq))
|
||||
{
|
||||
CORINFO_FIELD_HANDLE fieldHandle = fieldSeq->GetFieldHandle();
|
||||
if ((fieldHandle != nullptr) && (size > 0) && (size <= maxElementSize) && ((size_t)byteOffset < INT_MAX))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue