2006-06-12 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Mon, 12 Jun 2006 14:16:59 +0000 (14:16 -0000)
committerZoltan Varga <vargaz@gmail.com>
Mon, 12 Jun 2006 14:16:59 +0000 (14:16 -0000)
* mini.c (remove_block_if_useless): Do not remove the bblock immediately
after the end of a try bblock, to prevent asserts in mini_method_compile ().

* iltests.il: Add a test for the above.

svn path=/trunk/mono/; revision=61627

mono/mini/ChangeLog
mono/mini/iltests.il
mono/mini/mini.c

index 0f856608f5d786147ff2d93913cb212dbd7bf2a6..7d9e9f916838f4f60f72d6991eb75914c40030a6 100644 (file)
@@ -1,3 +1,10 @@
+2006-06-12  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini.c (remove_block_if_useless): Do not remove the bblock immediately
+       after the end of a try bblock, to prevent asserts in mini_method_compile ().
+
+       * iltests.il: Add a test for the above.
+
 2006-06-10  Zoltan Varga  <vargaz@gmail.com>
 
        * mini-ia64.c (mono_arch_lowering_pass): Remove some code duplication.
index 39c8f536f55796bcb79dc586648d56225c7e7914..f50606cf43d6ab93986abd23ca70fd205b8f7eef 100644 (file)
@@ -1041,4 +1041,30 @@ COND:   ldloc.0
        ret     
   }
 
+       .method public static void try_block_end_remove_if_useless () cil managed {
+           .maxstack  8
+
+           T_START:
+               ldstr   "Start"
+                       pop
+               leave.s COMPLETE
+           T1_END:
+
+           COMPLETE:
+               ret
+
+           F1_START:
+               ldstr   "Finally1"
+                       pop
+               endfinally
+           F1_END:
+
+           .try T_START to T1_END finally handler F1_START to F1_END
+       }
+
+       .method public static int32 test_0_try_block_end_remove_if_useless () cil managed {
+               call void class Tests::try_block_end_remove_if_useless ()
+               ldc.i4.0
+               ret
+       }
 }
index f5bdb78a2ee8652582567a5521c17634162c28c4..2f2ef8b44bdf94c36d1c57b2ed1b91530b3793e8 100644 (file)
@@ -8762,6 +8762,13 @@ remove_block_if_useless (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *p
        if ((previous_bb == cfg->bb_entry) && (bb->next_bb != target_bb)) {
                return FALSE;
        }
+
+       /* 
+        * Do not touch BBs following a try block as the code in 
+        * mini_method_compile needs them to compute the length of the try block.
+        */
+       if (MONO_BBLOCK_IS_IN_REGION (previous_bb, MONO_REGION_TRY))
+               return FALSE;
        
        /* Check that there is a target BB, and that bb is not an empty loop (Bug 75061) */
        if ((target_bb != NULL) && (target_bb != bb)) {