-
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.
Expand the GC hole fix for explicitly initialized structs (#69501)
* Expand the fix for explicitly initialized structs Liveness code already recognizes that it cannot delete certain local stores with the implicit side effect of "explicit initialization". However, it was only doing that for indirect "InitBlk" forms, while the store can have more or less arbitrary shape (the only requirement is that is must be "entire"). Fix this by not constraining the check to "InitBlk"s. * Add a test
- Loading branch information
1 parent
1d1df64
commit fbef29b
Showing
5 changed files
with
109 additions
and
44 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
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
41 changes: 41 additions & 0 deletions
41
src/tests/JIT/Regression/JitBlue/Runtime_65694/Runtime_65694_2.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,41 @@ | ||
// 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; | ||
|
||
public class Runtime_65694_2 | ||
{ | ||
public static int Main() | ||
{ | ||
var a = new StructWithObj { Obj = new object() }; | ||
var c = new StructWithObj { Obj = new object() }; | ||
|
||
return Problem(a, c).Obj == c.Obj ? 100 : 101; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static StructWithObj Problem(StructWithObj a, StructWithObj c) | ||
{ | ||
StructWithObj b = a; | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void GcSafePoint() { GC.Collect(); } | ||
|
||
GcSafePoint(); | ||
GcSafePoint(); | ||
|
||
if (a.Obj == b.Obj) | ||
{ | ||
b = c; | ||
} | ||
|
||
return b; | ||
} | ||
|
||
struct StructWithObj | ||
{ | ||
public object Obj; | ||
} | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
src/tests/JIT/Regression/JitBlue/Runtime_65694/Runtime_65694_2.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,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<Optimize>True</Optimize> | ||
<CLRTestBatchPreCommands><![CDATA[ | ||
$(CLRTestBatchPreCommands) | ||
set DOTNET_JitNoStructPromotion=1 | ||
]]></CLRTestBatchPreCommands> | ||
<BashCLRTestPreCommands><![CDATA[ | ||
$(BashCLRTestPreCommands) | ||
export DOTNET_JitNoStructPromotion=1 | ||
]]></BashCLRTestPreCommands> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |