@@ -965,39 +965,6 @@ GenTree* Compiler::impStoreStruct(GenTree* store,
965
965
return src;
966
966
}
967
967
}
968
- else if (src->OperIs(GT_MKREFANY))
969
- {
970
- // Since we are assigning the result of a GT_MKREFANY, "destAddr" must point to a refany.
971
- // TODO-CQ: we can do this without address-exposing the local on the LHS.
972
- GenTreeFlags indirFlags = GTF_EMPTY;
973
- GenTree* destAddr = impGetNodeAddr(store, CHECK_SPILL_ALL, &indirFlags);
974
- GenTree* destAddrClone;
975
- destAddr = impCloneExpr(destAddr, &destAddrClone, curLevel, pAfterStmt DEBUGARG("MKREFANY assignment"));
976
-
977
- assert(OFFSETOF__CORINFO_TypedReference__dataPtr == 0);
978
- assert(destAddr->gtType == TYP_I_IMPL || destAddr->gtType == TYP_BYREF);
979
-
980
- // Append the store of the pointer value.
981
- // TODO-Bug: the pointer value can be a byref. Use its actual type here instead of TYP_I_IMPL.
982
- GenTree* ptrFieldStore = gtNewStoreIndNode(TYP_I_IMPL, destAddr, src->AsOp()->gtOp1, indirFlags);
983
- if (pAfterStmt)
984
- {
985
- Statement* newStmt = gtNewStmt(ptrFieldStore, usedDI);
986
- fgInsertStmtAfter(block, *pAfterStmt, newStmt);
987
- *pAfterStmt = newStmt;
988
- }
989
- else
990
- {
991
- impAppendTree(ptrFieldStore, curLevel, usedDI);
992
- }
993
-
994
- GenTree* typeFieldOffset = gtNewIconNode(OFFSETOF__CORINFO_TypedReference__type, TYP_I_IMPL);
995
- GenTree* typeFieldAddr = gtNewOperNode(GT_ADD, genActualType(destAddr), destAddrClone, typeFieldOffset);
996
- GenTree* typeFieldStore = gtNewStoreIndNode(TYP_I_IMPL, typeFieldAddr, src->AsOp()->gtOp2);
997
-
998
- // Return the store of the type value, to be appended.
999
- return typeFieldStore;
1000
- }
1001
968
else if (src->OperIs(GT_COMMA))
1002
969
{
1003
970
if (pAfterStmt)
@@ -9601,31 +9568,14 @@ void Compiler::impImportBlockCode(BasicBlock* block)
9601
9568
{
9602
9569
op1 = impPopStack().val;
9603
9570
9604
- if (op1->OperIs(GT_MKREFANY))
9605
- {
9606
- // The pointer may have side-effects
9607
- if (op1->AsOp()->gtOp1->gtFlags & GTF_SIDE_EFFECT)
9608
- {
9609
- impAppendTree(op1->AsOp()->gtOp1, CHECK_SPILL_ALL, impCurStmtDI);
9610
- #ifdef DEBUG
9611
- impNoteLastILoffs();
9612
- #endif
9613
- }
9571
+ // Get the address of the refany
9572
+ GenTreeFlags indirFlags = GTF_EMPTY;
9573
+ op1 = impGetNodeAddr(op1, CHECK_SPILL_ALL, &indirFlags);
9614
9574
9615
- // We already have the class handle
9616
- op1 = op1->AsOp()->gtOp2;
9617
- }
9618
- else
9619
- {
9620
- // Get the address of the refany
9621
- GenTreeFlags indirFlags = GTF_EMPTY;
9622
- op1 = impGetNodeAddr(op1, CHECK_SPILL_ALL, &indirFlags);
9623
-
9624
- // Fetch the type from the correct slot
9625
- op1 = gtNewOperNode(GT_ADD, TYP_BYREF, op1,
9626
- gtNewIconNode(OFFSETOF__CORINFO_TypedReference__type, TYP_I_IMPL));
9627
- op1 = gtNewIndir(TYP_BYREF, op1, indirFlags);
9628
- }
9575
+ // Fetch the type from the correct slot
9576
+ op1 = gtNewOperNode(GT_ADD, TYP_BYREF, op1,
9577
+ gtNewIconNode(OFFSETOF__CORINFO_TypedReference__type, TYP_I_IMPL));
9578
+ op1 = gtNewIndir(TYP_BYREF, op1, indirFlags);
9629
9579
9630
9580
// Convert native TypeHandle to RuntimeTypeHandle.
9631
9581
op1 = gtNewHelperCallNode(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_MAYBENULL, TYP_STRUCT, op1);
@@ -10309,16 +10259,9 @@ void Compiler::impImportBlockCode(BasicBlock* block)
10309
10259
}
10310
10260
10311
10261
case CEE_MKREFANY:
10312
-
10262
+ {
10313
10263
assert(!compIsForInlining());
10314
10264
10315
- // Being lazy here. Refanys are tricky in terms of gc tracking.
10316
- // Since it is uncommon, just don't perform struct promotion in any method that contains mkrefany.
10317
-
10318
- JITDUMP("disabling struct promotion because of mkrefany\n");
10319
- fgNoStructPromotion = true;
10320
-
10321
- oper = GT_MKREFANY;
10322
10265
assertImp(sz == sizeof(unsigned));
10323
10266
10324
10267
_impResolveToken(CORINFO_TOKENKIND_Class);
@@ -10339,13 +10282,21 @@ void Compiler::impImportBlockCode(BasicBlock* block)
10339
10282
10340
10283
// @SPECVIOLATION: TYP_INT should not be allowed here by a strict reading of the spec.
10341
10284
// But JIT32 allowed it, so we continue to allow it.
10342
- assertImp(op1->TypeGet() == TYP_BYREF || op1->TypeGet() == TYP_I_IMPL || op1->TypeGet() == TYP_INT);
10285
+ assertImp(op1->TypeIs( TYP_BYREF, TYP_I_IMPL, TYP_INT) );
10343
10286
10344
- // MKREFANY returns a struct. op2 is the class token.
10345
- op1 = gtNewOperNode(oper, TYP_STRUCT, op1, op2 );
10287
+ unsigned refAnyLcl = lvaGrabTemp(false DEBUGARG("mkrefany temp"));
10288
+ lvaSetStruct(refAnyLcl, impGetRefAnyClass(), false );
10346
10289
10347
- impPushOnStack(op1, verMakeTypeInfo(impGetRefAnyClass()));
10290
+ GenTree* storeData =
10291
+ gtNewStoreLclFldNode(refAnyLcl, op1->TypeGet(), OFFSETOF__CORINFO_TypedReference__dataPtr, op1);
10292
+ GenTree* storeType =
10293
+ gtNewStoreLclFldNode(refAnyLcl, op2->TypeGet(), OFFSETOF__CORINFO_TypedReference__type, op2);
10294
+ impAppendTree(storeData, CHECK_SPILL_ALL, impCurStmtDI);
10295
+ impAppendTree(storeType, CHECK_SPILL_ALL, impCurStmtDI);
10296
+
10297
+ impPushOnStack(gtNewLclVarNode(refAnyLcl, TYP_STRUCT), verMakeTypeInfo(impGetRefAnyClass()));
10348
10298
break;
10299
+ }
10349
10300
10350
10301
case CEE_LDOBJ:
10351
10302
{
@@ -12639,12 +12590,6 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,
12639
12590
12640
12591
assert(!curArgVal->OperIs(GT_RET_EXPR));
12641
12592
12642
- if (curArgVal->gtOper == GT_MKREFANY)
12643
- {
12644
- inlineResult->NoteFatal(InlineObservation::CALLSITE_ARG_IS_MKREFANY);
12645
- return;
12646
- }
12647
-
12648
12593
GenTree* lclVarTree;
12649
12594
const bool isAddressInLocal = impIsAddressInLocal(curArgVal, &lclVarTree);
12650
12595
if (isAddressInLocal)
0 commit comments