Skip to content

Commit

Permalink
JIT: Fix codegen for misaligned double STORE_LCL_FLD on arm32 (#109547
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jakobbotsch authored Nov 6, 2024
1 parent 3116db9 commit 2d07d3d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ void CodeGen::genCodeForStoreLclFld(GenTreeLclFld* tree)
regNumber halfdoubleAsInt2 = internalRegisters.GetSingle(tree);
emit->emitIns_R_R_R(INS_vmov_d2i, EA_8BYTE, halfdoubleAsInt1, halfdoubleAsInt2, dataReg);
emit->emitIns_R_R_I(INS_str, EA_4BYTE, halfdoubleAsInt1, addr, 0);
emit->emitIns_R_R_I(INS_str, EA_4BYTE, halfdoubleAsInt1, addr, 4);
emit->emitIns_R_R_I(INS_str, EA_4BYTE, halfdoubleAsInt2, addr, 4);
}
}
else
Expand Down
28 changes: 28 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_109269/Runtime_109269.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.Runtime.InteropServices;
using Xunit;

public class Runtime_108969
{
[Fact]
public static int TestEntryPoint() => (int)Foo(100.0).D;

[MethodImpl(MethodImplOptions.NoInlining)]
private static S Foo(double d)
{
S s = default;
s.D = d;
return s;
}

[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct S
{
public byte B;
public double D;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Needed for CLRTestEnvironmentVariable -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
<CLRTestEnvironmentVariable Include="DOTNET_JitNoStructPromotion" Value="1" />
</ItemGroup>
</Project>

0 comments on commit 2d07d3d

Please sign in to comment.