summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Sullivan <briansul@microsoft.com>2020-02-13 14:26:51 -0800
committerHyungju Lee <leee.lee@samsung.com>2020-10-30 18:22:08 +0900
commit4c3b471c380dcc01579c18ae5756480d27cd1ea1 (patch)
tree98368132ce4b392168fe80e6e675d31b6d788d2e
parent5700c9b189b25a7c68936bde8d11b45e17d95f83 (diff)
downloadcoreclr-4c3b471c380dcc01579c18ae5756480d27cd1ea1.tar.gz
coreclr-4c3b471c380dcc01579c18ae5756480d27cd1ea1.tar.bz2
coreclr-4c3b471c380dcc01579c18ae5756480d27cd1ea1.zip
Port the 5.0 fix for issue #1104 (#28003)
* Port the 5.0 fix for issue #1104 3.1 - Pull Request Runtime\#1734 - This change corrects a cut-and paste typo with a previous commit. - Includes test case Runtime_1104.cs * Updated the csproj to use 3.1 syntax
-rw-r--r--src/jit/rangecheck.cpp2
-rw-r--r--tests/src/JIT/Regression/JitBlue/Runtime_1104/Runtime_1104.cs62
-rw-r--r--tests/src/JIT/Regression/JitBlue/Runtime_1104/Runtime_1104.csproj33
3 files changed, 96 insertions, 1 deletions
diff --git a/src/jit/rangecheck.cpp b/src/jit/rangecheck.cpp
index 96fcaf9561..5c26087864 100644
--- a/src/jit/rangecheck.cpp
+++ b/src/jit/rangecheck.cpp
@@ -362,7 +362,7 @@ bool RangeCheck::IsMonotonicallyIncreasing(GenTree* expr, bool rejectNegativeCon
JITDUMP("[RangeCheck::IsMonotonicallyIncreasing] [%06d]\n", Compiler::dspTreeID(expr));
// Add hashtable entry for expr.
- bool alreadyPresent = !m_pSearchPath->Set(expr, nullptr, SearchPath::Overwrite);
+ bool alreadyPresent = m_pSearchPath->Set(expr, nullptr, SearchPath::Overwrite);
if (alreadyPresent)
{
return true;
diff --git a/tests/src/JIT/Regression/JitBlue/Runtime_1104/Runtime_1104.cs b/tests/src/JIT/Regression/JitBlue/Runtime_1104/Runtime_1104.cs
new file mode 100644
index 0000000000..da0de8fadf
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/Runtime_1104/Runtime_1104.cs
@@ -0,0 +1,62 @@
+// 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.Diagnostics;
+using System.Runtime.CompilerServices;
+
+class Runtime_1104
+{
+ static int TestOutOfBoundProxy(Func<int> actualTest)
+ {
+ try
+ {
+ actualTest();
+ }
+ catch (IndexOutOfRangeException)
+ {
+ Console.WriteLine("caught IndexOutOfRangeException");
+ return 100;
+ }
+ Debug.Fail("unreached");
+ return 101;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int TestOutOfBoundLowerDecreasing()
+ {
+ int[] arr = new int[10];
+ int i = 9;
+ int j = 15;
+ int sum = 0;
+
+ // our range check optimizer is very naive, so if you don't have
+ // i < 10, then it thinks `i` can overflow and doesn't bother
+ // calling `Widen` at all.
+ //
+ while (j >= 0 && i < 10)
+ {
+ --j;
+ --i;
+ sum += arr[i]; // range check will use 9 as lower bound.
+
+ Console.WriteLine("i = " + i + ", j = " + j);
+ }
+ return sum;
+ }
+
+ public static int Main()
+ {
+ try
+ {
+ TestOutOfBoundProxy(TestOutOfBoundLowerDecreasing);
+ }
+ catch (Exception)
+ {
+ return 101;
+ }
+
+ return 100;
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/Runtime_1104/Runtime_1104.csproj b/tests/src/JIT/Regression/JitBlue/Runtime_1104/Runtime_1104.csproj
new file mode 100644
index 0000000000..95052d9884
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/Runtime_1104/Runtime_1104.csproj
@@ -0,0 +1,33 @@
+<?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>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>