GC Bridge: Make merge_cache more aggressive, less exact, faster
[mono.git] / mono / mini / branch-opts.c
index 7b2bedd56470c901f27cba63a015a2309c382c16..cab90f84d3de89b717e58beaf13e98419f440afa 100644 (file)
@@ -209,9 +209,11 @@ mono_replace_ins (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, MonoInst
 
                /* Multiple BBs */
 
-               /* Set region */
-               for (tmp = first_bb; tmp; tmp = tmp->next_bb)
+               /* Set region/real_offset */
+               for (tmp = first_bb; tmp; tmp = tmp->next_bb) {
                        tmp->region = bb->region;
+                       tmp->real_offset = bb->real_offset;
+               }
 
                /* Split the original bb */
                if (ins->next)
@@ -249,7 +251,8 @@ mono_replace_ins (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, MonoInst
                bb->has_array_access |= first_bb->has_array_access;
 
                /* Delete the links between the original bb and its successors */
-               tmp_bblocks = bb->out_bb;
+               tmp_bblocks = mono_mempool_alloc0 (cfg->mempool, sizeof (MonoBasicBlock*) * bb->out_count);
+               memcpy (tmp_bblocks, bb->out_bb, sizeof (MonoBasicBlock*) * bb->out_count);
                count = bb->out_count;
                for (i = 0; i < count; ++i)
                        mono_unlink_bblock (cfg, bb, tmp_bblocks [i]);