forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: block throw helper merges for first block of a try
Otherwise we may create a branch into the middle of a try. We could fix the transform, but if the first block of a try has a throw helper call, the rest of the try will subsequently be removed, so merging is not all that interesting. Addresses an issue that came up in dotnet#33924.
- Loading branch information
1 parent
e177402
commit 2cab722
Showing
3 changed files
with
57 additions
and
0 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
36 changes: 36 additions & 0 deletions
36
src/coreclr/tests/src/JIT/opt/ThrowHelper/ThrowHelperAtTryEntry.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,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
// Test case where throw helper is in the try entry block. | ||
// | ||
// Throw helper merging is run lexically backwards, | ||
// so the optimization may introduce a jump into the middle of the try. | ||
|
||
class ThrowHelperAtTryEntry | ||
{ | ||
static void ThrowHelper() | ||
{ | ||
throw new Exception(); | ||
} | ||
|
||
public static int Main() | ||
{ | ||
int x = 0; | ||
bool p = true; | ||
try | ||
{ | ||
ThrowHelper(); | ||
x = -1; | ||
if (p) ThrowHelper(); | ||
} | ||
catch (Exception) | ||
{ | ||
x = 100; | ||
} | ||
|
||
return x; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/coreclr/tests/src/JIT/opt/ThrowHelper/ThrowHelperAtTryEntry.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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="ThrowHelperAtTryEntry.cs" /> | ||
</ItemGroup> | ||
</Project> |