summaryrefslogtreecommitdiff
path: root/tests/src/JIT
diff options
context:
space:
mode:
authorBrian Sullivan <briansul@microsoft.com>2018-11-05 18:26:10 -0800
committerBrian Sullivan <briansul@microsoft.com>2018-11-08 10:58:00 -0800
commita35f0620007ca6f8f6c0223b7f6e0d7573a40121 (patch)
tree92a3896d188f84b4d9427417be55f026dceed8e4 /tests/src/JIT
parent624767281d5dfa75c82a72d56c348cc53db844b4 (diff)
downloadcoreclr-a35f0620007ca6f8f6c0223b7f6e0d7573a40121.tar.gz
coreclr-a35f0620007ca6f8f6c0223b7f6e0d7573a40121.tar.bz2
coreclr-a35f0620007ca6f8f6c0223b7f6e0d7573a40121.zip
Fixes issue 18259
The problem here was that we have an indirection of a LclVar that was a pointer to an array element whose type is a struct. The following discussion refers to the test case GitHub_18259/GitHub_18259.cs We recorded that the struct field F1.F0 is assigned 1234u. With the bug all subsequent reads of vr7.F0 return this value. We miss the update to zero because we didn't add the Zero Field sequence value to the LclVar vr7 Added Test case GitHub_18259.cs Added Test case GitHub_20838.cs
Diffstat (limited to 'tests/src/JIT')
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_18259/GitHub_18259.cs49
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_18259/GitHub_18259.csproj17
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_20838/GitHub_20838.cs628
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_20838/GitHub_20838.csproj17
4 files changed, 711 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18259/GitHub_18259.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18259/GitHub_18259.cs
new file mode 100644
index 0000000000..86aa938117
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_18259/GitHub_18259.cs
@@ -0,0 +1,49 @@
+// 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;
+
+// Test case for issue 18259
+//
+// We were a missing check for ZeroOffsetFldSeq values on LclVar reads
+//
+// Debug: Outputs 0
+// Release: Outputs 1234
+
+struct S1
+{
+ public uint F0;
+ public S1(uint f0): this() { F0 = f0; }
+}
+
+struct S2
+{
+ public S1 F1;
+ public int F2;
+ public S2(S1 f1): this() { F1 = f1; F2 = 1; }
+}
+
+public class Program
+{
+ static S2[] s_11 = new S2[]{new S2(new S1(1234u))}; // Assigns 1234 to F1.F0
+ public static int Main()
+ {
+ ref S1 vr7 = ref s_11[0].F1;
+ vr7.F0 = vr7.F0;
+
+ vr7.F0 = 0; // Bug: We fail to update the Map with the proper ValueNum here.
+
+ if (vr7.F0 != 0) // Bug: We continue to return the old value for vr7.F0
+ {
+ System.Console.WriteLine(vr7.F0);
+ System.Console.WriteLine("Failed");
+ return 101;
+ }
+ else
+ {
+ System.Console.WriteLine("Passed");
+ return 100;
+ }
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18259/GitHub_18259.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18259/GitHub_18259.csproj
new file mode 100644
index 0000000000..d86ed9f3d7
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_18259/GitHub_18259.csproj
@@ -0,0 +1,17 @@
+<?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)' == '' ">Release</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <OutputType>Exe</OutputType>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_20838/GitHub_20838.cs b/tests/src/JIT/Regression/JitBlue/GitHub_20838/GitHub_20838.cs
new file mode 100644
index 0000000000..2b0f4cb66f
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_20838/GitHub_20838.cs
@@ -0,0 +1,628 @@
+// 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;
+
+// Test case for fix 20838
+// We are a missing check for ZeroOffsetFldSeq values on LclVar reads
+// without the fix several cases in this test fail because value numbering
+// gives us the old value instead of the modified value.
+//
+// CoreRun.exe GitHub_18259.exe
+// Failed - Test_e0_S2_F3_F1() - 640 -- 512 + 128
+// Failed - Test_e0_S2_F4_F1() - 960 -- 512 + 256 + 128 + 64
+// Failed - Test_e1_S2_F3_F1() - 640
+// Failed - Test_e1_S2_F4_F1() - 960
+
+struct S1
+{
+ public int F1;
+ public int F2;
+
+ public S1(int a1, int a2) { F1 = a1; F2 = a2; }
+}
+
+struct S2
+{
+ public S1 F3;
+ public S1 F4;
+
+ public S2(S1 a1, S1 a2) { F3 = a1; F4 = a2; }
+}
+
+public class Program
+{
+
+ static S1 ss_S1a = new S1(101, 102);
+ static S1 ss_S1b = new S1(103, 104);
+ static S1 ss_S1c = new S1(105, 106);
+ static S1 ss_S1d = new S1(107, 108);
+ static S2 ss_S2a = new S2(ss_S1a, ss_S1b);
+ static S2 ss_S2b = new S2(ss_S1c, ss_S1d);
+ static S2[] sa_S2 = new S2[] { ss_S2a, ss_S2b };
+
+ static bool Test_e0_S2_F3_F1()
+ {
+ ref S2 ref_e0_S2 = ref sa_S2[0];
+ ref S1 ref_e0_S2_F3 = ref sa_S2[0].F3;
+ ref int ref_e0_S2_F3_F1 = ref sa_S2[0].F3.F1;
+
+ int result = 0;
+
+ if (sa_S2[0].F3.F1 != 101)
+ {
+ result |= 1;
+ }
+
+ if (ref_e0_S2_F3_F1 != 101)
+ {
+ result |= 2;
+ }
+
+ if (ref_e0_S2_F3.F1 != 101)
+ {
+ result |= 4;
+ }
+
+ if (ref_e0_S2.F3.F1 != 101)
+ {
+ result |= 8;
+ }
+
+ if (ref_e0_S2_F3.F1 != 101)
+ {
+ result |= 16;
+ }
+
+ ref_e0_S2_F3.F1 = 99;
+
+ if (sa_S2[0].F3.F1 != 99)
+ {
+ result |= 32;
+ }
+
+ if (ref_e0_S2_F3_F1 != 99)
+ {
+ result |= 64;
+ }
+
+ if (ref_e0_S2_F3.F1 != 99)
+ {
+ result |= 128;
+ }
+
+ if (ref_e0_S2.F3.F1 != 99)
+ {
+ result |= 256;
+ }
+
+ if (ref_e0_S2_F3.F1 != 99)
+ {
+ result |= 512;
+ }
+
+ if (result != 0)
+ {
+ Console.WriteLine("Failed - Test_e0_S2_F3_F1() - " + result);
+ return false;
+ }
+
+ return true;
+ }
+
+ static bool Test_e0_S2_F3_F2()
+ {
+ ref S2 ref_e0_S2 = ref sa_S2[0];
+ ref S1 ref_e0_S2_F3 = ref sa_S2[0].F3;
+ ref int ref_e0_S2_F3_F2 = ref sa_S2[0].F3.F2;
+
+ int result = 0;
+
+ if (sa_S2[0].F3.F2 != 102)
+ {
+ result |= 1;
+ }
+
+ if (ref_e0_S2_F3_F2 != 102)
+ {
+ result |= 2;
+ }
+
+ if (ref_e0_S2_F3.F2 != 102)
+ {
+ result |= 4;
+ }
+
+ if (ref_e0_S2.F3.F2 != 102)
+ {
+ result |= 8;
+ }
+
+ if (ref_e0_S2_F3.F2 != 102)
+ {
+ result |= 16;
+ }
+
+ ref_e0_S2_F3.F2 = 98;
+
+ if (sa_S2[0].F3.F2 != 98)
+ {
+ result |= 32;
+ }
+
+ if (ref_e0_S2_F3_F2 != 98)
+ {
+ result |= 64;
+ }
+
+ if (ref_e0_S2_F3.F2 != 98)
+ {
+ result |= 128;
+ }
+
+ if (ref_e0_S2.F3.F2 != 98)
+ {
+ result |= 256;
+ }
+
+ if (ref_e0_S2_F3.F2 != 98)
+ {
+ result |= 512;
+ }
+
+ if (result != 0)
+ {
+ Console.WriteLine("Failed - Test_e0_S2_F3_F2() - " + result);
+ return false;
+ }
+
+ return true;
+ }
+
+ static bool Test_e0_S2_F4_F1()
+ {
+ ref S2 ref_e0_S2 = ref sa_S2[0];
+ ref S1 ref_e0_S2_F4 = ref sa_S2[0].F4;
+ ref int ref_e0_S2_F4_F1 = ref sa_S2[0].F4.F1;
+
+ int result = 0;
+
+ if (sa_S2[0].F4.F1 != 103)
+ {
+ result |= 1;
+ }
+
+ if (ref_e0_S2_F4_F1 != 103)
+ {
+ result |= 2;
+ }
+
+ if (ref_e0_S2_F4.F1 != 103)
+ {
+ result |= 4;
+ }
+
+ if (ref_e0_S2.F4.F1 != 103)
+ {
+ result |= 8;
+ }
+
+ if (ref_e0_S2_F4.F1 != 103)
+ {
+ result |= 16;
+ }
+
+ ref_e0_S2_F4.F1 = 97;
+
+ if (sa_S2[0].F4.F1 != 97)
+ {
+ result |= 32;
+ }
+
+ if (ref_e0_S2_F4_F1 != 97)
+ {
+ result |= 64;
+ }
+
+ if (ref_e0_S2_F4.F1 != 97)
+ {
+ result |= 128;
+ }
+
+ if (ref_e0_S2.F4.F1 != 97)
+ {
+ result |= 256;
+ }
+
+ if (ref_e0_S2_F4.F1 != 97)
+ {
+ result |= 512;
+ }
+
+ if (result != 0)
+ {
+ Console.WriteLine("Failed - Test_e0_S2_F4_F1() - " + result);
+ return false;
+ }
+
+ return true;
+ }
+
+ static bool Test_e0_S2_F4_F2()
+ {
+ ref S2 ref_e0_S2 = ref sa_S2[0];
+ ref S1 ref_e0_S2_F4 = ref sa_S2[0].F4;
+ ref int ref_e0_S2_F4_F2 = ref sa_S2[0].F4.F2;
+
+ int result = 0;
+
+ if (sa_S2[0].F4.F2 != 104)
+ {
+ result |= 1;
+ }
+
+ if (ref_e0_S2_F4_F2 != 104)
+ {
+ result |= 2;
+ }
+
+ if (ref_e0_S2_F4.F2 != 104)
+ {
+ result |= 4;
+ }
+
+ if (ref_e0_S2.F4.F2 != 104)
+ {
+ result |= 8;
+ }
+
+ if (ref_e0_S2_F4.F2 != 104)
+ {
+ result |= 16;
+ }
+
+ ref_e0_S2_F4.F2 = 96;
+
+ if (sa_S2[0].F4.F2 != 96)
+ {
+ result |= 32;
+ }
+
+ if (ref_e0_S2_F4_F2 != 96)
+ {
+ result |= 64;
+ }
+
+ if (ref_e0_S2_F4.F2 != 96)
+ {
+ result |= 128;
+ }
+
+ if (ref_e0_S2.F4.F2 != 96)
+ {
+ result |= 256;
+ }
+
+ if (ref_e0_S2_F4.F2 != 96)
+ {
+ result |= 512;
+ }
+
+ if (result != 0)
+ {
+ Console.WriteLine("Failed - Test_e0_S2_F4_F2() - " + result);
+ return false;
+ }
+
+ return true;
+ }
+
+ static bool Test_e1_S2_F3_F1()
+ {
+ ref S2 ref_e1_S2 = ref sa_S2[1];
+ ref S1 ref_e1_S2_F3 = ref sa_S2[1].F3;
+ ref int ref_e1_S2_F3_F1 = ref sa_S2[1].F3.F1;
+
+ int result = 0;
+
+ if (sa_S2[1].F3.F1 != 105)
+ {
+ result |= 1;
+ }
+
+ if (ref_e1_S2_F3_F1 != 105)
+ {
+ result |= 2;
+ }
+
+ if (ref_e1_S2_F3.F1 != 105)
+ {
+ result |= 4;
+ }
+
+ if (ref_e1_S2.F3.F1 != 105)
+ {
+ result |= 8;
+ }
+
+ if (ref_e1_S2_F3.F1 != 105)
+ {
+ result |= 16;
+ }
+
+ ref_e1_S2_F3.F1 = 95;
+
+ if (sa_S2[1].F3.F1 != 95)
+ {
+ result |= 32;
+ }
+
+ if (ref_e1_S2_F3_F1 != 95)
+ {
+ result |= 64;
+ }
+
+ if (ref_e1_S2_F3.F1 != 95)
+ {
+ result |= 128;
+ }
+
+ if (ref_e1_S2.F3.F1 != 95)
+ {
+ result |= 256;
+ }
+
+ if (ref_e1_S2_F3.F1 != 95)
+ {
+ result |= 512;
+ }
+
+ if (result != 0)
+ {
+ Console.WriteLine("Failed - Test_e1_S2_F3_F1() - " + result);
+ return false;
+ }
+
+ return true;
+ }
+
+ static bool Test_e1_S2_F3_F2()
+ {
+ ref S2 ref_e1_S2 = ref sa_S2[1];
+ ref S1 ref_e1_S2_F3 = ref sa_S2[1].F3;
+ ref int ref_e1_S2_F3_F2 = ref sa_S2[1].F3.F2;
+
+ int result = 0;
+
+ if (sa_S2[1].F3.F2 != 106)
+ {
+ result |= 1;
+ }
+
+ if (ref_e1_S2_F3_F2 != 106)
+ {
+ result |= 2;
+ }
+
+ if (ref_e1_S2_F3.F2 != 106)
+ {
+ result |= 4;
+ }
+
+ if (ref_e1_S2.F3.F2 != 106)
+ {
+ result |= 8;
+ }
+
+ if (ref_e1_S2_F3.F2 != 106)
+ {
+ result |= 16;
+ }
+
+ ref_e1_S2_F3.F2 = 94;
+
+ if (sa_S2[1].F3.F2 != 94)
+ {
+ result |= 32;
+ }
+
+ if (ref_e1_S2_F3_F2 != 94)
+ {
+ result |= 64;
+ }
+
+ if (ref_e1_S2_F3.F2 != 94)
+ {
+ result |= 128;
+ }
+
+ if (ref_e1_S2.F3.F2 != 94)
+ {
+ result |= 256;
+ }
+
+ if (ref_e1_S2_F3.F2 != 94)
+ {
+ result |= 512;
+ }
+
+ if (result != 0)
+ {
+ Console.WriteLine("Failed - Test_e1_S2_F3_F2() - " + result);
+ return false;
+ }
+
+ return true;
+ }
+
+ static bool Test_e1_S2_F4_F1()
+ {
+ ref S2 ref_e1_S2 = ref sa_S2[1];
+ ref S1 ref_e1_S2_F4 = ref sa_S2[1].F4;
+ ref int ref_e1_S2_F4_F1 = ref sa_S2[1].F4.F1;
+
+ int result = 0;
+
+ if (sa_S2[1].F4.F1 != 107)
+ {
+ result |= 1;
+ }
+
+ if (ref_e1_S2_F4_F1 != 107)
+ {
+ result |= 2;
+ }
+
+ if (ref_e1_S2_F4.F1 != 107)
+ {
+ result |= 4;
+ }
+
+ if (ref_e1_S2.F4.F1 != 107)
+ {
+ result |= 8;
+ }
+
+ if (ref_e1_S2_F4.F1 != 107)
+ {
+ result |= 16;
+ }
+
+ ref_e1_S2_F4.F1 = 93;
+
+ if (sa_S2[1].F4.F1 != 93)
+ {
+ result |= 32;
+ }
+
+ if (ref_e1_S2_F4_F1 != 93)
+ {
+ result |= 64;
+ }
+
+ if (ref_e1_S2_F4.F1 != 93)
+ {
+ result |= 128;
+ }
+
+ if (ref_e1_S2.F4.F1 != 93)
+ {
+ result |= 256;
+ }
+
+ if (ref_e1_S2_F4.F1 != 93)
+ {
+ result |= 512;
+ }
+
+ if (result != 0)
+ {
+ Console.WriteLine("Failed - Test_e1_S2_F4_F1() - " + result);
+ return false;
+ }
+
+ return true;
+ }
+
+ static bool Test_e1_S2_F4_F2()
+ {
+ ref S2 ref_e1_S2 = ref sa_S2[1];
+ ref S1 ref_e1_S2_F4 = ref sa_S2[1].F4;
+ ref int ref_e1_S2_F4_F2 = ref sa_S2[1].F4.F2;
+
+ int result = 0;
+
+ if (sa_S2[1].F4.F2 != 108)
+ {
+ result |= 1;
+ }
+
+ if (ref_e1_S2_F4_F2 != 108)
+ {
+ result |= 2;
+ }
+
+ if (ref_e1_S2_F4.F2 != 108)
+ {
+ result |= 4;
+ }
+
+ if (ref_e1_S2.F4.F2 != 108)
+ {
+ result |= 8;
+ }
+
+ if (ref_e1_S2_F4.F2 != 108)
+ {
+ result |= 16;
+ }
+
+ ref_e1_S2_F4.F2 = 92;
+
+ if (sa_S2[1].F4.F2 != 92)
+ {
+ result |= 32;
+ }
+
+ if (ref_e1_S2_F4_F2 != 92)
+ {
+ result |= 64;
+ }
+
+ if (ref_e1_S2_F4.F2 != 92)
+ {
+ result |= 128;
+ }
+
+ if (ref_e1_S2.F4.F2 != 92)
+ {
+ result |= 256;
+ }
+
+ if (ref_e1_S2_F4.F2 != 92)
+ {
+ result |= 512;
+ }
+
+ if (result != 0)
+ {
+ Console.WriteLine("Failed - Test_e1_S2_F4_F2() - " + result);
+ return false;
+ }
+
+ return true;
+ }
+
+ public static int Main()
+ {
+ bool isPassing = true;
+
+ isPassing &= Test_e0_S2_F3_F1();
+
+ isPassing &= Test_e0_S2_F3_F2();
+
+ isPassing &= Test_e0_S2_F4_F1();
+
+ isPassing &= Test_e0_S2_F4_F2();
+
+ isPassing &= Test_e1_S2_F3_F1();
+
+ isPassing &= Test_e1_S2_F3_F2();
+
+ isPassing &= Test_e1_S2_F4_F1();
+
+ isPassing &= Test_e1_S2_F4_F2();
+
+ if (isPassing)
+ {
+ Console.WriteLine("Passed");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("Failed");
+ return 101;
+ }
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_20838/GitHub_20838.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_20838/GitHub_20838.csproj
new file mode 100644
index 0000000000..d86ed9f3d7
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_20838/GitHub_20838.csproj
@@ -0,0 +1,17 @@
+<?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)' == '' ">Release</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <OutputType>Exe</OutputType>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project> \ No newline at end of file