summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Andreenko <seandree@microsoft.com>2017-09-21 21:30:15 -0700
committerGitHub <noreply@github.com>2017-09-21 21:30:15 -0700
commit43cf34fe74b435427ffb62f54fc730b4b46c4c22 (patch)
tree804ee54b70eb40841e29a7f7e31eea3dd92745dd /tests
parent8c33e99150cfe9c173f524acff4ea7be320ce08c (diff)
downloadcoreclr-43cf34fe74b435427ffb62f54fc730b4b46c4c22.tar.gz
coreclr-43cf34fe74b435427ffb62f54fc730b4b46c4c22.tar.bz2
coreclr-43cf34fe74b435427ffb62f54fc730b4b46c4c22.zip
fix checkLclVarSemantics (#14053)
* extract CheckLclVarSemantics from CheckLIR. * add a test that shows the silent bad execution. * fix the checker. * add the test to the exclude list. * rename consumed to used
Diffstat (limited to 'tests')
-rw-r--r--tests/issues.targets3
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.cs120
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.csproj45
3 files changed, 168 insertions, 0 deletions
diff --git a/tests/issues.targets b/tests/issues.targets
index fce3f8aee7..af769509cd 100644
--- a/tests/issues.targets
+++ b/tests/issues.targets
@@ -184,6 +184,9 @@
<ExcludeList Include="$(XunitTestBinBase)\Loader\classloader\TypeGeneratorTests\TypeGeneratorTest683\Generated683\*">
<Issue>6707</Issue>
</ExcludeList>
+ <ExcludeList Include="$(XunitTestBinBase)\JIT\Regression\JitBlue\GitHub_13910\GitHub_13910\GitHub_13910.cmd">
+ <Issue>13910</Issue>
+ </ExcludeList>
</ItemGroup>
<!-- The following are x86 failures -->
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.cs b/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.cs
new file mode 100644
index 0000000000..d1805d1fa0
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.cs
@@ -0,0 +1,120 @@
+// 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.InteropServices;
+
+// Represents a problem with contained nodes chains, that contain lclVar reads, that were moved through lclVar stores.
+// Notice that the project file sets complus_JitStressModeNames.
+
+[StructLayout(LayoutKind.Explicit)]
+internal class AA
+{
+
+ [FieldOffset(8)]
+ public QQ q;
+
+
+ public static AA[] a_init = new AA[101];
+
+ public static AA[] a_zero = new AA[101];
+
+
+ public AA(int qq)
+ {
+
+ this.q = new QQ(qq);
+ }
+
+
+ public static void reset()
+ {
+ AA.a_init[100] = new AA(1);
+ AA.a_zero[100] = new AA(2);
+ }
+}
+
+internal class QQ
+{
+ public int val;
+
+ public QQ(int vv)
+ {
+ this.val = vv;
+ }
+
+ public int ret_code()
+ {
+ return 100;
+ }
+}
+
+internal class TestApp
+{
+
+ private static int test_2_2(int num)
+ {
+ int result;
+ if (AA.a_init[num].q != AA.a_zero[num].q)
+ // Access field with contained IND instruction.
+ // EQ marks its operands as contained too.
+ // AA.a_init[num].q and AA.a_zero[num].q are allocated to the same lclVar.
+ // So we calculate AA.a_init[num].q and store as tmp0, use this temp to do nullCheck.
+ // Then store AA.a_zero[num].q as tmp0, destroy the old value and try to do EQ thinking that
+ // tmp0 is AA.a_init[num].q.
+ // It needs stress (complus_JitStressModeNames=STRESS_NULL_OBJECT_CHECK, STRESS_MAKE_CSE)
+ // to force the compiler to do implicit null checks and store values as local variables.
+// Bad IL example, t53 is set as contained, t143 is set as contained, it means they will be calculated as part of their parent t9.
+// But at that moment V02, that is read in t143 is already modified by [000056].
+// N035 ( 1, 1) [000035] ------------ t35 = LCL_VAR ref V02 tmp0 u:3 eax (last use) REG eax <l:$149, c:$182>
+// /--* t35 ref
+// N037 (???,???) [000143] -c---------- t143 = * LEA(b+12) byref REG NA
+// /--* t143 byref
+// N039 ( 4, 4) [000054] Rc---O------ t54 = * IND ref REG NA <l:$155, c:$184> // This contained flag is invalid because
+// // the value will be read after the store 000056.
+// *********************************************************************************************
+// /--* t117 ref
+// N073 ( 18, 22) [000056] DA-XG------- * STORE_LCL_VAR ref V02 tmp0 d:4 eax REG eax // the store that corrupts t54 value.
+// N075 ( 1, 1) [000057] ------------ t57 = LCL_VAR ref V02 tmp0 u:4 eax REG eax <l:$160, c:$187>
+// /--* t57 ref
+// N077 ( 2, 2) [000058] ---X---N---- * NULLCHECK byte REG NA <l:$166, c:$165>
+// N079 ( 1, 1) [000060] ------------ t60 = LCL_VAR ref V02 tmp0 u:4 eax REG eax <l:$160, c:$187>
+// /--* t60 ref
+// N081 (???,???) [000146] -c---------- t146 = * LEA(b+12) byref REG NA
+// /--* t146 byref
+// N083 ( 4, 4) [000079] R----O------ t79 = * IND ref REG ecx <l:$16b, c:$189>
+// /--* t79 ref
+// N085 ( 4, 4) [000121] DA---O------ * STORE_LCL_VAR ref V07 cse1 ecx REG ecx
+// N087 ( 1, 1) [000122] ------------ t122 = LCL_VAR ref V07 cse1 ecx REG ecx <l:$16b, c:$189>
+// /--* t54 ref // reads V02.
+// +--* t122 ref
+// N089 ( 48, 56) [000009] J--XGO-N---- t9 = * EQ int REG NA <l:$1c5, c:$1c4>
+ {
+ result = 100;
+ }
+ else
+ {
+ result = AA.a_zero[num].q.val;
+ }
+ return result;
+ }
+
+ private static int Main()
+ {
+ AA.reset();
+ int result;
+
+ int r = TestApp.test_2_2(100);
+ if (r != 100)
+ {
+ Console.WriteLine("Failed.");
+ result = 101;
+ }
+ else
+ {
+ Console.WriteLine("Passed.");
+ result = 100;
+ }
+ return result;
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.csproj
new file mode 100644
index 0000000000..8cb39e1055
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13910/GitHub_13910.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>{E2C84853-0100-4C5D-88C0-355F70483779}</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>
+ <PropertyGroup>
+ <!-- Set JitStreess variables, Linux requires them to be properly capitalized. -->
+ <CLRTestBatchPreCommands><![CDATA[
+$(CLRTestBatchPreCommands)
+set COMPlus_JitStressModeNames=STRESS_NULL_OBJECT_CHECK, STRESS_MAKE_CSE
+]]></CLRTestBatchPreCommands>
+ <BashCLRTestPreCommands><![CDATA[
+$(BashCLRTestPreCommands)
+export COMPlus_JitStressModeNames=STRESS_NULL_OBJECT_CHECK, STRESS_MAKE_CSE
+]]></BashCLRTestPreCommands>
+ </PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project> \ No newline at end of file