-
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.
Fix missing zero-offset sequences and add checking (#64805)
* Add checking for zero-offset FldSeq addition * Add a test * Fix ADDR(LCL_VAR) Zero [FldSeq] * Always add NotAField field sequences * NotAField printing improvements
- Loading branch information
1 parent
8b5e4cc
commit 1ea9cf4
Showing
6 changed files
with
237 additions
and
19 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
102 changes: 102 additions & 0 deletions
102
src/tests/JIT/opt/ValueNumbering/ZeroOffsetFieldSeqs.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,102 @@ | ||
// 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.InteropServices; | ||
using System.Runtime.CompilerServices; | ||
|
||
class ZeroOffsetFieldSeqs | ||
{ | ||
private static UnionStruct s_union; | ||
|
||
public static int Main() | ||
{ | ||
if (ProblemWithArrayUnions(new UnionStruct[] { default })) | ||
{ | ||
return 101; | ||
} | ||
|
||
if (ProblemWithStaticUnions()) | ||
{ | ||
return 102; | ||
} | ||
|
||
if (AnotherProblemWithArrayUnions(new UnionStruct[] { default })) | ||
{ | ||
return 103; | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static bool ProblemWithArrayUnions(UnionStruct[] a) | ||
{ | ||
if (a[0].UnionOne.UnionOneFldTwo == 0) | ||
{ | ||
a[0].UnionTwo.UnionTwoFldTwo = 1; | ||
if (a[0].UnionOne.UnionOneFldTwo == 0) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static bool ProblemWithStaticUnions() | ||
{ | ||
if (s_union.UnionOne.UnionOneFldTwo == 0) | ||
{ | ||
s_union.UnionTwo.UnionTwoFldTwo = 1; | ||
if (s_union.UnionOne.UnionOneFldTwo == 0) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static bool AnotherProblemWithArrayUnions(UnionStruct[] a) | ||
{ | ||
ref var p1 = ref a[0]; | ||
ref var p1a = ref Unsafe.Add(ref p1, 0).UnionOne; | ||
ref var p1b = ref Unsafe.Add(ref p1, 0).UnionTwo; | ||
|
||
if (p1a.UnionOneFldTwo == 0) | ||
{ | ||
p1b.UnionTwoFldTwo = 1; | ||
if (p1a.UnionOneFldTwo == 0) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
[StructLayout(LayoutKind.Explicit)] | ||
struct UnionStruct | ||
{ | ||
[FieldOffset(0)] | ||
public UnionPartOne UnionOne; | ||
[FieldOffset(0)] | ||
public UnionPartTwo UnionTwo; | ||
} | ||
|
||
struct UnionPartOne | ||
{ | ||
public long UnionOneFldOne; | ||
public long UnionOneFldTwo; | ||
} | ||
|
||
struct UnionPartTwo | ||
{ | ||
public long UnionTwoFldOne; | ||
public long UnionTwoFldTwo; | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
src/tests/JIT/opt/ValueNumbering/ZeroOffsetFieldSeqs.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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |