+
+ /* 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);
+