diff options
author | Marek Safar <marek.safar@gmail.com> | 2022-05-20 20:59:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-20 20:59:58 +0300 |
commit | b0479355a71752de103a2aac89af5cdcdb0455ad (patch) | |
tree | 5ee42f59e7034f89c55d306741116fe2c8d350b6 /test | |
parent | 55c9a27e7b1c9c76ffb1a0454e5e79ded646be02 (diff) |
Add retargeting switch labels to ILProcessor (#2801)
Fixes #2799
Diffstat (limited to 'test')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/UnreachableBlock/ReplacedJumpTarget.cs | 77 | ||||
-rw-r--r-- | test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs | 5 |
2 files changed, 82 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/ReplacedJumpTarget.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ReplacedJumpTarget.cs new file mode 100644 index 000000000..5c7ee375f --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/ReplacedJumpTarget.cs @@ -0,0 +1,77 @@ +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+")] + [SetupLinkerArgument ("--enable-opt", "ipconstprop")] + public class ReplacedJumpTarget + { + public static void Main () + { + Test_1 (int.Parse ("91")); + } + + [Kept] + [ExpectedInstructionSequence (new[] { + "ldarg.0", + "ldc.i4.2", + "sub", + "switch (il_2a, il_2c, il_2e, il_30, il_32)", + "ldarg.0", + "ldc.i4.s 0x32", + "sub", + "ldc.i4.5", + "ble.un.s il_34", + "ldarg.0", + "ldc.i4.s 0x64", + "bne.un.s il_36", + "ldc.i4.1", + "ret", + "ldc.i4.2", + "ret", + "ldc.i4.2", + "ret", + "ldc.i4.2", + "ret", + "ldc.i4.5", + "ret", + "ldc.i4.5", + "ret", + "ldc.i4.5", + "ret", + "ldc.i4.2", + "ret", + })] + static int Test_1 (int value) + { + switch (value) { + case 100: + return 1; + case 2: + return Value; + case 3: + return Value; + case 4: + return Value; + case 5: + return 5; + case 6: + return 5; + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + return 5; + } + + return 2; + } + + static int Value => 2; + } +}
\ No newline at end of file diff --git a/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs b/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs index e6a9a6012..630dfef12 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs @@ -490,6 +490,11 @@ namespace Mono.Linker.Tests.TestCasesRunner if (instr.Operand is Instruction target) return $"{instr.OpCode.ToString ()} il_{target.Offset.ToString ("x")}"; + if (instr.Operand is Instruction[] targets) { + string stargets = string.Join (", ", targets.Select (l => $"il_{l.Offset.ToString ("x")}")); + return $"{instr.OpCode.ToString ()} ({stargets})"; + } + break; } |