@@ -1499,7 +1499,21 @@ MethodTableBuilder::BuildMethodTableThrowing(
1499
1499
LPCUTF8 className;
1500
1500
LPCUTF8 nameSpace;
1501
1501
HRESULT hr = GetMDImport ()->GetNameOfTypeDef (bmtInternal->pType ->GetTypeDefToken (), &className, &nameSpace);
1502
-
1502
+
1503
+ if (hr == S_OK && strcmp (nameSpace, " System.Runtime.Intrinsics" ) == 0 )
1504
+ {
1505
+ if (IsCompilationProcess ())
1506
+ {
1507
+ // Disable AOT compiling for the SIMD hardware intrinsic types. These types require special
1508
+ // ABI handling as they represent fundamental data types (__m64, __m128, and __m256) and not
1509
+ // aggregate or union types. See https://github.com/dotnet/coreclr/issues/15943
1510
+ //
1511
+ // Once they are properly handled according to the ABI requirements, we can remove this check
1512
+ // and allow them to be used in crossgen/AOT scenarios.
1513
+ COMPlusThrow (kTypeLoadException , IDS_EE_HWINTRINSIC_NGEN_DISALLOWED);
1514
+ }
1515
+ }
1516
+
1503
1517
#if defined(_TARGET_ARM64_)
1504
1518
// All the funtions in System.Runtime.Intrinsics.Arm.Arm64 are hardware intrinsics.
1505
1519
if (hr == S_OK && strcmp (nameSpace, " System.Runtime.Intrinsics.Arm.Arm64" ) == 0 )
@@ -1844,6 +1858,24 @@ MethodTableBuilder::BuildMethodTableThrowing(
1844
1858
pMT->SetIsByRefLike ();
1845
1859
}
1846
1860
1861
+ // If this type is marked by [Intrinsic] attribute, it may be specially treated by the runtime/compiler
1862
+ // Currently, only SIMD types have [Intrinsic] attribute
1863
+ //
1864
+ // We check this here, before the SystemVAmd64CheckForPass[Native]StructInRegister calls to ensure the SIMD
1865
+ // intrinsics are not enregistered incorrectly.
1866
+ if ((GetModule ()->IsSystem () || GetAssembly ()->IsSIMDVectorAssembly ()) && IsValueClass () && bmtGenerics->HasInstantiation ())
1867
+ {
1868
+ HRESULT hr = GetMDImport ()->GetCustomAttributeByName (bmtInternal->pType ->GetTypeDefToken (),
1869
+ g_CompilerServicesIntrinsicAttribute,
1870
+ NULL ,
1871
+ NULL );
1872
+
1873
+ if (hr == S_OK)
1874
+ {
1875
+ pMT->SetIsIntrinsicType ();
1876
+ }
1877
+ }
1878
+
1847
1879
if (IsValueClass ())
1848
1880
{
1849
1881
if (bmtFP->NumInstanceFieldBytes != totalDeclaredFieldSize || HasOverLayedField ())
@@ -2025,21 +2057,6 @@ MethodTableBuilder::BuildMethodTableThrowing(
2025
2057
pMT->SetICastable ();
2026
2058
}
2027
2059
#endif // FEATURE_ICASTABLE
2028
-
2029
- // If this type is marked by [Intrinsic] attribute, it may be specially treated by the runtime/compiler
2030
- // Currently, only SIMD types have [Intrinsic] attribute
2031
- if ((GetModule ()->IsSystem () || GetAssembly ()->IsSIMDVectorAssembly ()) && IsValueClass () && bmtGenerics->HasInstantiation ())
2032
- {
2033
- HRESULT hr = GetMDImport ()->GetCustomAttributeByName (bmtInternal->pType ->GetTypeDefToken (),
2034
- g_CompilerServicesIntrinsicAttribute,
2035
- NULL ,
2036
- NULL );
2037
-
2038
- if (hr == S_OK)
2039
- {
2040
- pMT->SetIsIntrinsicType ();
2041
- }
2042
- }
2043
2060
2044
2061
// Grow the typedef ridmap in advance as we can't afford to
2045
2062
// fail once we set the resolve bit
0 commit comments