-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/9.0-staging] JIT: Read back all replacements before statemen…
…ts with implicit EH control flow (#109143) Physical promotion sometimes needs to insert read backs of all stale pending replacements when it encounters potential implicit EH control flow (that is, intra-function control flow because of locally caught exceptions). It would be possible for this to interact with QMARKs such that we inserted readbacks inside one of the branches, yet believed we had read back the replacement on all paths. The fix here is to indiscriminately start reading back all replacements before a statement that may cause potential intra-function control flow to occur. Fix #108969
- Loading branch information
1 parent
30c4237
commit fc3708f
Showing
4 changed files
with
126 additions
and
24 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
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
55 changes: 55 additions & 0 deletions
55
src/tests/JIT/Regression/JitBlue/Runtime_108969/Runtime_108969.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,55 @@ | ||
// 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 System.Runtime.Intrinsics; | ||
using Xunit; | ||
|
||
public class Runtime_108969 | ||
{ | ||
[Fact] | ||
public static int TestEntryPoint() => Foo(null); | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static int Foo(object o) | ||
{ | ||
S v = default; | ||
try | ||
{ | ||
v = Bar(); | ||
|
||
// "(int?)o" creates a QMARK with a branch that may throw; we would | ||
// end up reading back v.A inside the QMARK | ||
Use((int?)o); | ||
} | ||
catch (Exception) | ||
{ | ||
} | ||
|
||
// Induce promotion of v.A field | ||
Use(v.A); | ||
Use(v.A); | ||
Use(v.A); | ||
Use(v.A); | ||
Use(v.A); | ||
Use(v.A); | ||
return v.A; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static S Bar() | ||
{ | ||
return new S { A = 100 }; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static void Use<T>(T x) | ||
{ | ||
} | ||
|
||
private struct S | ||
{ | ||
public int A, B, C, D; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/tests/JIT/Regression/JitBlue/Runtime_108969/Runtime_108969.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,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |