summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Regression/JitBlue/DevDiv_278376/DevDiv_278376.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/JIT/Regression/JitBlue/DevDiv_278376/DevDiv_278376.cs')
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_278376/DevDiv_278376.cs36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_278376/DevDiv_278376.cs b/tests/src/JIT/Regression/JitBlue/DevDiv_278376/DevDiv_278376.cs
new file mode 100644
index 0000000000..63e3d29f7a
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_278376/DevDiv_278376.cs
@@ -0,0 +1,36 @@
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// NOTE: the bug for this test was an assertion in RyuJIT/x86 when generating code for a double-returning call that
+// was spilled by the RA and subsequently used. The call in question is the call to `C.GetDouble` in `C.Test`.
+// To ensure that its return value is spilled, `C.GetDouble` is implemented as a P/Invoke method: the return
+// value ends up spilled because there is a call to `TrapReturningThreads` between the call and the use of the
+// return value by the cast. Because the bug is a simple assert, there is no need for the problematic code to
+// actually run, so the implementation of `GetDouble` does not need to actually exist.
+
+sealed class C
+{
+ [DllImport("nonexistent.dll")]
+ extern static double GetDouble();
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static void UseDouble(double d)
+ {
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Test(bool condition)
+ {
+ if (condition)
+ {
+ UseDouble((double)GetDouble());
+ }
+
+ return 100;
+ }
+
+ static int Main(string[] args)
+ {
+ return Test(false);
+ }
+}