2009-12-03 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Thu, 3 Dec 2009 21:07:07 +0000 (21:07 -0000)
committerZoltan Varga <vargaz@gmail.com>
Thu, 3 Dec 2009 21:07:07 +0000 (21:07 -0000)
* 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
mono/mini/exceptions.cs
mono/mini/mini.c

index 0154d272c18d276f65920d10eba304d74927f779..661b1145e7f7fe4087a5a20dd7ccc6149864daad 100644 (file)
@@ -1,3 +1,11 @@
+2009-12-03  Zoltan Varga  <vargaz@gmail.com>
+
+       * 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  <munroesj@us.ibm.com>
 
        This patch is contributed under the terms of the MIT/X11 license
index fefe52dc5fb316de8ea4f684700177007807c24d..22cffb1711a3dac6203ad5aed914ccb82d8a0b12 100644 (file)
@@ -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;
+       }
 }
 
index df985a3c3936844dfc7ff2de27b9d2379becf4d5..1bb8d72af58c5c57cb1375dfc5231273691f4e53 100644 (file)
@@ -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
+        * <something which throws>
+        * 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;