Skip to content

Commit a7d85eb

Browse files
committed
JIT: Fix gtGetClassHandle with commas
gtGetClassHandle has comments about "Tunnel through commas", yet several of the cases then do not actually use the effective value, resulting in possible asserts when this function is passed a comma. Fixes an issue I saw in dotnet#87265 when morph invokes gtFoldTypeCompare for the following IR: ``` fgMorphTree BB19, STMT00013 (before) [000045] -ACXG------ * JTRUE void [000044] -ACXG------ \--* NE int [000623] -ACXG------ +--* COMMA ref [000622] DA--------- | +--* STORE_LCL_VAR ref V29 tmp18 [000621] ----------- | | \--* LCL_FLD ref V07 loc3 [+0] [000041] -ACXG------ | \--* CALL nullcheck ref Microsoft.Extensions.Configuration.Test.ConfigurationProviderTestBase+TestKeyValue:get_AsArray():System.String[]:this [000620] -A--------- this | \--* COMMA ref [000619] DA--------- | +--* STORE_LCL_VAR ref V30 tmp19 [000618] ----------- | | \--* LCL_FLD ref V07 loc3 [+8] [000617] ----------- | \--* LCL_VAR ref V30 tmp19 [000043] ----------- \--* CNS_INT ref null ```
1 parent 3181f9c commit a7d85eb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/coreclr/jit/gentree.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17881,9 +17881,9 @@ CORINFO_CLASS_HANDLE Compiler::gtGetClassHandle(GenTree* tree, bool* pIsExact, b
1788117881

1788217882
case GT_CNS_INT:
1788317883
{
17884-
if (tree->IsIconHandle(GTF_ICON_OBJ_HDL))
17884+
if (obj->IsIconHandle(GTF_ICON_OBJ_HDL))
1788517885
{
17886-
objClass = info.compCompHnd->getObjectType((CORINFO_OBJECT_HANDLE)tree->AsIntCon()->IconValue());
17886+
objClass = info.compCompHnd->getObjectType((CORINFO_OBJECT_HANDLE)obj->AsIntCon()->IconValue());
1788717887
if (objClass != NO_CLASS_HANDLE)
1788817888
{
1788917889
// if we managed to get a class handle it's definitely not null
@@ -17898,14 +17898,14 @@ CORINFO_CLASS_HANDLE Compiler::gtGetClassHandle(GenTree* tree, bool* pIsExact, b
1789817898
{
1789917899
// If we see a RET_EXPR, recurse through to examine the
1790017900
// return value expression.
17901-
GenTree* retExpr = tree->AsRetExpr()->gtInlineCandidate;
17901+
GenTree* retExpr = obj->AsRetExpr()->gtInlineCandidate;
1790217902
objClass = gtGetClassHandle(retExpr, pIsExact, pIsNonNull);
1790317903
break;
1790417904
}
1790517905

1790617906
case GT_CALL:
1790717907
{
17908-
GenTreeCall* call = tree->AsCall();
17908+
GenTreeCall* call = obj->AsCall();
1790917909
if (call->gtCallMoreFlags & GTF_CALL_M_SPECIAL_INTRINSIC)
1791017910
{
1791117911
NamedIntrinsic ni = lookupNamedIntrinsic(call->gtCallMethHnd);

0 commit comments

Comments
 (0)