diff options
author | Eugene Rozenfeld <erozen@microsoft.com> | 2018-09-07 10:48:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-07 10:48:06 -0700 |
commit | 36449cf94237e7cddb7e43a9fe6f873e7f5ebf77 (patch) | |
tree | 5659b57fff5ebdab2dfeba510a8f1a1a64c3d69d /tests/src | |
parent | c96aff7670f7d70fe87d2ea60bba9534c5e56088 (diff) | |
download | coreclr-36449cf94237e7cddb7e43a9fe6f873e7f5ebf77.tar.gz coreclr-36449cf94237e7cddb7e43a9fe6f873e7f5ebf77.tar.bz2 coreclr-36449cf94237e7cddb7e43a9fe6f873e7f5ebf77.zip |
Fix for bug 12398: Lowering is inconsistent in checking safety of RegOptional. (#19740)
This fixes an inconsistency in lowering where it fails to make an
operand contained because IsSafeToContainMem() returns false yet
it marks it regOptional, which may cause a problem if the operand
will be loaded at the point of use.
I also fixed a case where an operand was marked RegOptional even though
there is a type size mismatch.
There are 7 places that are affected, I added repro cases for 4 of them.
I wasn't able to construct repros for the 3 places that deal with
floating point operands but decided to fix those places anyway.
Fixes #12398.
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_12398/Github_12398.cs | 84 | ||||
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_12398/Github_12398.csproj | 34 |
2 files changed, 118 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_12398/Github_12398.cs b/tests/src/JIT/Regression/JitBlue/GitHub_12398/Github_12398.cs new file mode 100644 index 0000000000..69057f33a3 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_12398/Github_12398.cs @@ -0,0 +1,84 @@ +// 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. +// +// GitHub12398: Lowering is inconsistent in checking safety of RegOptional. + +using System; +using System.Runtime.CompilerServices; + +struct S0 +{ + public sbyte F1; + public sbyte F2; +} + +class GitHub_12398 +{ + static int Main() + { + int result = 100; + if (TestBinary() != 0) { + Console.WriteLine("Failed TestBinary"); + result = -1; + } + + if (TestCompare()) { + Console.WriteLine("Failed TestCompare"); + result = -1; + } + + if (TestMul() != 1) { + Console.WriteLine("Failed TestMul"); + result = -1; + } + + if (TestMulTypeSize() != 0) { + Console.WriteLine ("Failed TestMulTypeSize"); + result = -1; + } + + if (result == 100) { + Console.WriteLine("PASSED"); + } + else { + Console.WriteLine("FAILED"); + } + + return result; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static long TestBinary() + { + long l = 0; + long result = l ^ System.Threading.Interlocked.Exchange(ref l, 1); + return result; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static bool TestCompare() + { + long l = 0; + bool result = l > System.Threading.Interlocked.Exchange(ref l, 1); + return result; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static long TestMul() + { + long l = 1; + long result = l * System.Threading.Interlocked.Exchange(ref l, 0); + return result; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static int TestMulTypeSize() + { + S0 s = new S0(); + s.F2--; + int i = System.Threading.Volatile.Read(ref s.F1) * 100; + return i; + } +} + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_12398/Github_12398.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_12398/Github_12398.csproj new file mode 100644 index 0000000000..67d0b29edb --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_12398/Github_12398.csproj @@ -0,0 +1,34 @@ +<?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>{ADEEA3D1-B67B-456E-8F2B-6DCCACC2D34C}</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> + </PropertyGroup> + <ItemGroup> + <Compile Include="$(MSBuildProjectName).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> |