Skip to content

Commit 61664ed

Browse files
committed
Ensure we don't reuse temps when calling fgMorphArgs on LIR nodes
1 parent 7cac50f commit 61664ed

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

src/coreclr/jit/rationalize.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ void Rationalizer::RewriteNodeAsCall(GenTree** use,
6969
}
7070
}
7171

72-
CORINFO_ARG_LIST_HANDLE sigArg = sig->args;
73-
size_t firstArg = 0;
72+
CORINFO_ARG_LIST_HANDLE sigArg = sig->args;
73+
size_t firstArg = 0;
74+
bool hasStructArg = false;
7475

7576
if (sig->hasThis())
7677
{
@@ -117,7 +118,8 @@ void Rationalizer::RewriteNodeAsCall(GenTree** use,
117118
unreached();
118119
#endif // FEATURE_HW_INTRINSICS
119120
}
120-
arg = NewCallArg::Struct(operand, sigTyp, clsHnd);
121+
arg = NewCallArg::Struct(operand, sigTyp, clsHnd);
122+
hasStructArg = true;
121123
}
122124
else
123125
{
@@ -150,6 +152,12 @@ void Rationalizer::RewriteNodeAsCall(GenTree** use,
150152
call->gtType = TYP_VOID;
151153
}
152154

155+
// We need to ensure we don't use any of the available outgoing arg temps
156+
// as those were valid from a different scope. We do want to restore them
157+
// back to what they were after we're done here. This is expected to be
158+
// a rare scenario in the first place, so the allocation/copy isn't a big
159+
// concern, but we still don't want to do it unnecessarily
160+
153161
call = comp->fgMorphArgs(call);
154162

155163
GenTree* result = call;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Generated by Fuzzlyn v1.7 on 2024-07-25 11:40:55
2+
// Run on X64 Windows
3+
// Seed: 418121815423725559-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86bmi1,x86bmi1x64,x86bmi2,x86bmi2x64,x86fma,x86lzcnt,x86lzcntx64,x86pclmulqdq,x86popcnt,x86popcntx64,x86sse,x86ssex64,x86sse2,x86sse2x64,x86sse3,x86sse41,x86sse41x64,x86sse42,x86sse42x64,x86ssse3,x86x86base
4+
// Reduced from 72.7 KiB to 1.0 KiB in 00:01:55
5+
// Debug: Outputs <0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>
6+
// Release: Outputs <1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>
7+
using System;
8+
using System.Runtime.CompilerServices;
9+
using System.Runtime.Intrinsics;
10+
using System.Runtime.Intrinsics.X86;
11+
using Xunit;
12+
13+
[module: SkipLocalsInit]
14+
15+
public struct S3
16+
{
17+
public byte F0;
18+
}
19+
20+
public class Runtime_105468
21+
{
22+
public static S3 s_3;
23+
24+
[Fact]
25+
public static void TestEntryPoint()
26+
{
27+
if (Avx2.IsSupported)
28+
{
29+
var vr15 = (ushort)0;
30+
var vr16 = Vector256.CreateScalar(vr15);
31+
var vr17 = Vector256.Create<ushort>(1);
32+
var vr18 = (ushort)0;
33+
var vr19 = Vector256.CreateScalar(vr18);
34+
var vr20 = s_3.F0;
35+
var vr21 = Avx2.AlignRight(vr17, vr19, vr20);
36+
M6(vr16, vr21);
37+
}
38+
}
39+
40+
[MethodImpl(MethodImplOptions.NoInlining)]
41+
private static void M6(Vector256<ushort> arg1, Vector256<ushort> arg3)
42+
{
43+
Assert.Equal(Vector256<ushort>.Zero, arg1);
44+
}
45+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)