* mini-s390x.c, mini-s390x.h: Check for presence of long displacement
[mono.git] / mono / mini / dominators.c
index 735f404a964c42bdd4608462780927915c69e5fa..4ebf433eaef23e7e616a3a654648d37ad5fd653a 100644 (file)
@@ -73,7 +73,7 @@ compute_dominators (MonoCompile *m) {
 
 #ifdef DEBUG_DOMINATORS
        printf ("DTREE %s %d\n", mono_method_full_name (m->method, TRUE), 
-               ((MonoMethodNormal *)m->method)->header->num_clauses);
+               mono_method_get_header (m->method)->num_clauses);
        for (i = 0; i < m->num_bblocks; ++i) {
                bb = m->bblocks [i];
                printf ("BB%d: ", bb->block_num);
@@ -413,6 +413,7 @@ void
 mono_compute_natural_loops (MonoCompile *cfg)
 {
        int i, j, k;
+       int *bb_indexes;
 
        g_assert (!(cfg->comp_done & MONO_COMP_LOOPS));
 
@@ -460,7 +461,37 @@ mono_compute_natural_loops (MonoCompile *cfg)
        }
 
        cfg->comp_done |= MONO_COMP_LOOPS;
-       
+
+       /* Compute loop_body_start for each loop */
+       bb_indexes = g_new0 (int, cfg->num_bblocks);
+       {
+               MonoBasicBlock *bb;
+
+               for (i = 0, bb = cfg->bb_entry; bb; i ++, bb = bb->next_bb) {
+                       if (bb->dfn)
+                               bb_indexes [bb->dfn] = i;
+               }
+       }
+       for (i = 0; i < cfg->num_bblocks; ++i) {
+               if (cfg->bblocks [i]->loop_blocks) {
+                       /* The loop body start is the first bblock in the order they will be emitted */
+                       MonoBasicBlock *h = cfg->bblocks [i];
+                       MonoBasicBlock *body_start = h;
+                       GList *l;
+
+                       for (l = h->loop_blocks; l; l = l->next) {
+                               MonoBasicBlock *cb = (MonoBasicBlock *)l->data;
+
+                               if (cb->dfn && bb_indexes [cb->dfn] < bb_indexes [body_start->dfn]) {
+                                       body_start = cb;
+                               }
+                       }
+
+                       body_start->loop_body_start = 1;
+               }
+       }
+       g_free (bb_indexes);
+
 #ifdef DEBUG_NATURAL_LOOPS
        for (i = 0; i < cfg->num_bblocks; ++i) {
                if (cfg->bblocks [i]->loop_blocks) {