diff options
-rw-r--r-- | src/jit/liveness.cpp | 54 | ||||
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/DevDiv_524312/DevDiv_524312.il | 74 | ||||
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/DevDiv_524312/DevDiv_524312.ilproj | 35 |
3 files changed, 162 insertions, 1 deletions
diff --git a/src/jit/liveness.cpp b/src/jit/liveness.cpp index 3f4d3a18ca..7f268a54b5 100644 --- a/src/jit/liveness.cpp +++ b/src/jit/liveness.cpp @@ -1977,6 +1977,45 @@ void Compiler::fgComputeLife(VARSET_TP& life, } } +static bool HasAnyThrowableNodes(Compiler* compiler, BasicBlock* block, jitstd::vector<GenTree*>& disabledNodes) +{ + + LIR::Range& blockRange = LIR::AsRange(block); + GenTree* currentNode = blockRange.LastNode(); + GenTree* endNode = blockRange.FirstNonPhiNode()->gtPrev; + + size_t left = disabledNodes.size(); + + while (currentNode != endNode) + { + for (size_t i = 0; i < disabledNodes.size(); ++i) + { + if (disabledNodes[i] == currentNode) + { + --left; + disabledNodes[i] = nullptr; + break; + } + } + + if (currentNode->OperMayThrow(compiler)) + { + return true; + } + + if (left == 0) + { + return false; + } + + currentNode = currentNode->gtPrev; + } + + // If we reach here that means that there is an affecting node outside the current block + // so return true + return true; +} + void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALARG_TP volatileVars) { // Don't kill volatile vars and vars in scope. @@ -2006,7 +2045,9 @@ void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALAR JITDUMP("Removing dead call:\n"); DISPNODE(call); - node->VisitOperands([](GenTree* operand) -> GenTree::VisitResult { + jitstd::vector<GenTree*> disabledNodes(getAllocator()); + + node->VisitOperands([&disabledNodes](GenTree* operand) -> GenTree::VisitResult { if (operand->IsValue()) { operand->SetUnusedValue(); @@ -2016,6 +2057,9 @@ void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALAR // these nodes. if (operand->OperIs(GT_PUTARG_STK)) { + + // collect stack-affecting nodes + disabledNodes.push_back(operand); operand->AsPutArgStk()->gtOp1->SetUnusedValue(); operand->gtBashToNOP(); } @@ -2023,6 +2067,14 @@ void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALAR return GenTree::VisitResult::Continue; }); + if (!disabledNodes.empty()) + { + if (HasAnyThrowableNodes(this, block, disabledNodes)) + { + codeGen->setFramePointerRequired(true); + } + } + blockRange.Remove(node); // Removing a call does not affect liveness unless it is a tail call in a nethod with P/Invokes or diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_524312/DevDiv_524312.il b/tests/src/JIT/Regression/JitBlue/DevDiv_524312/DevDiv_524312.il new file mode 100644 index 0000000000..d69be2b35a --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_524312/DevDiv_524312.il @@ -0,0 +1,74 @@ + +// Microsoft (R) .NET Framework IL Disassembler. Version 4.7.3018.0 +// Copyright (c) Microsoft Corporation. All rights reserved. + + + +.assembly extern mscorlib{} +.assembly ILGEN_MODULE{} + +.class ILGEN_CLASS +{ + .method static int32 Main() + { + .entrypoint + // Code size 19 (0x13) + .maxstack 8 + .try + { + IL_0000: nop + IL_0001: ldc.r8 0.0 + IL_000a: ldc.i4.s 97 + IL_000c: call char ILGEN_CLASS::ILGEN_METHOD_ZERO(float64, char) + IL_0011: pop + IL_0201: ldc.r8 0.0 + IL_020a: ldc.i4.s 97 + IL_0212: call char ILGEN_CLASS::ILGEN_METHOD_INF(float64, char) + IL_0220: pop + IL_0320: leave.s done + } + catch [mscorlib]System.Exception + { + leave.s done + } + done: + ldc.i4 100 + ret + } // end of method Program::Main + + .method private hidebysig static char ILGEN_METHOD_ZERO(float64 d, char cc) cil managed + { + // Code size 7 (0x7) + .maxstack 18 + .locals init (native int, unsigned int64, unsigned int64, float32, float32, float64, int8, float32, bool, native int, unsigned int64, unsigned int64, int64) + IL_0000: ldloc 0x0006 + IL_0004: ldloc 0x0003 + IL_0008: ldc.r4 0x0 // ZERO + IL_000a: dup + IL_000b: ckfinite + IL_000c: rem + IL_000d: conv.r.un + IL_000e: cgt.un + IL_0010: pop + IL_0011: ret + } // end of method Program::ILGEN_METHOD_ZERO + + .method private hidebysig static char ILGEN_METHOD_INF(float64 d, char cc) cil managed + { + // Code size 7 (0x7) + .maxstack 18 + .locals init (native int, unsigned int64, unsigned int64, float32, float32, float64, int8, float32, bool, native int, unsigned int64, unsigned int64, int64) + IL_0000: ldloc 0x0006 + IL_0004: ldloc 0x0003 + IL_0008: ldc.r4 0x7f800000 // INF + IL_000a: dup + IL_000b: ckfinite + IL_000c: rem + IL_000d: conv.r.un + IL_000e: cgt.un + IL_0010: pop + IL_0011: ret + } // end of method Program::ILGEN_METHOD_INF + +} // end of class test.Program + diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_524312/DevDiv_524312.ilproj b/tests/src/JIT/Regression/JitBlue/DevDiv_524312/DevDiv_524312.ilproj new file mode 100644 index 0000000000..643b5e48e0 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_524312/DevDiv_524312.ilproj @@ -0,0 +1,35 @@ +<?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> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <CLRTestPriority>1</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> + <DebugType>None</DebugType> + <Optimize>True</Optimize> + </PropertyGroup> + <ItemGroup> + <Compile Include="DevDiv_524312.il" /> + </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 |