提交 38928d62 编写于 作者: J Jan Vorlicek 提交者: GitHub

Fix SIMD intrinsics handling in crossgen2 (dotnet/coreclr#27853)

* Fix SIMD intrinsics handling in crossgen2

Crossgen2 was compiling methods that call SIMD intrinsics
(System.Numerics.Vector<T>). This is not correct, as the size of the
vector is a runtime specific detail - e.g. when running on devices
without SSE2 support, the size is 4 and when running on devices with
SSE2 support, the size is 8.
This fixes runtime errors in 6 coreclr pri 0 tests.

* Reflect PR feedback

Create a IsVectorOfT method and use it at all places where we were
previously checking the namespace and type name of Vector<T>


Commit migrated from https://github.com/dotnet/coreclr/commit/0f9814cc4e25ee4060d8f3ae2305210aef94f1bc
上级 364b8d19
......@@ -106,5 +106,10 @@ public static bool IsVectorType(DefType type)
type.Name == "Vector128`1" ||
type.Name == "Vector256`1");
}
public static bool IsVectorOfTType(DefType type)
{
return type.IsIntrinsic && type.Namespace == "System.Numerics" && type.Name == "Vector`1";
}
}
}
......@@ -697,6 +697,15 @@ private uint getMethodAttribsInternal(MethodDesc method)
result |= CorInfoFlag.CORINFO_FLG_FINAL;
}
#if READYTORUN
// Check for SIMD intrinsics
DefType owningDefType = method.OwningType as DefType;
if (owningDefType != null && VectorFieldLayoutAlgorithm.IsVectorOfTType(owningDefType))
{
throw new RequiresRuntimeJitException("This function is using SIMD intrinsics, their size is machine specific");
}
#endif
// Check for hardware intrinsics
if (HardwareIntrinsicHelpers.IsHardwareIntrinsic(method))
{
......
......@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using ILCompiler;
using Internal.TypeSystem;
namespace Internal.JitInterface
......@@ -261,16 +262,8 @@ static SystemVClassificationType ReClassifyField(SystemVClassificationType origi
InstantiatedType instantiatedType = typeDesc as InstantiatedType;
if (instantiatedType != null)
{
string typeName = instantiatedType.Name;
string namespaceName = instantiatedType.Namespace;
if (typeName == "Vector256`1" || typeName == "Vector128`1" || typeName == "Vector64`1")
{
Debug.Assert(namespaceName == "System.Runtime.Intrinsics");
return false;
}
if ((typeName == "Vector`1") && (namespaceName == "System.Numerics"))
if (VectorFieldLayoutAlgorithm.IsVectorType(instantiatedType) ||
VectorFieldLayoutAlgorithm.IsVectorOfTType(instantiatedType))
{
return false;
}
......
......@@ -45,7 +45,7 @@ public override FieldLayoutAlgorithm GetLayoutAlgorithmForType(DefType type)
throw new NotImplementedException();
else if (type.IsRuntimeDeterminedType)
throw new NotImplementedException();
else if (type.IsIntrinsic && (type.Name == "Vector`1") && (type.Namespace == "System.Numerics"))
else if (VectorIntrinsicFieldLayoutAlgorithm.IsVectorOfTType(type))
{
return _vectorFieldLayoutAlgorithm;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册