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.
Handle the case where we're indirectly updating a local with a value that is not a constant. Fixes dotnet#92218.
- Loading branch information
1 parent
1f9764f
commit edad3b9
Showing
3 changed files
with
55 additions
and
0 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
40 changes: 40 additions & 0 deletions
40
src/tests/JIT/Regression/JitBlue/Runtime_92218/Runtime_92218.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,40 @@ | ||
// 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 System.Threading; | ||
using Xunit; | ||
|
||
public struct MutableStruct | ||
{ | ||
private long _internalValue; | ||
|
||
public long InternalValue | ||
{ | ||
get => Volatile.Read(ref _internalValue); | ||
private set => Volatile.Write(ref _internalValue, value); | ||
} | ||
|
||
public void Add(long value) => AddInternal(value); | ||
private void AddInternal(long value) => InternalValue += value; | ||
public MutableStruct(long value) => InternalValue = value; | ||
} | ||
|
||
public static class Runtime_92218 | ||
{ | ||
[Fact] | ||
[MethodImpl(MethodImplOptions.AggressiveOptimization)] | ||
public static void Problem() | ||
{ | ||
var test = new MutableStruct(420); | ||
var from = new MutableStruct(42); | ||
|
||
var wrapper = -new TimeSpan(3); | ||
|
||
while (test.InternalValue >= from.InternalValue) | ||
{ | ||
test.Add(wrapper.Ticks); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/tests/JIT/Regression/JitBlue/Runtime_92218/Runtime_92218.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,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |