-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Take into account zero-offset field sequences when propagating locals (…
…#64701) * Add a test * Fix the problem LCL_VAR use VN != VN of its SSA def. Using one for replacement can run afoul of substituting into a LCL_VAR that has a zero-offset field sequence on top and thus duplicate the sequence (as the replacement def will already have this sequence incorporated into its VN). * Fix the same problem in local propagation Just one diff, missing null check elimination: we propagated a field sequence for an array address (PtrToArrElem) that later wasn't recognized as implying non-nullness of another PtrToArrElem to the same array.
- Loading branch information
1 parent
75589ae
commit 713c8dd
Showing
5 changed files
with
164 additions
and
22 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
82 changes: 82 additions & 0 deletions
82
src/tests/JIT/Regression/JitBlue/Runtime_64700/Runtime_64700.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,82 @@ | ||
// 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.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
class Runtime_64700 | ||
{ | ||
private static StructWithVtors _structWithVtorsStatic; | ||
|
||
static int Main() | ||
{ | ||
_structWithVtorsStatic = new StructWithVtors { StructWithOneVtor = { OneVtor = new Vector2(1, 0) } }; | ||
|
||
if (ProblemWithCopyProp(0) != 0) | ||
{ | ||
return 101; | ||
} | ||
|
||
if (ProblemWithLocalAssertionProp(new SmallerStruct[] { default }) != 1) | ||
{ | ||
return 102; | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static float ProblemWithCopyProp(float a) | ||
{ | ||
ref var p1 = ref _structWithVtorsStatic.StructWithOneVtor.OneVtor; | ||
ref var p2 = ref _structWithVtorsStatic; | ||
|
||
if (_structWithVtorsStatic.StructWithOneVtor.OneVtor.X == 1) | ||
{ | ||
p2.StructWithOneVtor.OneVtor = Vector2.Zero; | ||
if (_structWithVtorsStatic.StructWithOneVtor.OneVtor.X == 1) | ||
{ | ||
a = 1; | ||
} | ||
} | ||
|
||
return a + p1.Y; | ||
} | ||
|
||
struct StructWithVtors | ||
{ | ||
public StructWithOneVtor StructWithOneVtor; | ||
} | ||
|
||
struct StructWithOneVtor | ||
{ | ||
public Vector2 OneVtor; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static long ProblemWithLocalAssertionProp(SmallerStruct[] a) | ||
{ | ||
ref var p1 = ref a[0]; | ||
Use(ref p1); | ||
ref var p2 = ref p1.RegStruct; | ||
Use(ref p2); | ||
|
||
var t = p2.FirstLngValue; | ||
a[0].RegStruct.FirstLngValue = 1; | ||
|
||
return t + p2.FirstLngValue; | ||
} | ||
|
||
public static void Use<T>(ref T arg) { } | ||
|
||
struct SmallerStruct | ||
{ | ||
public RegStruct RegStruct; | ||
} | ||
|
||
struct RegStruct | ||
{ | ||
public long FirstLngValue; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/tests/JIT/Regression/JitBlue/Runtime_64700/Runtime_64700.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_JitOptRepeat=ProblemWithCopyProp | ||
]]></CLRTestBatchPreCommands> | ||
<BashCLRTestPreCommands><![CDATA[ | ||
$(BashCLRTestPreCommands) | ||
export DOTNET_JitOptRepeat=ProblemWithCopyProp | ||
]]></BashCLRTestPreCommands> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |