summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorCarol Eidt <carol.eidt@microsoft.com>2018-07-16 11:37:40 -0700
committerCarol Eidt <carol.eidt@microsoft.com>2018-07-17 08:57:02 -0700
commitf48801ea7c1412e228a5230ec6cbeabdf5277ec0 (patch)
treeda485d0e0aa9196da1ffa4eef2a1a7b8d89dff9b /tests/src
parentd25bcb8e27c5e583d6abfe6d59d3f32316ac7733 (diff)
downloadcoreclr-f48801ea7c1412e228a5230ec6cbeabdf5277ec0.tar.gz
coreclr-f48801ea7c1412e228a5230ec6cbeabdf5277ec0.tar.bz2
coreclr-f48801ea7c1412e228a5230ec6cbeabdf5277ec0.zip
Kill RCX when used by shift
RCX must be explicitly killed. Otherwise, if there's a case of a def/use conflict - as in this test case where the shift amount is defined by a divide that must go in RAX, it won't be explicitly assigned to RCX,. Also, the handling of conflicts must not use the register assignment of the def on the use if it conflicts with the use register requirements, and vice versa. Fix #18884
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.cs82
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.csproj45
2 files changed, 127 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.cs
new file mode 100644
index 0000000000..1cd9085bbe
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.cs
@@ -0,0 +1,82 @@
+// 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.
+
+// This bug had to do with the handling (reserving and killing) of RCX
+// for variable shift operations on X64.
+
+using System;
+using System.Collections.Specialized;
+using System.Runtime.CompilerServices;
+
+static class GitHub_18884
+{
+ static ushort s_3;
+ static long s_5;
+ static int returnVal = 100;
+
+ public static int Main()
+ {
+ s_3 = 0; // avoid runtime checks in M15
+ ReproWindows(0, 0, 1, 0);
+ ReproUx(0, 0, 1, 0);
+ Set_Mask_AllTest();
+ return returnVal;
+ }
+
+ static void ReproWindows(byte arg0, long arg1, ushort arg2, ulong arg3)
+ {
+ s_5 >>= 50 / arg2; // the value shifted by here
+ if (arg0 != 0)
+ {
+ s_3 = s_3;
+ }
+
+ // Is in arg0 here
+ if (arg0 != 0)
+ {
+ Console.WriteLine("FAIL: ReproWindows");
+ returnVal = -1;
+ }
+ }
+ static void ReproUx(ulong arg0, long arg1, ushort arg2, byte arg3)
+ {
+ s_5 >>= 50 / arg2; // the value shifted by here
+ if (arg3 != 0)
+ {
+ s_3 = s_3;
+ }
+
+ // Is in arg3 here
+ if (arg3 != 0)
+ {
+ Console.WriteLine("FAIL: ReproUx");
+ returnVal = -1;
+ }
+ }
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void CheckValue(int value, int expectedValue)
+ {
+ if (value != expectedValue)
+ {
+ returnVal = -1;
+ Console.WriteLine("FAIL: Set_Mask_AllTest");
+ }
+ }
+
+ // While fixing the above failures, this test (from corefx) failed.
+ public static void Set_Mask_AllTest()
+ {
+ BitVector32 flip = new BitVector32();
+ int mask = 0;
+ for (int bit = 1; bit < 32 + 1; bit++)
+ {
+ mask = BitVector32.CreateMask(mask);
+ BitVector32 single = new BitVector32();
+ single[mask] = true;
+
+ // The bug was exposed by passing the result of a shift in RCX on x64/ux.
+ CheckValue(1 << (bit - 1), single.Data);
+ }
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.csproj
new file mode 100644
index 0000000000..ea8e8a7e42
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.csproj
@@ -0,0 +1,45 @@
+<?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>
+ <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' "></PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <PropertyGroup>
+ <CLRTestBatchPreCommands><![CDATA[
+$(CLRTestBatchPreCommands)
+set COMPlus_TailcallStress=1
+]]></CLRTestBatchPreCommands>
+ <BashCLRTestPreCommands><![CDATA[
+$(BashCLRTestPreCommands)
+export COMPlus_TailcallStress=1
+]]></BashCLRTestPreCommands>
+ </PropertyGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>