-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix argument passing of structs with padding on x86 (#108867)
When passing a struct by value on x86, we copy its value to the stack. Sometimes this is done one field at a time, if the struct has been promoted. If there is padding between the fields (to create appropriate field alignment), then that padding needs to be zeroed. The bug is a case where there is padding between an earlier `double` field and a later, larger, SIMD field. We push 4-byte zeros but the code thinks it is pushing 8-byte zeros. The fix is simply to correctly calculate the number of zeros to push. Fixes #106140
- Loading branch information
1 parent
a636e6d
commit e1a14a8
Showing
3 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
src/tests/JIT/Regression/JitBlue/Runtime_106140/Runtime_106140.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,32 @@ | ||
// 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.Intrinsics; | ||
using Xunit; | ||
|
||
public class Runtime_106140 | ||
{ | ||
public struct S1 | ||
{ | ||
public double F0; | ||
public Vector256<int> F1; | ||
public S1(bool f3) : this() | ||
{ | ||
F1 = Vector256.Create(1,2,100,4,5,6,7,8); | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static int t(S1 s) | ||
{ | ||
return s.F1.GetElement(2); | ||
} | ||
|
||
[Fact] | ||
public static void TestEntryPoint() | ||
{ | ||
Assert.Equal(100, t(new S1(false))); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/tests/JIT/Regression/JitBlue/Runtime_106140/Runtime_106140.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,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |