diff options
author | Eugene Rozenfeld <erozen@microsoft.com> | 2019-05-09 17:16:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-09 17:16:10 -0700 |
commit | c6d9f0cc72c355475e404bb70986be0a4c8ad114 (patch) | |
tree | 3dfff51cd2f3db957e176fd436f715eb17d0dcab /tests/src/JIT | |
parent | a086fa2466d601fed6d2f4fb029b78613bf4ec7a (diff) | |
parent | 993b7c5d4c002ff2f9f11b4ac3176baf72ec1b77 (diff) | |
download | coreclr-c6d9f0cc72c355475e404bb70986be0a4c8ad114.tar.gz coreclr-c6d9f0cc72c355475e404bb70986be0a4c8ad114.tar.bz2 coreclr-c6d9f0cc72c355475e404bb70986be0a4c8ad114.zip |
Merge pull request #24482 from erozenfeld/Fix24159
Mark local struct as having overlapping fields after struct reinterpretation
Diffstat (limited to 'tests/src/JIT')
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_24159/GitHub_24159.cs | 61 | ||||
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_24159/GitHub_24159.csproj | 17 |
2 files changed, 78 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24159/GitHub_24159.cs b/tests/src/JIT/Regression/JitBlue/GitHub_24159/GitHub_24159.cs new file mode 100644 index 0000000000..8017ca5e0c --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_24159/GitHub_24159.cs @@ -0,0 +1,61 @@ +// 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.CompilerServices; + +namespace GitHub_24159 +{ + + public struct Str1 + { + public int i1; + public int i2; + public int i3; + public int i4; + public int i5; + } + + public struct Str2 + { + public int j1; + public int j2; + public int j3; + public int j4; + public int j5; + } + + class Test + { + static int i; + + public static int Main() + { + i = 0; + + Str1 str1 = new Str1(); + + if (i != 0) + { + str1 = new Str1(); + } + else + { + str1.i2 = 7; + } + + // This call reinterprets the struct. + Str2 str2 = Unsafe.As<Str1, Str2>(ref str1); + + // The bug was that value numbering couldn't recognize + // that this field has been updated on str1. + int k = str2.j2; + + Console.WriteLine(k); + + return k + 93; + + } + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24159/GitHub_24159.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_24159/GitHub_24159.csproj new file mode 100644 index 0000000000..d86ed9f3d7 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_24159/GitHub_24159.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 |