summaryrefslogtreecommitdiff
path: root/tests/src/jit
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2017-11-01 15:17:40 -0700
committerGitHub <noreply@github.com>2017-11-01 15:17:40 -0700
commit0ea9d2e189ea1b4f069204d3f57645067ceb0d38 (patch)
treed9074b7b49560d5a9fe8fcae606fb0e19563d731 /tests/src/jit
parentc80085a9271d5bc234cafeb14e89fdade3de4247 (diff)
downloadcoreclr-0ea9d2e189ea1b4f069204d3f57645067ceb0d38.tar.gz
coreclr-0ea9d2e189ea1b4f069204d3f57645067ceb0d38.tar.bz2
coreclr-0ea9d2e189ea1b4f069204d3f57645067ceb0d38.zip
JIT: convert fixed-sized locallocs to locals, enable inlining (#14623)
Optimize fixed sized locallocs of 32 bytes or less to use local buffers, if the localloc is not in a loop. Also "optimize" the degenerate 0 byte case. Allow inline candidates containing localloc, but fail inlining if any of a candidate's locallocs do not convert to local buffers. The 32 byte size threshold was arrived at empirically; larger values did not enable many more cases and started seeinge size bloat because of larger stack offsets. We can revise this threshold if we are willing to reorder locals and see fixed sized cases larger than 32 bytes. Closes #8542. Also add missing handler for the callsite is in try region, this was an oversight.
Diffstat (limited to 'tests/src/jit')
-rw-r--r--tests/src/jit/opt/LocAlloc/inloop.cs43
-rw-r--r--tests/src/jit/opt/LocAlloc/inloop.csproj40
2 files changed, 83 insertions, 0 deletions
diff --git a/tests/src/jit/opt/LocAlloc/inloop.cs b/tests/src/jit/opt/LocAlloc/inloop.cs
new file mode 100644
index 0000000000..777b34e90a
--- /dev/null
+++ b/tests/src/jit/opt/LocAlloc/inloop.cs
@@ -0,0 +1,43 @@
+// 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.
+
+// ensure localloc in a loop is not converted
+// to local buffer
+
+using System;
+
+unsafe class Program
+{
+ struct Element
+ {
+ public Element* Next;
+ public int Value;
+ }
+
+ static int foo(int n)
+ {
+ Element* root = null;
+ for (int i = 0; i < n; i++)
+ {
+ byte* pb = stackalloc byte[16];
+ Element* p = (Element*)pb;
+ p->Value = i;
+ p->Next = root;
+ root = p;
+ }
+
+ int sum = 0;
+ while (root != null)
+ {
+ sum += root->Value;
+ root = root->Next;
+ }
+ return sum;
+ }
+
+ static int Main(string[] args)
+ {
+ return foo(10) + 55;
+ }
+}
diff --git a/tests/src/jit/opt/LocAlloc/inloop.csproj b/tests/src/jit/opt/LocAlloc/inloop.csproj
new file mode 100644
index 0000000000..bfc7fa4d88
--- /dev/null
+++ b/tests/src/jit/opt/LocAlloc/inloop.csproj
@@ -0,0 +1,40 @@
+<?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-E94EE1F7140D}</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 .0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <CLRTestPriority>0</CLRTestPriority>
+ </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>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="inloop.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