Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3433,7 +3433,6 @@ void Lowering::LowerRetSingleRegStructLclVar(GenTreeUnOp* ret)

if (varDsc->lvDoNotEnregister)
{
assert(!replacedInLowering);
lclVar->ChangeOper(GT_LCL_FLD);
lclVar->AsLclFld()->SetLclOffs(0);

Expand Down
37 changes: 37 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_58972/Runtime_58972.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

public class Runtime_58972
{
public static int Main()
{
GetItem(new MyStruct[1], 0);
return 100;
}

// This code results in a struct returned in register where we replace the local
// of type MyStruct by its only field, and where that field cannot be enregistered.
// We would potentially miss normalization if the struct was returned as an integer
// type and hit a defensive assertion because of it.
static MyStruct GetItem(MyStruct[] a, int i)
{
try
{
return a[i];
}
catch (IndexOutOfRangeException)
{
ThrowHelper();
return default;
}
}

static void ThrowHelper() => throw new Exception();

struct MyStruct
{
byte b;
}
}
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>