diff options
author | Carol Eidt <carol.eidt@microsoft.com> | 2018-05-15 13:57:09 -0700 |
---|---|---|
committer | Carol Eidt <carol.eidt@microsoft.com> | 2018-05-15 13:57:09 -0700 |
commit | a7f129cce3ee1ccbc119d771ae517f7e4f18b782 (patch) | |
tree | 4a7d91b5542b8fa5892587598f4327a8f79eebeb /tests/src/JIT/Regression/JitBlue/GitHub_5556 | |
parent | cc0e7b49019d5d08aebd8cfa714d9864f2d65a8e (diff) | |
download | coreclr-a7f129cce3ee1ccbc119d771ae517f7e4f18b782.tar.gz coreclr-a7f129cce3ee1ccbc119d771ae517f7e4f18b782.tar.bz2 coreclr-a7f129cce3ee1ccbc119d771ae517f7e4f18b782.zip |
Add tests for struct-related issues
Diffstat (limited to 'tests/src/JIT/Regression/JitBlue/GitHub_5556')
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_5556/GitHub_5556.cs | 52 | ||||
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_5556/GitHub_5556.csproj | 38 |
2 files changed, 90 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_5556/GitHub_5556.cs b/tests/src/JIT/Regression/JitBlue/GitHub_5556/GitHub_5556.cs new file mode 100644 index 0000000000..3cfea7642f --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_5556/GitHub_5556.cs @@ -0,0 +1,52 @@ +// 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. + +// This test has two effectively identical methods, one of which copies +// its input paramter to a local, allowing it to be promoted. +// The JIT should be able to generate identical code for these. + +using System; +using System.Runtime.CompilerServices; + +class GitHub_5556 +{ + [MethodImpl(MethodImplOptions.NoInlining)] + public static long SpanAsParam(Span<long> span) + { + long value = 0; + for (int i = 0; i < span.Length; i++) + { + value = span[i]; + } + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static long SpanWithLocalCopy(Span<long> span) + { + var spanLocal = span; + long value = 0; + for (int i = 0; i < spanLocal.Length; i++) + { + value = spanLocal[i]; + } + return value; + } + + static int Main() + { + long[] a = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + Span<long> mySpan = new Span<long>(a); + int returnVal = 100; + if (SpanAsParam(mySpan) != 9) + { + returnVal = -1; + } + if (SpanWithLocalCopy(mySpan) != 9) + { + returnVal = -1; + } + return returnVal; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_5556/GitHub_5556.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_5556/GitHub_5556.csproj new file mode 100644 index 0000000000..5bd417ae6c --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_5556/GitHub_5556.csproj @@ -0,0 +1,38 @@ +<?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>{95DFC527-4DC1-495E-97D7-B8089FFA8D79}</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> + </PropertyGroup> + <ItemGroup> + <Compile Include="$(MSBuildProjectName).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>
\ No newline at end of file |