Fix STOREIND optimization. (#39066)
authorSergey Andreenko <seandree@microsoft.com>
Fri, 10 Jul 2020 22:52:29 +0000 (15:52 -0700)
committerGitHub <noreply@github.com>
Fri, 10 Jul 2020 22:52:29 +0000 (15:52 -0700)
* add 1 repro test.

* temporary disable the tranformation.

src/coreclr/src/jit/lower.cpp
src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.csproj [new file with mode: 0644]

index 60c6d4e..69cfbbe 100644 (file)
@@ -6530,6 +6530,8 @@ void Lowering::LowerBlockStoreCommon(GenTreeBlk* blkNode)
 bool Lowering::TryTransformStoreObjAsStoreInd(GenTreeBlk* blkNode)
 {
     assert(blkNode->OperIs(GT_STORE_BLK, GT_STORE_DYN_BLK, GT_STORE_OBJ));
+    return false;
+#if 0 // the optimization is temporary disabled due to https://github.com/dotnet/wpf/issues/3226 issue.
     if (blkNode->OperIs(GT_STORE_DYN_BLK))
     {
         return false;
@@ -6597,4 +6599,5 @@ bool Lowering::TryTransformStoreObjAsStoreInd(GenTreeBlk* blkNode)
     }
     LowerStoreIndirCommon(blkNode);
     return true;
+#endif
 }
diff --git a/src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.cs b/src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.cs
new file mode 100644 (file)
index 0000000..af4264e
--- /dev/null
@@ -0,0 +1,51 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[StructLayout(LayoutKind.Sequential)]
+class POINT 
+{
+    public int x;
+    public int y;
+    public override string ToString() => $"{{{x}, {y}}}";
+}
+
+[StructLayout(LayoutKind.Sequential)]
+class MINMAXINFO 
+{
+    public POINT ptMinTrackSize = new POINT();
+    public POINT ptMaxTrackSize = new POINT();
+}
+
+class Test
+{
+    static void WmGetMinMaxInfo(IntPtr lParam)
+    {
+        MINMAXINFO mmi = new MINMAXINFO();
+
+        mmi.ptMinTrackSize.x = 100101;
+        mmi.ptMinTrackSize.y = 102103;
+        mmi.ptMaxTrackSize.x = 200201;
+        mmi.ptMaxTrackSize.y = 202203;
+
+        Marshal.StructureToPtr(mmi, lParam, true);
+    }
+
+    public unsafe static int Main()
+    {
+        MINMAXINFO mmi = new MINMAXINFO();
+        IntPtr pmmi = Marshal.AllocHGlobal(Marshal.SizeOf(mmi));
+        WmGetMinMaxInfo(pmmi);
+        mmi = (MINMAXINFO) Marshal.PtrToStructure(pmmi, typeof(MINMAXINFO));
+        bool valid =  mmi.ptMinTrackSize.x == 100101 &&  mmi.ptMinTrackSize.y == 102103 &&  mmi.ptMaxTrackSize.x == 200201 && mmi.ptMaxTrackSize.y == 202203;
+        if (!valid)
+        {
+            Console.WriteLine($"Got {mmi.ptMinTrackSize}, expected {{100101, 102103}}");
+            Console.WriteLine($"Got {mmi.ptMaxTrackSize}, expected {{200201, 202203}}");
+        }
+        return valid ? 100 : -1;
+    }
+}
diff --git a/src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.csproj b/src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.csproj
new file mode 100644 (file)
index 0000000..5d49e8d
--- /dev/null
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+  </PropertyGroup>
+  <PropertyGroup>
+    <DebugType />
+    <Optimize>True</Optimize>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="$(MSBuildProjectName).cs" />
+  </ItemGroup>
+</Project>