forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: fix redundant zero init issue (.NET 8 port)
"Port" the changes from dotnet#103788 to .NET 8. We don't have the DFS tree, so enhance the topological sort that SSA uses to detect cycles and backedges. Use this info to stop searching for redundant zero inits once flow from entry has entered a cycle. Fixes dotnet#103477 (for .NET 8).
- Loading branch information
1 parent
683125a
commit 6e832c5
Showing
7 changed files
with
143 additions
and
16 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,4 +101,6 @@ class SsaBuilder | |
BitVec m_visited; | ||
|
||
SsaRenameState m_renameStack; | ||
|
||
bool m_hasCycle; | ||
}; |
71 changes: 71 additions & 0 deletions
71
src/tests/JIT/Regression/JitBlue/Runtime_103477/Runtime_103477.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,71 @@ | ||
// 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_103477 | ||
{ | ||
static int s_count; | ||
|
||
[Fact] | ||
public static int Test() | ||
{ | ||
int result = -1; | ||
try | ||
{ | ||
Problem(); | ||
result = 100; | ||
} | ||
catch (Exception) | ||
{ | ||
} | ||
return result; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void Problem() | ||
{ | ||
string s = "12151"; | ||
int i = 0; | ||
|
||
char? a = null; | ||
int count = 0; | ||
while (true) | ||
{ | ||
string? res = get(s, ref i, ref a); | ||
if (res != null) | ||
{ | ||
Count(res); | ||
a = null; // !!! this line is removed from the published version | ||
continue; | ||
} | ||
|
||
if (i >= s.Length) | ||
break; | ||
|
||
a = '.'; | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void Count(string s) | ||
{ | ||
s_count++; | ||
if (s_count > 5) throw new Exception(); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static string? get(string s, ref int index, ref char? a) | ||
{ | ||
if (index >= s.Length) | ||
return null; | ||
|
||
if (a == '.') | ||
return "."; | ||
|
||
a ??= s[index++]; | ||
return (a == '1') ? "1" : null; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/tests/JIT/Regression/JitBlue/Runtime_103477/Runtime_103477.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,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |