Skip to content

Commit 2d07d3d

Browse files
authored
JIT: Fix codegen for misaligned double STORE_LCL_FLD on arm32 (#109547)
1 parent 3116db9 commit 2d07d3d

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/coreclr/jit/codegenarm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ void CodeGen::genCodeForStoreLclFld(GenTreeLclFld* tree)
10361036
regNumber halfdoubleAsInt2 = internalRegisters.GetSingle(tree);
10371037
emit->emitIns_R_R_R(INS_vmov_d2i, EA_8BYTE, halfdoubleAsInt1, halfdoubleAsInt2, dataReg);
10381038
emit->emitIns_R_R_I(INS_str, EA_4BYTE, halfdoubleAsInt1, addr, 0);
1039-
emit->emitIns_R_R_I(INS_str, EA_4BYTE, halfdoubleAsInt1, addr, 4);
1039+
emit->emitIns_R_R_I(INS_str, EA_4BYTE, halfdoubleAsInt2, addr, 4);
10401040
}
10411041
}
10421042
else
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Runtime.CompilerServices;
6+
using System.Runtime.InteropServices;
7+
using Xunit;
8+
9+
public class Runtime_108969
10+
{
11+
[Fact]
12+
public static int TestEntryPoint() => (int)Foo(100.0).D;
13+
14+
[MethodImpl(MethodImplOptions.NoInlining)]
15+
private static S Foo(double d)
16+
{
17+
S s = default;
18+
s.D = d;
19+
return s;
20+
}
21+
22+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
23+
struct S
24+
{
25+
public byte B;
26+
public double D;
27+
}
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<!-- Needed for CLRTestEnvironmentVariable -->
4+
<RequiresProcessIsolation>true</RequiresProcessIsolation>
5+
<Optimize>True</Optimize>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<Compile Include="$(MSBuildProjectName).cs" />
9+
<CLRTestEnvironmentVariable Include="DOTNET_JitNoStructPromotion" Value="1" />
10+
</ItemGroup>
11+
</Project>

0 commit comments

Comments
 (0)