From 0d6880d377bdedd4c64635760d25fb57ba573910 Mon Sep 17 00:00:00 2001 From: Fei Peng Date: Sun, 17 Dec 2017 18:17:46 -0800 Subject: [PATCH] gtNewMustThrowException works with SIMD and struct --- src/jit/compiler.h | 2 +- src/jit/gentree.cpp | 16 ++++++++++++---- src/jit/hwintrinsicxarch.cpp | 9 +++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/jit/compiler.h b/src/jit/compiler.h index e8c5b12ab6d8..1fd5d8330759 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -2067,7 +2067,7 @@ class Compiler GenTree* op1, GenTree* op2, NamedIntrinsic hwIntrinsicID); - GenTree* gtNewMustThrowException(unsigned helper, var_types type); + GenTree* gtNewMustThrowException(unsigned helper, var_types type, CORINFO_CLASS_HANDLE clsHnd); CORINFO_CLASS_HANDLE gtGetStructHandleForHWSIMD(var_types simdType, var_types simdBaseType); #endif // FEATURE_HW_INTRINSICS diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index 4984df2c46c8..196e3c99bd12 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -17858,15 +17858,23 @@ GenTreeHWIntrinsic* Compiler::gtNewScalarHWIntrinsicNode(var_types type, // Return Value // pointer to the throw node // -GenTree* Compiler::gtNewMustThrowException(unsigned helper, var_types type) +GenTree* Compiler::gtNewMustThrowException(unsigned helper, var_types type, CORINFO_CLASS_HANDLE clsHnd) { GenTreeCall* node = gtNewHelperCallNode(helper, TYP_VOID); node->gtCallMoreFlags |= GTF_CALL_M_DOES_NOT_RETURN; if (type != TYP_VOID) { - unsigned dummyTemp = lvaGrabTemp(true DEBUGARG("dummy temp of must thrown exception")); - lvaTable[dummyTemp].lvType = type; - GenTree* dummyNode = gtNewLclvNode(dummyTemp, type); + unsigned dummyTemp = lvaGrabTemp(true DEBUGARG("dummy temp of must thrown exception")); + if (type == TYP_STRUCT) + { + lvaSetStruct(dummyTemp, clsHnd, false); + type = lvaTable[dummyTemp].lvType; // struct type is normalized + } + else + { + lvaTable[dummyTemp].lvType = type; + } + GenTree* dummyNode = gtNewLclvNode(dummyTemp, type); return gtNewOperNode(GT_COMMA, type, node, dummyNode); } return node; diff --git a/src/jit/hwintrinsicxarch.cpp b/src/jit/hwintrinsicxarch.cpp index e406d8868768..f2f98b41ff7c 100644 --- a/src/jit/hwintrinsicxarch.cpp +++ b/src/jit/hwintrinsicxarch.cpp @@ -212,7 +212,8 @@ GenTree* Compiler::impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HA { impPopStack(); } - return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, JITtype2varType(sig->retType)); + return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, JITtype2varType(sig->retType), + sig->retTypeClass); } switch (isa) { @@ -425,7 +426,7 @@ GenTree* Compiler::impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HA #ifdef _TARGET_X86_ if (varTypeIsLong(callType)) { - return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType); + return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType, sig->retTypeClass); } #endif argLst = info.compCompHnd->getArgNext(argLst); // the second argument @@ -565,7 +566,7 @@ GenTree* Compiler::impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HA #ifdef _TARGET_X86_ if (varTypeIsLong(callType)) { - return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType); + return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType, sig->retTypeClass); } #endif retNode = gtNewScalarHWIntrinsicNode(callType, op1, NI_LZCNT_LeadingZeroCount); @@ -608,7 +609,7 @@ GenTree* Compiler::impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_H #ifdef _TARGET_X86_ if (varTypeIsLong(callType)) { - return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType); + return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType, sig->retTypeClass); } #endif retNode = gtNewScalarHWIntrinsicNode(callType, op1, NI_POPCNT_PopCount);