-
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.
- Loading branch information
1 parent
6b69b7e
commit ec5f2a8
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/tests/JIT/Methodical/Arrays/misc/IndexingSideEffects.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,50 @@ | ||
// 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 IndexingSideEffects | ||
{ | ||
[Fact] | ||
public static int TestEntryPoint() | ||
{ | ||
if (!Problem()) | ||
{ | ||
return 101; | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static bool Problem() | ||
{ | ||
bool result = false; | ||
|
||
try | ||
{ | ||
TryIndexing(new int[0]); | ||
} | ||
catch (IndexOutOfRangeException) | ||
{ | ||
result = true; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static void TryIndexing(int[] a) | ||
{ | ||
// Make sure that early flowgraph simplification does not remove the side effect of indexing | ||
// when deleting the relop. | ||
if (a[int.MaxValue] == 0) | ||
{ | ||
NopInlinedCall(); | ||
} | ||
} | ||
|
||
private static void NopInlinedCall() { } | ||
} |
9 changes: 9 additions & 0 deletions
9
src/tests/JIT/Methodical/Arrays/misc/IndexingSideEffects.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,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |