Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 0d6880d

Browse files
committed
gtNewMustThrowException works with SIMD and struct
1 parent 78e6deb commit 0d6880d

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/jit/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,7 @@ class Compiler
20672067
GenTree* op1,
20682068
GenTree* op2,
20692069
NamedIntrinsic hwIntrinsicID);
2070-
GenTree* gtNewMustThrowException(unsigned helper, var_types type);
2070+
GenTree* gtNewMustThrowException(unsigned helper, var_types type, CORINFO_CLASS_HANDLE clsHnd);
20712071
CORINFO_CLASS_HANDLE gtGetStructHandleForHWSIMD(var_types simdType, var_types simdBaseType);
20722072
#endif // FEATURE_HW_INTRINSICS
20732073

src/jit/gentree.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17858,15 +17858,23 @@ GenTreeHWIntrinsic* Compiler::gtNewScalarHWIntrinsicNode(var_types type,
1785817858
// Return Value
1785917859
// pointer to the throw node
1786017860
//
17861-
GenTree* Compiler::gtNewMustThrowException(unsigned helper, var_types type)
17861+
GenTree* Compiler::gtNewMustThrowException(unsigned helper, var_types type, CORINFO_CLASS_HANDLE clsHnd)
1786217862
{
1786317863
GenTreeCall* node = gtNewHelperCallNode(helper, TYP_VOID);
1786417864
node->gtCallMoreFlags |= GTF_CALL_M_DOES_NOT_RETURN;
1786517865
if (type != TYP_VOID)
1786617866
{
17867-
unsigned dummyTemp = lvaGrabTemp(true DEBUGARG("dummy temp of must thrown exception"));
17868-
lvaTable[dummyTemp].lvType = type;
17869-
GenTree* dummyNode = gtNewLclvNode(dummyTemp, type);
17867+
unsigned dummyTemp = lvaGrabTemp(true DEBUGARG("dummy temp of must thrown exception"));
17868+
if (type == TYP_STRUCT)
17869+
{
17870+
lvaSetStruct(dummyTemp, clsHnd, false);
17871+
type = lvaTable[dummyTemp].lvType; // struct type is normalized
17872+
}
17873+
else
17874+
{
17875+
lvaTable[dummyTemp].lvType = type;
17876+
}
17877+
GenTree* dummyNode = gtNewLclvNode(dummyTemp, type);
1787017878
return gtNewOperNode(GT_COMMA, type, node, dummyNode);
1787117879
}
1787217880
return node;

src/jit/hwintrinsicxarch.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ GenTree* Compiler::impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HA
212212
{
213213
impPopStack();
214214
}
215-
return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, JITtype2varType(sig->retType));
215+
return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, JITtype2varType(sig->retType),
216+
sig->retTypeClass);
216217
}
217218
switch (isa)
218219
{
@@ -425,7 +426,7 @@ GenTree* Compiler::impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HA
425426
#ifdef _TARGET_X86_
426427
if (varTypeIsLong(callType))
427428
{
428-
return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType);
429+
return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType, sig->retTypeClass);
429430
}
430431
#endif
431432
argLst = info.compCompHnd->getArgNext(argLst); // the second argument
@@ -565,7 +566,7 @@ GenTree* Compiler::impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HA
565566
#ifdef _TARGET_X86_
566567
if (varTypeIsLong(callType))
567568
{
568-
return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType);
569+
return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType, sig->retTypeClass);
569570
}
570571
#endif
571572
retNode = gtNewScalarHWIntrinsicNode(callType, op1, NI_LZCNT_LeadingZeroCount);
@@ -608,7 +609,7 @@ GenTree* Compiler::impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_H
608609
#ifdef _TARGET_X86_
609610
if (varTypeIsLong(callType))
610611
{
611-
return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType);
612+
return gtNewMustThrowException(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, callType, sig->retTypeClass);
612613
}
613614
#endif
614615
retNode = gtNewScalarHWIntrinsicNode(callType, op1, NI_POPCNT_PopCount);

0 commit comments

Comments
 (0)