blob: 63e3d29f7a1cea80cface08cd441259590c50859 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
}
}
|