Support mkrefany for x86
authorCarol Eidt <carol.eidt@microsoft.com>
Thu, 22 Sep 2016 05:49:59 +0000 (22:49 -0700)
committerCarol Eidt <carol.eidt@microsoft.com>
Thu, 22 Sep 2016 15:16:15 +0000 (08:16 -0700)
Use a GT_FIELD_LIST to pass the RefAny struct.

Fix #4183

src/jit/morph.cpp

index d1a85a1..0ca2954 100644 (file)
@@ -4103,11 +4103,22 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* callNode)
 #ifndef LEGACY_BACKEND
         if (argx->gtOper == GT_MKREFANY)
         {
-            NYI_X86("MKREFANY");
-
             // 'Lower' the MKREFANY tree and insert it.
             noway_assert(!reMorphing);
 
+#ifdef _TARGET_X86_
+
+            // Build the mkrefany as a GT_FIELD_LIST
+            GenTreeFieldList* fieldList = new (this, GT_FIELD_LIST)
+                GenTreeFieldList(argx->gtOp.gtOp1, offsetof(CORINFO_RefAny, dataPtr), TYP_I_IMPL, nullptr);
+            (void)new (this, GT_FIELD_LIST)
+                GenTreeFieldList(argx->gtOp.gtOp2, offsetof(CORINFO_RefAny, type), TYP_I_IMPL, fieldList);
+            fgArgTabEntryPtr fp = Compiler::gtArgEntryByNode(call, argx);
+            fp->node            = fieldList;
+            args->gtOp.gtOp1    = fieldList;
+
+#else  // !_TARGET_X86_
+
             // Get a new temp
             // Here we don't need unsafe value cls check since the addr of temp is used only in mkrefany
             unsigned tmp = lvaGrabTemp(true DEBUGARG("by-value mkrefany struct argument"));
@@ -4132,6 +4143,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* callNode)
             // EvalArgsToTemps will cause tmp to actually get loaded as the argument
             call->fgArgInfo->EvalToTmp(argIndex, tmp, asg);
             lvaSetVarAddrExposed(tmp);
+#endif // !_TARGET_X86_
         }
 #endif // !LEGACY_BACKEND