Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a test
  • Loading branch information
SingleAccretion committed Dec 12, 2021
commit f48008b0385d6c274579dfd3cf0980b72d807971
36 changes: 36 additions & 0 deletions src/tests/JIT/Directed/StructPromote/FldSeqsInPromotedCpBlk.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;

class FldSeqsInPromotedCpBlk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment linking this test to the PR and/or describing the problem this test is supposed to cover?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one, hopefully it captures the problem precisely enough.

{
public static int Main()
{
PromotableStruct s = default;
return Problem(new PromotableStruct[1]) == 2 ? 100 : 101;
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static long Problem(PromotableStruct[] a)
{
ref var firstElem = ref a[0];

firstElem.SecondLngValue = 1;
var b = new PromotableStruct() { SecondLngValue = 2 };

if (firstElem.SecondLngValue == 1)
{
firstElem = b;
return firstElem.SecondLngValue;
}

return -1;
}
}

struct PromotableStruct
{
public long FirstLngValue;
public long SecondLngValue;
}
13 changes: 13 additions & 0 deletions src/tests/JIT/Directed/StructPromote/FldSeqsInPromotedCpBlk.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>