forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: Mark replacements as dirty after setting GTF_VAR_DEATH (dotnet#8…
…8669) Physically promoted struct locals are marked as dying when their remainder dies since all other state is stored in other locals. However, when we do this we must also mark all replacements as stale; otherwise a future struct use could skip writebacks and effectively introduce new uses, invalidating the previously marked last use bit. Fix dotnet#88616
- Loading branch information
1 parent
31b1fd4
commit ddbce91
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/tests/JIT/Regression/JitBlue/Runtime_88616/Runtime_88616.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using Xunit; | ||
|
||
public class Runtime_88616 | ||
{ | ||
[Fact] | ||
public static int TestEntryPoint() | ||
{ | ||
S foo; | ||
foo.A = 10; | ||
foo.B = 20; | ||
foo.C = 30; | ||
foo.D = 40; | ||
foo.E = 50; | ||
foo.A += foo.A += foo.A += foo.A += foo.A; | ||
foo.B += foo.B += foo.B += foo.B += foo.B; | ||
foo.C += foo.C += foo.C += foo.C += foo.C; | ||
foo.D += foo.D += foo.D += foo.D += foo.D; | ||
foo.E += foo.E += foo.E += foo.E += foo.E; | ||
// 'foo' is a last use here (it is fully promoted so all of its state | ||
// is stored in separate field locals), so physical promotions marks | ||
// this occurence as GTF_VAR_DEATH. | ||
Mutate(foo); | ||
// However, we cannot use the fact that we wrote the fields back into | ||
// the struct local above to skip those same write backs here; if we | ||
// skip those write backs then we effectively introduce new uses of the | ||
// struct local. | ||
return Check(foo); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static void Mutate(S s) | ||
{ | ||
s.A = -42; | ||
Consume(ref s); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static void Consume(ref S s) | ||
{ | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static int Check(S s) | ||
{ | ||
if (s.A != 50) | ||
{ | ||
Console.WriteLine("FAIL: s.A == {0}", s.A); | ||
return -1; | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
private struct S | ||
{ | ||
public long A, B, C, D, E; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/tests/JIT/Regression/JitBlue/Runtime_88616/Runtime_88616.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Optimize>True</Optimize> | ||
<DebugType>None</DebugType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |