-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes and improvements for removal of redundant zero inits #37786
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
71 changes: 71 additions & 0 deletions
71
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_37666/GitHub_37666.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. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
|
||
public struct TwoBools | ||
{ | ||
public bool b1; | ||
public bool b2; | ||
|
||
public TwoBools(bool b1, bool b2) | ||
{ | ||
this.b1 = b1; | ||
this.b2 = b2; | ||
} | ||
} | ||
|
||
class Test | ||
{ | ||
public static int Main() | ||
{ | ||
int result = 100; | ||
|
||
RunTest(Test1, "Test1", ref result); | ||
RunTest(Test2, "Test2", ref result); | ||
|
||
return result; | ||
} | ||
|
||
delegate TwoBools TestZeroInit(); | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void RunTest(TestZeroInit test, string testName, ref int result) | ||
{ | ||
if (test().b2) | ||
{ | ||
Console.WriteLine(testName + " failed"); | ||
result = -1; | ||
} | ||
else | ||
{ | ||
Console.WriteLine(testName + " passed"); | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static TwoBools Test1() | ||
{ | ||
TwoBools result = CreateTwoBools(); | ||
result.b2 = false; | ||
return result; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static TwoBools Test2() | ||
{ | ||
TwoBools result = default(TwoBools); | ||
result.b2 = true; | ||
result = default(TwoBools); | ||
return result; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static TwoBools CreateTwoBools() | ||
{ | ||
TwoBools result = new TwoBools(true, true); | ||
return result; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_37666/GitHub_37666.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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<CLRTestPriority>0</CLRTestPriority> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally don't incrementally update ref counts anymore. Is this important?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added that in #37280. The idea is to detect cases where we make the struct dependently promoted because of a block assignment and then delete that block assignment. In that case we can make the field tracked and eliminate dead field assignments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there is any guarantee that the count is > 0 at this point? I suppose this is running not long after the first call to
lvaMarkLocalVars
so the ref counts are probably still fairly accurate.And the code to determine which locals to track is just a heuristic, so it's ok if it is based on incorrect ref count info.