Skip to content

Commit 0dea0b5

Browse files
authored
JIT: Properly check spilling around fat pointer calls (#116692)
1 parent d1770cc commit 0dea0b5

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

src/coreclr/jit/importercalls.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,8 +1475,7 @@ var_types Compiler::impImportCall(OPCODE opcode,
14751475
varDsc->lvType = call->AsCall()->gtReturnType;
14761476
}
14771477

1478-
// TODO-Bug: CHECK_SPILL_NONE here looks wrong.
1479-
impStoreToTemp(calliSlot, call, CHECK_SPILL_NONE);
1478+
impStoreToTemp(calliSlot, call, CHECK_SPILL_ALL);
14801479
// impStoreToTemp can change src arg list and return type for call that returns struct.
14811480
var_types type = genActualType(lvaTable[calliSlot].TypeGet());
14821481
call = gtNewLclvNode(calliSlot, type);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Runtime.CompilerServices;
5+
using Xunit;
6+
7+
public unsafe class Runtime_116689
8+
{
9+
[Fact]
10+
public static int TestEntryPoint()
11+
{
12+
s_value = -1;
13+
return Test(&GetVal);
14+
}
15+
16+
private static int s_value;
17+
[MethodImpl(MethodImplOptions.NoInlining)]
18+
private static unsafe int Test(delegate*<int> foo)
19+
{
20+
return s_value + foo();
21+
}
22+
23+
private static int GetVal()
24+
{
25+
s_value = 0;
26+
return 101;
27+
}
28+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)