[llvm] Make sure the initlocals_bb is not treated as part of a try block if one start...
authorZoltan Varga <vargaz@gmail.com>
Sat, 8 Oct 2016 00:42:32 +0000 (20:42 -0400)
committerGitHub <noreply@github.com>
Sat, 8 Oct 2016 00:42:32 +0000 (20:42 -0400)
mono/mini/generics.cs
mono/mini/gshared.cs
mono/mini/method-to-ir.c
mono/mini/mini-llvm.c

index 80638b5048e6edf80854c7509ee3b7d18292cd5c..018619449191a8cf24899b7d1cba6f55519a85d0 100644 (file)
@@ -1272,7 +1272,6 @@ class Tests
                c.throw_catch_t ();
                return 0;
        }
-
 }
 
 #if !__MOBILE__
index 88f8c2ebb22b780a3c461daf2d8b62e6370f3e68..4456aaeb48aa2dbdbfe285762f8f46ff9c0b35a4 100644 (file)
@@ -1907,6 +1907,15 @@ public class Tests
                bool success = zz == 0xAAAAAAAAAAAAAAAA;
                return success ? 20 : 1;
        }
+
+       void gsharedvt_try_at_offset_0<T> (ref T disposable)
+               where T : class, IDisposable {
+                       try {
+                               disposable.Dispose ();
+                       } finally {
+                               disposable = null;
+                       }
+               }
 }
 
 // #13191
index 95b0002ea9136a17b83300f6f8e8f173bc2418cf..0929e7dc70050bcb549e1fd4fd4cb898d2fdbca2 100644 (file)
@@ -8479,7 +8479,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
        /* we use a separate basic block for the initialization code */
        NEW_BBLOCK (cfg, init_localsbb);
-       cfg->bb_init = init_localsbb;
+       if (cfg->method == method)
+               cfg->bb_init = init_localsbb;
        init_localsbb->real_offset = cfg->real_offset;
        start_bblock->next_bb = init_localsbb;
        init_localsbb->next_bb = cfg->cbb;
@@ -13685,7 +13686,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
        if (cfg->method == method) {
                MonoBasicBlock *bb;
                for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
-                       bb->region = mono_find_block_region (cfg, bb->real_offset);
+                       if (bb == cfg->bb_init)
+                               bb->region = -1;
+                       else
+                               bb->region = mono_find_block_region (cfg, bb->real_offset);
                        if (cfg->spvars)
                                mono_create_spvar_for_region (cfg, bb->region);
                        if (cfg->verbose_level > 2)
index 54873523202042720ff13d345b428e48f2bbab1e..249a5d93b8937da0502f1fa1b384bd9552e447ca 100644 (file)
@@ -1740,6 +1740,8 @@ get_handler_clause (MonoCompile *cfg, MonoBasicBlock *bb)
 static MonoExceptionClause *
 get_most_deep_clause (MonoCompile *cfg, EmitContext *ctx, MonoBasicBlock *bb)
 {
+       if (bb == cfg->bb_init)
+               return NULL;
        // Since they're sorted by nesting we just need
        // the first one that the bb is a member of
        for (int i = 0; i < cfg->header->num_clauses; i++) {