From f04a83ca39e0a4bbf01bcd96236e3017e85390cf Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 5 Jan 2016 12:30:03 -0500 Subject: [llvm] Fix the linking of the bblocks containing endfinally instructions with the targets of leave instructions, previously we would link the first bblock instead of the last one. Fixes #37412. --- mono/mini/iltests.il | 21 +++++++++++++++++++++ mono/mini/method-to-ir.c | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mono/mini/iltests.il b/mono/mini/iltests.il index 35f1f8db28f..203584e1433 100644 --- a/mono/mini/iltests.il +++ b/mono/mini/iltests.il @@ -668,6 +668,27 @@ COND: ldloc.0 ret } + .method public static int32 test_5_endfinally_llvm_linking () il managed { + .maxstack 16 + + .try { + leave IL_0 + } + finally { + ldc.i4.0 + dup + brtrue L1 + pop + br L2 + L1: + pop + L2: + endfinally + } + IL_0: ldc.i4.5 + ret + } + .method public static int32 test_0_conv_ovf_i8_neg () il managed { .maxstack 16 diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index a1dc9fbc994..795fee2ef9f 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -12335,8 +12335,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b /* * Link the finally bblock with the target, since it will * conceptually branch there. - * FIXME: Have to link the bblock containing the endfinally. */ + GET_BBLOCK (cfg, tblock, cfg->cil_start + clause->handler_offset + clause->handler_len - 1); GET_BBLOCK (cfg, target_bb, target); link_bblock (cfg, tblock, target_bb); } -- cgit v1.2.3