summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorJoseph Tremoulet <jotrem@microsoft.com>2017-05-17 16:32:14 -0400
committerJoseph Tremoulet <jotrem@microsoft.com>2017-05-19 20:31:47 -0400
commit66e5e7f5c728e499f5a46c052842249662471dae (patch)
tree9633c74c98e734ee872d2158d8f95cacfed5d89b /tests/src
parenta96445ddc2c487b4adf79edd1d90a1646f2120dc (diff)
downloadcoreclr-66e5e7f5c728e499f5a46c052842249662471dae.tar.gz
coreclr-66e5e7f5c728e499f5a46c052842249662471dae.tar.bz2
coreclr-66e5e7f5c728e499f5a46c052842249662471dae.zip
Don't hoist IConHandle statics above cctors
These constants appear loop invariant, hence so do their dereferences when a loop has no memory side-effects. Add flag `GTF_ICON_INITCLASS` similar to `GTF_FLD_INITCLASS`/`GTF_CLS_VAR_INITCLASS`, and use it to prevent hoisting such references without also hoisting their static init helper calls. Resolves #11689
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_11689/GitHub_11689.cs39
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_11689/GitHub_11689.csproj53
2 files changed, 92 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_11689/GitHub_11689.cs b/tests/src/JIT/Regression/JitBlue/GitHub_11689/GitHub_11689.cs
new file mode 100644
index 0000000000..3d8428c928
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_11689/GitHub_11689.cs
@@ -0,0 +1,39 @@
+// 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.
+
+// Repro case for a bug involving hoisting of static field loads out of
+// loops and (illegally) above the corresponding type initializer calls.
+
+using System.Runtime.CompilerServices;
+
+namespace N
+{
+ struct WrappedInt
+ {
+ public int Value;
+
+ public static WrappedInt Twenty = new WrappedInt() { Value = 20 };
+ }
+ public static class C
+ {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static int unwrap(WrappedInt wi) => wi.Value;
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int foo(int s, int n)
+ {
+ for (int i = 0; i < n; ++i)
+ {
+ s += unwrap(WrappedInt.Twenty); // Loading WrappedInt.Twenty must happen after calling the cctor
+ }
+
+ return s;
+ }
+
+ public static int Main(string[] args)
+ {
+ return foo(20, 4);
+ }
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_11689/GitHub_11689.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_11689/GitHub_11689.csproj
new file mode 100644
index 0000000000..52f50228df
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_11689/GitHub_11689.csproj
@@ -0,0 +1,53 @@
+<?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>{A04B4F1F-62D3-4799-94AB-ABFB220415BE}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <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>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="GitHub_11689.cs" />
+ </ItemGroup>
+ <PropertyGroup>
+ <CLRTestBatchPreCommands><![CDATA[
+$(CLRTestBatchPreCommands)
+set COMPlus_TailcallStress=1
+]]></CLRTestBatchPreCommands>
+ <BashCLRTestPreCommands><![CDATA[
+$(BashCLRTestPreCommands)
+export COMPlus_TailcallStress=1
+]]></BashCLRTestPreCommands>
+ </PropertyGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>