-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loop alignment: Fix loop size calculation to exclude IG's size that a…
…re marked as not aligned (#68869) * Flag to track IGs whose alignment was removed * Update src/coreclr/jit/emit.cpp Co-authored-by: Wraith <wraith2@gmail.com> * Fix for 65988: Unmark the firstBB as not aligned * Add test case for #65690 * Replace IGF_REMOVE_FLAG with different logic * improve loops natvis * Add back IGF_REMOVED_ALIGN * review comments Co-authored-by: Wraith <wraith2@gmail.com>
- Loading branch information
1 parent
336a5d2
commit 478b1b4
Showing
9 changed files
with
268 additions
and
9 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
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
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
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
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
120 changes: 120 additions & 0 deletions
120
src/tests/JIT/Regression/JitBlue/GitHub_65690/GitHub_65690.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,120 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// | ||
// Note: In below test case, there are two backedges to a loop that is marked for align. | ||
// If we see intersecting aligned loops, we mark that loop as not needing alignment | ||
// but then when we see 2nd backedge we again try to mark it as not needing alignment | ||
// and that triggers an assert. | ||
// Found by Antigen | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
public class TestClass_65690 | ||
{ | ||
public struct S1 | ||
{ | ||
public struct S1_D1_F1 | ||
{ | ||
public decimal decimal_0; | ||
public bool bool_1; | ||
public sbyte sbyte_2; | ||
} | ||
public double double_3; | ||
} | ||
public struct S2 | ||
{ | ||
public S1.S1_D1_F1 s1_s1_d1_f1_5; | ||
} | ||
static byte s_byte_7 = 2; | ||
static decimal s_decimal_9 = -1.9647058823529411764705882353m; | ||
static int s_int_12 = 1; | ||
static long s_long_13 = -2147483647; | ||
static ulong s_ulong_19 = 1; | ||
static S1.S1_D1_F1 s_s1_s1_d1_f1_20 = new S1.S1_D1_F1(); | ||
bool bool_23 = true; | ||
byte byte_24 = 5; | ||
int int_29 = 1; | ||
ushort ushort_34 = 5; | ||
uint uint_35 = 5; | ||
S1.S1_D1_F1 s1_s1_d1_f1_37 = new S1.S1_D1_F1(); | ||
S1 s1_38 = new S1(); | ||
S2 s2_39 = new S2(); | ||
static int s_loopInvariant = 4; | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public byte LeafMethod1() | ||
{ | ||
unchecked | ||
{ | ||
return 15 + 4; | ||
} | ||
} | ||
|
||
public double Method3(out sbyte p_sbyte_93, out double p_double_94, out S1.S1_D1_F1 p_s1_s1_d1_f1_98) | ||
{ | ||
unchecked | ||
{ | ||
p_double_94 = 15 + 4; | ||
p_s1_s1_d1_f1_98 = new S1.S1_D1_F1(); | ||
p_sbyte_93 = 15 % 4; | ||
return 15 + 4; | ||
} | ||
} | ||
|
||
public void Method0() | ||
{ | ||
unchecked | ||
{ | ||
int int_145 = -5; | ||
ulong ulong_152 = 5; | ||
S1.S1_D1_F1 s1_s1_d1_f1_153 = new S1.S1_D1_F1(); | ||
S2 s2_155 = new S2(); | ||
if (15 - 4 != LeafMethod1()) | ||
{ | ||
} | ||
else | ||
{ | ||
try | ||
{ | ||
ulong_152 >>= s_int_12 = int_145 -= 15 + 4; | ||
} | ||
finally | ||
{ | ||
s2_39.s1_s1_d1_f1_5.decimal_0 = 15 % 4 + s1_s1_d1_f1_153.decimal_0 - 15 + 4 + 40; | ||
} | ||
int __loopvar25 = 15 + 4; | ||
do | ||
{ | ||
if (__loopvar25 < s_loopInvariant - 1) | ||
break; | ||
} | ||
while (s1_s1_d1_f1_37.bool_1 = s1_s1_d1_f1_37.bool_1 = bool_23); | ||
} | ||
if (15 / 4 % ulong_152 + 22 + 78 - s_ulong_19 > 19) | ||
{ | ||
int __loopvar26 = 15 - 4; | ||
for (; ; ) | ||
{ | ||
if (__loopvar26 >= s_loopInvariant) | ||
break; | ||
if (s1_s1_d1_f1_37.bool_1) | ||
{ | ||
Method3(out s2_155.s1_s1_d1_f1_5.sbyte_2, out s1_38.double_3, out s1_s1_d1_f1_153); | ||
} | ||
else | ||
{ | ||
ushort_34 *= 15 % 4; | ||
} | ||
if ((byte_24 = s_byte_7 ^= 15 | 4) >= (15 | 4)) | ||
{ | ||
} | ||
} | ||
} | ||
return; | ||
} | ||
} | ||
public static int Main(string[] args) | ||
{ | ||
new TestClass_65690().Method0(); | ||
return 100; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/tests/JIT/Regression/JitBlue/GitHub_65690/GitHub_65690.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,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<CLRTestBatchPreCommands><![CDATA[ | ||
$(CLRTestBatchPreCommands) | ||
set COMPlus_JitDoValueNumber=0 | ||
set COMPlus_JitStressRegs=3 | ||
set COMPlus_TieredCompilation=0 | ||
]]></CLRTestBatchPreCommands> | ||
<BashCLRTestPreCommands><![CDATA[ | ||
$(BashCLRTestPreCommands) | ||
export COMPlus_JitDoValueNumber=0 | ||
export COMPlus_JitStressRegs=3 | ||
export COMPlus_TieredCompilation=0 | ||
]]></BashCLRTestPreCommands> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |
48 changes: 48 additions & 0 deletions
48
src/tests/JIT/Regression/JitBlue/GitHub_65988/GitHub_65988.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,48 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// | ||
// Note: In below test case, we were skipping the first block that is an alignment candidate, | ||
// but were not unmarking it such. As a result, we would hit assert during backedge setup. | ||
// Found by Antigen | ||
public class TestClass_65988 | ||
{ | ||
public struct S1 | ||
{ | ||
public decimal decimal_0; | ||
} | ||
public struct S2 | ||
{ | ||
public S1 s1_2; | ||
} | ||
static int s_int_9 = 1; | ||
decimal decimal_22 = 0.08m; | ||
S1 s1_33 = new S1(); | ||
public decimal LeafMethod3() => 67.1m; | ||
|
||
public void Method0() | ||
{ | ||
unchecked | ||
{ | ||
int int_85 = 76; | ||
S1 s1_93 = new S1(); | ||
for (; ; ) | ||
{ | ||
if ((15 << 4) < (s_int_9 *= int_85)) | ||
{ | ||
s1_33.decimal_0 += decimal_22 -= 15 * 4 - -2147483646.9375m; | ||
} | ||
s1_93.decimal_0 /= (s1_33.decimal_0 /= LeafMethod3()) + 28; | ||
if (int_85++ == 77000) | ||
{ | ||
break; | ||
} | ||
} | ||
return; | ||
} | ||
} | ||
public static int Main(string[] args) | ||
{ | ||
new TestClass_65988().Method0(); | ||
return 100; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/tests/JIT/Regression/JitBlue/GitHub_65988/GitHub_65988.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,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<CLRTestBatchPreCommands><![CDATA[ | ||
$(CLRTestBatchPreCommands) | ||
set COMPlus_EnableSSE2=0 | ||
set COMPlus_OSR_HitLimit=1 | ||
set COMPlus_TC_OnStackReplacement=1 | ||
set COMPlus_TC_OnStackReplacement_InitialCounter=1 | ||
set COMPlus_TC_QuickJitForLoops=1 | ||
]]></CLRTestBatchPreCommands> | ||
<BashCLRTestPreCommands><![CDATA[ | ||
$(BashCLRTestPreCommands) | ||
export COMPlus_EnableSSE2=0 | ||
export COMPlus_OSR_HitLimit=1 | ||
export COMPlus_TC_OnStackReplacement=1 | ||
export COMPlus_TC_OnStackReplacement_InitialCounter=1 | ||
export COMPlus_TC_QuickJitForLoops=1 | ||
]]></BashCLRTestPreCommands> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |