From 6a4a93690898f2da67c9a000d509369f0ce6a1de Mon Sep 17 00:00:00 2001 From: sivarv Date: Wed, 12 Oct 2016 10:49:03 -0700 Subject: [PATCH] Adding JIT regression test for a re-morph optimization. --- .../JitBlue/DevDiv_142976/DevDiv_142976.cs | 56 ++++++++++++++++++++++ .../JitBlue/DevDiv_142976/DevDiv_142976.csproj | 46 ++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 tests/src/JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976.cs create mode 100644 tests/src/JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976.csproj diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976.cs b/tests/src/JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976.cs new file mode 100644 index 0000000..7b01517 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + + +using System; +using System.Runtime.CompilerServices; + +// This test case is meant to test an optimization in morph that +// transforms helper call JIT_Stelem_Ref(a, null, i) to a[i] = null, +// which further gets transformed into an array address and bounds +// check nodes with references to the array local and the index +// local. It is expected while doing such a transform, array +// local and index local are appropriately ref counted and Value +// number is updated post-global-morph and jit compilation +// won't run into any asserts. +class DevDiv_142976 +{ + [MethodImpl(MethodImplOptions.NoInlining)] + public static String Foo() + { + return null; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static void Bar() + { + String[] args = new String[10]; + if (args != null) + { + throw new Exception(); + } + + String s = Foo(); + if (s == null) + { + // This will result in JIT_Stelem_Ref(args, null, 0) call + // which gets re-morphed into args[0] = null. + args[0] = s; + } + } + + public static int Main() + { + try + { + Bar(); + } + catch (Exception) + { + } + + Console.WriteLine("Pass"); + return 100; + } +} \ No newline at end of file diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976.csproj b/tests/src/JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976.csproj new file mode 100644 index 0000000..0c1a10e --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976.csproj @@ -0,0 +1,46 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages + ..\..\ + + 7a9bfb7d + + + + + + + + + False + + + + + True + + + + + + + + + $(JitPackagesConfigFileDirectory)minimal\project.json + $(JitPackagesConfigFileDirectory)minimal\project.lock.json + + + + + -- 2.7.4