Reset lvIsStructField when removing promoted struct vars (#15721)
authormikedn <onemihaid@hotmail.com>
Thu, 4 Jan 2018 23:40:59 +0000 (01:40 +0200)
committerAndy Ayers <andya@microsoft.com>
Thu, 4 Jan 2018 23:40:59 +0000 (15:40 -0800)
src/jit/regalloc.cpp
tests/src/JIT/Regression/JitBlue/GitHub_15718/GitHub_15718.cs [new file with mode: 0644]
tests/src/JIT/Regression/JitBlue/GitHub_15718/GitHub_15718.csproj [new file with mode: 0644]

index 7277b52..ad06ee1 100644 (file)
@@ -841,6 +841,7 @@ void Compiler::raAssignVars()
                  varNum++)
             {
                 noway_assert(lvaTable[varNum].lvRefCnt == 0);
+                lvaTable[varNum].lvIsStructField = false;
             }
         }
         else
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_15718/GitHub_15718.cs b/tests/src/JIT/Regression/JitBlue/GitHub_15718/GitHub_15718.cs
new file mode 100644 (file)
index 0000000..fdcf12f
--- /dev/null
@@ -0,0 +1,22 @@
+// 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.Collections.Generic;
+using System.Runtime.CompilerServices;
+
+class Program
+{
+    static int Main()
+    {
+        var map = new Dictionary<string, bool?> { { "foo", true } };
+        return (Test(map) == true) ? 100 : 1;
+    }
+
+    [MethodImpl(MethodImplOptions.NoInlining)]
+    static bool? Test(Dictionary<string, bool?> map)
+    {
+        return map["foo"];
+    }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_15718/GitHub_15718.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_15718/GitHub_15718.csproj
new file mode 100644 (file)
index 0000000..d0f6174
--- /dev/null
@@ -0,0 +1,31 @@
+<?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>
+    <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+  <PropertyGroup>
+    <DebugType></DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="GitHub_15718.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>