From 1f62917ca7c4d16cb5b4e12eaf4fd35f5cbb8715 Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Tue, 30 Oct 2018 13:38:50 -0700 Subject: Fix `JitStressRegs=0x1` issue with `RefTypeUpperVectorSaveDef`. (#20623) * Add a repro test. * Fix the issue. * Add comments --- .../JitBlue/DevDiv_714266/DevDiv_714266.cs | 62 ++++++++++++++++++++++ .../JitBlue/DevDiv_714266/DevDiv_714266.csproj | 35 ++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 tests/src/JIT/Regression/JitBlue/DevDiv_714266/DevDiv_714266.cs create mode 100644 tests/src/JIT/Regression/JitBlue/DevDiv_714266/DevDiv_714266.csproj (limited to 'tests') diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_714266/DevDiv_714266.cs b/tests/src/JIT/Regression/JitBlue/DevDiv_714266/DevDiv_714266.cs new file mode 100644 index 0000000000..23bb5e9768 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_714266/DevDiv_714266.cs @@ -0,0 +1,62 @@ +// 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.Numerics; +using System.Runtime.CompilerServices; + +// Based on DevDiv_714266, the issue reporoduced with JitStressRegs=0x1. +// `minRegCandidateCount` for `RefTypeUpperVectorSaveDef` did not count one temporary register +// that it used for the save. So if we had a call that did not require any registers (no defs/uses) +// then we set `minRegCandidateCount = 0`for `RefTypeUpperVectorSaveDef` `refPosition` +// and was not able to find a register for do the saving. + +class DevDiv_714266 +{ + [MethodImpl(MethodImplOptions.NoInlining)] + + public static void CallWithoutUsesAndDefs() + { + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static void MethodWithManyLiveVectors() + { + Vector v = new Vector(); + + Vector v0 = -v; + Vector v1 = -v; + Vector v2 = -v; + Vector v3 = -v; + Vector v4 = -v; + Vector v5 = -v; + Vector v6 = -v; + Vector v7 = -v; + Vector v8 = -v; + Vector v9 = -v; + + CallWithoutUsesAndDefs(); + + GC.KeepAlive(new object[10] + { + v1, + v2, + v3, + v4, + v5, + v6, + v7, + v8, + v9, + v0 + }); + } + + static int Main() + { + MethodWithManyLiveVectors(); + return 100; + } + +} diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_714266/DevDiv_714266.csproj b/tests/src/JIT/Regression/JitBlue/DevDiv_714266/DevDiv_714266.csproj new file mode 100644 index 0000000000..bcc4883f33 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_714266/DevDiv_714266.csproj @@ -0,0 +1,35 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + 1 + + + + + + + False + + + + + True + + + + + + + + + + -- cgit v1.2.3