-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Process also exception filters when marking unreachable blocks
Fixes dotnet/linker#1507 Commit migrated from dotnet/linker@337f0c5
- Loading branch information
1 parent
f96e791
commit 278e1e4
Showing
2 changed files
with
103 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
101 changes: 101 additions & 0 deletions
101
src/tools/illink/test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFilterBlocks.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,101 @@ | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
|
||
namespace Mono.Linker.Tests.Cases.UnreachableBlock | ||
{ | ||
[SetupCSharpCompilerToUse ("csc")] | ||
[SetupCompileArgument ("/optimize+")] | ||
[SetupLinkerArgument ("--enable-opt", "ipconstprop")] | ||
public class TryFilterBlocks | ||
{ | ||
public static void Main () | ||
{ | ||
TestUnreachableInsideTry (); | ||
TestUnreachableInsideFilterCondition (); | ||
} | ||
|
||
[Kept] | ||
[ExpectedInstructionSequence (new[] { | ||
"call", | ||
"brfalse.s", | ||
"call", | ||
"leave.s", | ||
"pop", | ||
"call", | ||
"ldc.i4.0", | ||
"cgt.un", | ||
"endfilter", | ||
"pop", | ||
"leave.s", | ||
"ldc.i4.2", | ||
"ret" | ||
})] | ||
[ExpectedExceptionHandlerSequence (new string[] { "filter" })] | ||
static int TestUnreachableInsideTry () | ||
{ | ||
try { | ||
if (Prop) | ||
Unreached_1 (); | ||
|
||
Reached_1 (); | ||
} catch when (Log ()) { | ||
} | ||
|
||
return 2; | ||
} | ||
|
||
[Kept] | ||
[ExpectedInstructionSequence (new[] { | ||
"call", | ||
"leave.s", | ||
"pop", | ||
"call", | ||
"brfalse.s", | ||
"ldc.i4.0", | ||
"ldc.i4.0", | ||
"cgt.un", | ||
"endfilter", | ||
"pop", | ||
"leave.s", | ||
"ldc.i4.3", | ||
"ret" | ||
})] | ||
[ExpectedExceptionHandlerSequence (new string[] { "filter" })] | ||
static int TestUnreachableInsideFilterCondition () | ||
{ | ||
try { | ||
Reached_2 (); | ||
} catch when (Log () && Unreached_2 ()) { | ||
} | ||
|
||
return 3; | ||
} | ||
|
||
[Kept] | ||
static bool Prop { | ||
[Kept] | ||
get { | ||
return false; | ||
} | ||
} | ||
|
||
[Kept] | ||
static bool Log () => false; | ||
|
||
[Kept] | ||
static void Reached_1 () | ||
{ | ||
} | ||
|
||
[Kept] | ||
static void Reached_2 () | ||
{ | ||
} | ||
|
||
static void Unreached_1 () | ||
{ | ||
} | ||
|
||
static bool Unreached_2 () => true; | ||
} | ||
} |