summaryrefslogtreecommitdiff
path: root/packaging/0020-JIT-port-fix-to-defer-removing-statements-during-opt.patch
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/0020-JIT-port-fix-to-defer-removing-statements-during-opt.patch')
-rw-r--r--packaging/0020-JIT-port-fix-to-defer-removing-statements-during-opt.patch132
1 files changed, 132 insertions, 0 deletions
diff --git a/packaging/0020-JIT-port-fix-to-defer-removing-statements-during-opt.patch b/packaging/0020-JIT-port-fix-to-defer-removing-statements-during-opt.patch
new file mode 100644
index 0000000000..db0d267dc2
--- /dev/null
+++ b/packaging/0020-JIT-port-fix-to-defer-removing-statements-during-opt.patch
@@ -0,0 +1,132 @@
+From 240ffdf43611fda5d22672f56be5760803d1a011 Mon Sep 17 00:00:00 2001
+From: Andy Ayers <andya@microsoft.com>
+Date: Mon, 4 Dec 2017 11:22:26 -0800
+Subject: [PATCH 20/47] JIT: port fix to defer removing statements during opt
+ CSE to release/2.0.0
+
+Port of #15323.
+Related issue #15319.
+---
+ src/jit/morph.cpp | 8 +++-
+ .../JitBlue/GitHub_15319/GitHub_15319.cs | 44 ++++++++++++++++++++++
+ .../JitBlue/GitHub_15319/GitHub_15319.csproj | 38 +++++++++++++++++++
+ 3 files changed, 89 insertions(+), 1 deletion(-)
+ create mode 100644 tests/src/JIT/Regression/JitBlue/GitHub_15319/GitHub_15319.cs
+ create mode 100644 tests/src/JIT/Regression/JitBlue/GitHub_15319/GitHub_15319.csproj
+
+diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp
+index 79b3fef..993ce53 100644
+--- a/src/jit/morph.cpp
++++ b/src/jit/morph.cpp
+@@ -15695,7 +15695,13 @@ bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreeStmt* stmt DEBUGARG(co
+ }
+
+ // Can the entire tree be removed?
+- bool removedStmt = fgCheckRemoveStmt(block, stmt);
++ bool removedStmt = false;
++
++ // Defer removing statements during CSE so we don't inadvertently remove any CSE defs.
++ if (!optValnumCSE_phase)
++ {
++ removedStmt = fgCheckRemoveStmt(block, stmt);
++ }
+
+ // Or this is the last statement of a conditional branch that was just folded?
+ if (!removedStmt && (stmt->getNextStmt() == nullptr) && !fgRemoveRestOfBlock)
+diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_15319/GitHub_15319.cs b/tests/src/JIT/Regression/JitBlue/GitHub_15319/GitHub_15319.cs
+new file mode 100644
+index 0000000..af7419f
+--- /dev/null
++++ b/tests/src/JIT/Regression/JitBlue/GitHub_15319/GitHub_15319.cs
+@@ -0,0 +1,44 @@
++// 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.Linq;
++
++// Bug where interacting CSEs of N - Old.Length and Old.Length
++// were not handled properly in optCSE
++
++class P
++{
++ private static int Main(string[] args)
++ {
++ var ar = new double[]
++ {
++ 100
++ };
++
++ FillTo1(ref ar, 5);
++ Console.WriteLine(string.Join(",", ar.Select(a => a.ToString()).ToArray()));
++ return (int)ar[4];
++ }
++
++ public static void FillTo1(ref double[] dd, int N)
++ {
++ if (dd.Length >= N)
++ return;
++
++ double[] Old = dd;
++ double d = double.NaN;
++ if (Old.Length > 0)
++ d = Old[0];
++
++ dd = new double[N];
++
++ for (int i = 0; i < Old.Length; i++)
++ {
++ dd[N - Old.Length + i] = Old[i];
++ }
++ for (int i = 0; i < N - Old.Length; i++)
++ dd[i] = d;
++ }
++}
+diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_15319/GitHub_15319.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_15319/GitHub_15319.csproj
+new file mode 100644
+index 0000000..c3a87c1
+--- /dev/null
++++ b/tests/src/JIT/Regression/JitBlue/GitHub_15319/GitHub_15319.csproj
+@@ -0,0 +1,38 @@
++<?xml version="1.0" encoding="utf-8"?>
++<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
++ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
++ <PropertyGroup>
++ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
++ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
++ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
++ <SchemaVersion>2.0</SchemaVersion>
++ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
++ <OutputType>Exe</OutputType>
++ <AppDesignerFolder>Properties</AppDesignerFolder>
++ <FileAlignment>512</FileAlignment>
++ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
++ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
++ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
++ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
++ </PropertyGroup>
++ <!-- Default configurations to help VS understand the configurations -->
++ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
++ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
++ <ItemGroup>
++ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
++ <Visible>False</Visible>
++ </CodeAnalysisDependentAssemblyPaths>
++ </ItemGroup>
++ <PropertyGroup>
++ <DebugType></DebugType>
++ <Optimize>True</Optimize>
++ </PropertyGroup>
++ <ItemGroup>
++ <Compile Include="GitHub_15319.cs" />
++ </ItemGroup>
++ <ItemGroup>
++ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
++ </ItemGroup>
++ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
++ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
++</Project>
+--
+2.7.4
+