From a50933644db48a8b85a2a166c7864cb4bac9e1db Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Thu, 3 Dec 2009 21:07:07 +0000 Subject: [PATCH] 2009-12-03 Zoltan Varga * mini.c (mini_method_compile): Call handle_exception_clauses earlier so the local optimization passes can take its result into account. Fixes #559876. * exceptions.cs: Add a test. svn path=/trunk/mono/; revision=147603 --- mono/mini/ChangeLog | 8 ++++++++ mono/mini/exceptions.cs | 22 ++++++++++++++++++++++ mono/mini/mini.c | 23 ++++++++++++++--------- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog index 0154d272c18..661b1145e7f 100644 --- a/mono/mini/ChangeLog +++ b/mono/mini/ChangeLog @@ -1,3 +1,11 @@ +2009-12-03 Zoltan Varga + + * mini.c (mini_method_compile): Call handle_exception_clauses earlier so + the local optimization passes can take its result into account. Fixes + #559876. + + * exceptions.cs: Add a test. + 2009-01-24 Steven Munroe This patch is contributed under the terms of the MIT/X11 license diff --git a/mono/mini/exceptions.cs b/mono/mini/exceptions.cs index fefe52dc5fb..22cffb1711a 100644 --- a/mono/mini/exceptions.cs +++ b/mono/mini/exceptions.cs @@ -2529,5 +2529,27 @@ class Tests { catch { } } + + private static void do_raise () { + throw new System.Exception (); + } + + private static int int_func (int i) { + return i; + } + + // #559876 + public static int test_8_local_deadce_causes () { + int myb = 4; + + try { + myb = int_func (8); + do_raise(); + myb = int_func (2); + } catch (System.Exception) { + return myb; + } + return 0; + } } diff --git a/mono/mini/mini.c b/mono/mini/mini.c index df985a3c393..1bb8d72af58 100644 --- a/mono/mini/mini.c +++ b/mono/mini/mini.c @@ -3462,6 +3462,20 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool cfg->opt &= ~MONO_OPT_BRANCH; } + /* todo: remove code when we have verified that the liveness for try/catch blocks + * works perfectly + */ + /* + * Currently, this can't be commented out since exception blocks are not + * processed during liveness analysis. + * It is also needed, because otherwise the local optimization passes would + * delete assignments in cases like this: + * r1 <- 1 + * + * r1 <- 2 + */ + mono_liveness_handle_exception_clauses (cfg); + /*g_print ("numblocks = %d\n", cfg->num_bblocks);*/ if (!COMPILE_LLVM (cfg)) @@ -3666,15 +3680,6 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool g_list_free (regs); } - /* todo: remove code when we have verified that the liveness for try/catch blocks - * works perfectly - */ - /* - * Currently, this can't be commented out since exception blocks are not - * processed during liveness analysis. - */ - mono_liveness_handle_exception_clauses (cfg); - if (cfg->globalra) { MonoBasicBlock *bb; -- 2.25.1