diff options
author | Marek Safar <marek.safar@gmail.com> | 2020-02-21 20:16:05 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2020-02-23 00:51:53 +0300 |
commit | b577649961239131e21288aa6b826a1e2bd92674 (patch) | |
tree | 35b49fcd9857242e7043a042b64e56f0045257a9 /test | |
parent | e06788800df2d0431c0821e1116406ff3a67226a (diff) |
When evaluating constant values load in UnreachableBlock consider
external jumps into load sequence.
Fixes #950
Diffstat (limited to 'test')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs | 73 | ||||
-rw-r--r-- | test/Mono.Linker.Tests.Cases/UnreachableBlock/SimpleConditionalProperty.cs | 1 |
2 files changed, 72 insertions, 2 deletions
diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs index 9a92ab742..2660b240d 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ComplexConditions.cs @@ -1,18 +1,46 @@ using System; using System.Reflection.Emit; using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; namespace Mono.Linker.Tests.Cases.UnreachableBlock { + [SetupCompileArgument ("/optimize-")] // Relying on debug csc behaviour public class ComplexConditions { - public static void Main() + public static void Main () { Test_1 (null); + Test_2 (9); } [Kept] +#if !NETCOREAPP [ExpectBodyModified] +#else + [ExpectedInstructionSequence (new [] { + "nop", + "ldarg.0", + "isinst", + "brtrue.s", + "call", + "pop", + "ldarg.0", + "isinst", + "ldnull", + "cgt.un", + "br.s", + "nop", + "br.s", + "ldc.i4.1", + "stloc.0", + "ldloc.0", + "brfalse.s", + "call", + "nop", + "ret" + })] +#endif static void Test_1 (object type) { if (type is Type || (IsDynamicCodeSupported && type is TypeBuilder)) @@ -20,6 +48,47 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock } [Kept] +#if !NETCOREAPP + [ExpectBodyModified] +#else + [ExpectedInstructionSequence (new [] { + "nop", + "call", + "stloc.1", + "ldloc.1", + "pop", + "ldc.i4.0", + "stloc.0", + "ldarg.0", + "ldc.i4.2", + "beq.s", + "ldarg.0", + "ldc.i4.3", + "ceq", + "br.s", + "ldc.i4.1", + "stloc.2", + "ldloc.2", + "brfalse.s", + "newobj", + "throw", + "newobj", + "throw" + })] +#endif + static void Test_2 (int a) + { + int zero; + if (IsDynamicCodeSupported) + zero = 0; + + if (a == 2 || a == 3) + throw new ArgumentException (); + + throw new ApplicationException (); + } + + [Kept] static bool IsDynamicCodeSupported { [Kept] get { @@ -29,7 +98,7 @@ namespace Mono.Linker.Tests.Cases.UnreachableBlock [Kept] static void Reached_1 () - { + { } } }
\ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/SimpleConditionalProperty.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/SimpleConditionalProperty.cs index f95a67a14..1b0eaad0d 100644 --- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/SimpleConditionalProperty.cs +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/SimpleConditionalProperty.cs @@ -5,6 +5,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata; namespace Mono.Linker.Tests.Cases.UnreachableBlock { // [SetupCSharpCompilerToUse ("csc")] + [SetupCompileArgument ("/optimize+")] public class SimpleConditionalProperty { public static void Main() |