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
structF2{publicdoublevalue;}[StructLayout(LayoutKind.Explicit)]structS{[FieldOffset(0)]publicdoublef1;[FieldOffset(3)]publicF2f2;[FieldOffset(8)]publicdoublef3;}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.