While working on the issue
#80218
based on Anton's PR feedback I noticed what looks like a CoreCLR runtime bug w.r.t. HFA calculation: in the routine EEClass::CheckForHFA, the switch case for ELEMENT_TYPE_VALUETYPE seems to be missing the alignment check, so that it looks like
struct F2
{
public double value;
}
[StructLayout(LayoutKind.Explicit)]
struct S
{
[FieldOffset(0)] public double f1;
[FieldOffset(3)] public F2 f2;
[FieldOffset(8)] public double f3;
}
would be erroneously identified as HFA-eligible. /cc @jkotas and @janvorli to confirm whether I'm not just misreading the code, otherwise I guess it is worth fixing in .NET 8.
Note: If JIT logic is fixed, please also fix the corresponding managed ComputeHomogeneousAggregateCharacteristic function in MetadataFieldLayoutAlgorithm.cs.
While working on the issue
#80218
based on Anton's PR feedback I noticed what looks like a CoreCLR runtime bug w.r.t. HFA calculation: in the routine
EEClass::CheckForHFA, theswitch caseforELEMENT_TYPE_VALUETYPEseems to be missing the alignment check, so that it looks likewould be erroneously identified as HFA-eligible. /cc @jkotas and @janvorli to confirm whether I'm not just misreading the code, otherwise I guess it is worth fixing in .NET 8.
Note: If JIT logic is fixed, please also fix the corresponding managed
ComputeHomogeneousAggregateCharacteristicfunction in MetadataFieldLayoutAlgorithm.cs.