summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Regression/JitBlue/GitHub_20269/GitHub_20269.cs
diff options
context:
space:
mode:
authorEugene Rozenfeld <erozen@microsoft.com>2019-02-08 00:14:35 -0800
committerGitHub <noreply@github.com>2019-02-08 00:14:35 -0800
commita8ebed30b50c32a84ca8edbe033870a9e0f1da61 (patch)
tree43e51ea34350bbc47ce3ba7da2f029b490ac96e9 /tests/src/JIT/Regression/JitBlue/GitHub_20269/GitHub_20269.cs
parentea452c1ff113413bddd22794dcac0359af0e79fe (diff)
downloadcoreclr-a8ebed30b50c32a84ca8edbe033870a9e0f1da61.tar.gz
coreclr-a8ebed30b50c32a84ca8edbe033870a9e0f1da61.tar.bz2
coreclr-a8ebed30b50c32a84ca8edbe033870a9e0f1da61.zip
Force results of rejected multi-reg-returning tail-call candidates to temp. (#22364)
* Force results of rejected multi-reg-returning tail-call candidates to temp. Issue #20269 ran into an assert when trying to merge returns, one of which is a call to a multi-reg-returning method. The repro in the bug is a pmi of `System.Reflection.Metadata`. I added a simple repro test case. Results of calls to multi-reg-returning methods are expected to be saved to temps. Normally it's ensured by `impFixupCallStructReturn`; however, it doesn't do that for tail-call candidates. This change forces results of calls to multi-reg-returning methods to temps if the tail call is rejected late in morph. Fixes #20269.
Diffstat (limited to 'tests/src/JIT/Regression/JitBlue/GitHub_20269/GitHub_20269.cs')
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_20269/GitHub_20269.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_20269/GitHub_20269.cs b/tests/src/JIT/Regression/JitBlue/GitHub_20269/GitHub_20269.cs
new file mode 100644
index 0000000000..39a6714ebe
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_20269/GitHub_20269.cs
@@ -0,0 +1,67 @@
+// 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.Runtime.CompilerServices;
+using System.Numerics;
+
+namespace GitHub_20269
+{
+ // This tests a case where
+ // 1) We merge returns.
+ // 2) One of the returns has an operand that is a call to a multi-reg returning method.
+ // 3) The call is marked as a tail-call candidate in the importer.
+ // 3) The tail call is rejected late in morph.
+ //
+
+ class Program
+ {
+ static int i;
+ static int Main(string[] args)
+ {
+ i = 1;
+ return (int)new Program().GetVector()[0] + 99;
+ }
+
+ public virtual Vector<float> GetVector()
+ {
+ // Address-taken local prevents tail-calling
+ // GetVectorHelper.
+ int x = 0;
+ DoNothing(ref x);
+
+ // 5 returns are needed to trigger merge of returns
+ switch(i)
+ {
+ case 1:
+ // This call is a tail-call candidate rejected late.
+ return GetVectorHelper();
+
+ case 2:
+ return new Vector<float>(2.0f);
+
+ case 3:
+ return new Vector<float>(3.0f);
+
+ case 4:
+ return new Vector<float>(4.0f);
+
+ default:
+ return new Vector<float>(100.0f);
+
+ }
+ }
+
+ // This is a multi-reg return method on ARM64
+ public virtual Vector<float> GetVectorHelper()
+ {
+ return new Vector<float>(1.0f);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void DoNothing(ref int i)
+ {
+ }
+ }
+}