From 0d5e5766c6688a5ab29d6e96c01abbfe1ad3659c Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Fri, 10 Jul 2020 15:52:29 -0700 Subject: [PATCH] Fix STOREIND optimization. (#39066) * add 1 repro test. * temporary disable the tranformation. --- src/coreclr/src/jit/lower.cpp | 3 ++ .../JitBlue/WPF_3226/CSharpRepro/WPF_3226.cs | 51 ++++++++++++++++++++++ .../JitBlue/WPF_3226/CSharpRepro/WPF_3226.csproj | 13 ++++++ 3 files changed, 67 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.cs create mode 100644 src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.csproj diff --git a/src/coreclr/src/jit/lower.cpp b/src/coreclr/src/jit/lower.cpp index 60c6d4e..69cfbbe 100644 --- a/src/coreclr/src/jit/lower.cpp +++ b/src/coreclr/src/jit/lower.cpp @@ -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 index 0000000..af4264e --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.cs @@ -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 index 0000000..5d49e8d --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/WPF_3226/CSharpRepro/WPF_3226.csproj @@ -0,0 +1,13 @@ + + + Exe + + + + True + True + + + + + -- 2.7.4