Fix isByteReg() assert for x86 (#48830)
authorKunal Pathak <Kunal.Pathak@microsoft.com>
Wed, 3 Mar 2021 17:16:12 +0000 (09:16 -0800)
committerGitHub <noreply@github.com>
Wed, 3 Mar 2021 17:16:12 +0000 (09:16 -0800)
* [Windows x86] Fix isByteReg() assert

The change is similar to the one done in https://github.com/dotnet/runtime/pull/46567. If the type if `BYTE`, the use byte regs.

Fixes the following failures:

https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-47307-head-c9ab37658a344842be/System.Linq.Queryable.Tests/console.2ce37104.log?sv=2019-07-07&se=2021-03-10T08%3A39%3A45Z&sr=c&sp=rl&sig=GdS1KlEkJHVcKz7lwpZeszudWYokZpr%2Bt7IGv4c61co%3D

https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-47307-head-c9ab37658a344842be/System.Linq.Tests/console.4bc4fd10.log?sv=2019-07-07&se=2021-03-10T08%3A39%3A45Z&sr=c&sp=rl&sig=GdS1KlEkJHVcKz7lwpZeszudWYokZpr%2Bt7IGv4c61co%3D

* add an assert in allRegs()

* Revert "add an assert in allRegs()"

This reverts commit 91d9602556a06ee7e480e2730b3802ccde560ebe.

src/coreclr/jit/lsrabuild.cpp

index 06b6799..88430f7 100644 (file)
@@ -3207,8 +3207,24 @@ void LinearScan::BuildStoreLocDef(GenTreeLclVarCommon* storeLoc,
             srcInterval->assignRelatedInterval(varDefInterval);
         }
     }
-    RefPosition* def =
-        newRefPosition(varDefInterval, currentLoc + 1, RefTypeDef, storeLoc, allRegs(varDsc->TypeGet()), index);
+
+    regMaskTP defCandidates = RBM_NONE;
+    var_types type          = varDsc->TypeGet();
+
+#ifdef TARGET_X86
+    if (varTypeIsByte(type))
+    {
+        defCandidates = allByteRegs();
+    }
+    else
+    {
+        defCandidates = allRegs(type);
+    }
+#else
+    defCandidates = allRegs(type);
+#endif // TARGET_X86
+
+    RefPosition* def = newRefPosition(varDefInterval, currentLoc + 1, RefTypeDef, storeLoc, defCandidates, index);
     if (varDefInterval->isWriteThru)
     {
         // We always make write-thru defs reg-optional, as we can store them if they don't