[cfgdump] insert NOP in empty basic blocks in order to not confuse graph dumper
authorBernhard Urban <bernhard.urban@xamarin.com>
Thu, 2 Jun 2016 22:23:36 +0000 (15:23 -0700)
committerBernhard Urban <bernhard.urban@xamarin.com>
Thu, 9 Jun 2016 20:32:36 +0000 (13:32 -0700)
mono/mini/mini.c

index af779644801d323dcd3ca945e6abe73c0aba5ef4..777eae0c02e708df689bfb4bf8e1e95d556ad9b7 100644 (file)
@@ -2896,6 +2896,17 @@ is_open_method (MonoMethod *method)
        return FALSE;
 }
 
+static void mono_insert_nop_in_empty_bb (MonoCompile *cfg)
+{
+       MonoBasicBlock *bb;
+       for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
+               if (bb->code)
+                       continue;
+               MonoInst *nop;
+               MONO_INST_NEW (cfg, nop, OP_NOP);
+               MONO_ADD_INS (bb, nop);
+       }
+}
 static void
 mono_create_gc_safepoint (MonoCompile *cfg, MonoBasicBlock *bblock)
 {
@@ -3499,6 +3510,11 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
        MONO_TIME_TRACK (mono_jit_stats.jit_method_to_ir, i = mono_method_to_ir (cfg, method_to_compile, NULL, NULL, NULL, NULL, 0, FALSE));
        mono_cfg_dump_ir (cfg, "method-to-ir");
 
+       if (cfg->gdump_ctx != NULL) {
+               mono_insert_nop_in_empty_bb (cfg);
+               mono_cfg_dump_ir (cfg, "mono_insert_nop_in_empty_bb");
+       }
+
        if (i < 0) {
                if (try_generic_shared && cfg->exception_type == MONO_EXCEPTION_GENERIC_SHARING_FAILED) {
                        if (compile_aot) {