obstack access function
[libfirm] / ir / ana / irscc.c
1 /* Copyright (C) 2002 by Universitaet Karlsruhe
2 * All rights reserved.
3 *
4 * Authors:  Goetz Lindenmaier
5 *
6 * irscc.c  Computing the strongly connected regions and building
7 * backedge/loop datastructures.
8 *
9 */
10
11 /* $Id$ */
12
13 #include <string.h>
14
15 #include "irloop_t.h"
16 #include "irnode.h"
17 #include "irgraph_t.h"
18 #include "array.h"
19 #include "xprintf.h"
20 #include "irgwalk.h"
21 #include "irprog.h"
22
23 ir_graph *outermost_ir_graph;      /* The outermost graph the scc is computed
24                                       for */
25 static ir_loop *current_loop;      /* Current loop construction is working
26                                       on. */
27 static int loop_node_cnt = 0;      /* Counts the number of allocated loop nodes.
28                                       Each loop node gets a unique number.
29                                       What for? ev. remove. @@@ */
30 static int current_dfn = 1;        /* Counter to generate depth first numbering
31                                       of visited nodes.  */
32
33 /**********************************************************************/
34 /* Node attributes needed for the construction.                      **/
35 /**********************************************************************/
36
37 typedef struct scc_info {
38   bool in_stack;         /* Marks whether node is on the stack. */
39   int dfn;               /* Depth first search number. */
40   int uplink;            /* dfn number of ancestor. */
41   ir_loop *loop;         /* Refers to the containing loop. */
42   /*
43       struct section *section;
44       xset def;
45       xset use;
46   */
47 } scc_info;
48
49 static INLINE scc_info* new_scc_info(void) {
50   scc_info *info = obstack_alloc (outermost_ir_graph->obst, sizeof (scc_info));
51   memset (info, 0, sizeof (scc_info));
52   return info;
53 }
54
55 static INLINE void
56 mark_irn_in_stack (ir_node *n) {
57   assert(get_irn_link(n));
58   ((scc_info *)get_irn_link(n))->in_stack = true;
59 }
60
61 static INLINE void
62 mark_irn_not_in_stack (ir_node *n) {
63   assert(get_irn_link(n));
64   ((scc_info *)get_irn_link(n))->in_stack = false;
65 }
66
67 static INLINE bool
68 irn_is_in_stack (ir_node *n) {
69   assert(get_irn_link(n));
70   return ((scc_info *)get_irn_link(n))->in_stack;
71 }
72
73 static INLINE void
74 set_irn_uplink (ir_node *n, int uplink) {
75   assert(get_irn_link(n));
76   ((scc_info *)get_irn_link(n))->uplink = uplink;
77 }
78
79 static INLINE int
80 get_irn_uplink (ir_node *n) {
81   assert(get_irn_link(n));
82   return ((scc_info *)get_irn_link(n))->uplink;
83 }
84
85 static INLINE void
86 set_irn_dfn (ir_node *n, int dfn) {
87   if (! get_irn_link(n)) { DDMN(n); DDME(get_irg_ent(current_ir_graph));}
88   assert(get_irn_link(n));
89   ((scc_info *)get_irn_link(n))->dfn = dfn;
90 }
91
92 static INLINE int
93 get_irn_dfn (ir_node *n) {
94   assert(get_irn_link(n));
95   return ((scc_info *)get_irn_link(n))->dfn;
96 }
97
98 /* Uses temporary information to set the loop */
99 static INLINE void
100 set_irn_loop_tmp (ir_node *n, ir_loop* loop) {
101   assert(get_irn_link(n));
102   ((scc_info *)get_irn_link(n))->loop = loop;
103 }
104
105 #if 0
106 /* Uses temporary information to get the loop */
107 static INLINE ir_loop *
108 get_irn_loop_tmp (ir_node *n) {
109   assert(get_irn_link(n));
110   return ((scc_info *)get_irn_link(n))->loop;
111 }
112 #endif
113
114 static ir_loop *find_nodes_loop (ir_node *n, ir_loop *l) {
115   int i;
116   ir_loop *res = NULL;
117
118   /* Test whether n is contained in this loop. */
119   for (i = 0; i < get_loop_n_nodes(l); i++)
120     if (n == get_loop_node(l, i)) return l;
121
122   /* Is this a leave in the loop tree? If so loop not found. */
123   if (get_loop_n_sons(l) == 0) return NULL;
124
125   /* Else descend in the loop tree. */
126   for (i = 0; i < get_loop_n_sons(l); i++) {
127     res = find_nodes_loop(n, get_loop_son(l, i));
128     if (res) break;
129   }
130   return res;
131 }
132
133 /* @@@ temporary implementation, costly!!! */
134 ir_loop * get_irn_loop(ir_node *n) {
135   ir_loop *l = get_irg_loop(current_ir_graph);
136   l = find_nodes_loop(n, l);
137   return l;
138 }
139
140 /**********************************************************************/
141 /* A stack.                                                          **/
142 /**********************************************************************/
143
144 static ir_node **stack = NULL;
145 static int tos = 0;                /* top of stack */
146
147 static INLINE void init_stack(void) {
148   if (stack) {
149     ARR_RESIZE (ir_node *, stack, 1000);
150   } else {
151     stack = NEW_ARR_F (ir_node *, 1000);
152   }
153   tos = 0;
154 }
155
156 #if 0
157 static INLINE void free_stack(void) {
158   DEL_ARR_F(stack);
159   stack = NULL;
160   tos = 0;
161 }
162 #endif
163
164 static INLINE void
165 push (ir_node *n)
166 {
167   //DDMN(n);
168
169   if (tos == ARR_LEN (stack)) {
170     int nlen = ARR_LEN (stack) * 2;
171     ARR_RESIZE (ir_node *, stack, nlen);
172   }
173   stack [tos++] = n;
174   mark_irn_in_stack(n);
175 }
176
177 static INLINE ir_node *
178 pop (void)
179 {
180   ir_node *n = stack[--tos];
181   mark_irn_not_in_stack(n);
182   return n;
183 }
184
185 /* The nodes up to n belong to the current loop.
186    Removes them from the stack and adds them to the current loop. */
187 static INLINE void
188 pop_scc_to_loop (ir_node *n)
189 {
190   ir_node *m;
191
192   for (;;) {
193     m = pop();
194     set_irn_dfn(m, loop_node_cnt);
195     loop_node_cnt++;
196     add_loop_node(current_loop, m);
197     set_irn_loop_tmp(m, current_loop);
198     if (m==n) break;
199   }
200 }
201
202 /* Removes and unmarks all nodes up to n from the stack.
203    The nodes must be visited once more to assign them to a scc. */
204 static INLINE void
205 pop_scc_unmark_visit (ir_node *n)
206 {
207   ir_node *m = NULL;
208
209   while (m != n) {
210     m = pop();
211     set_irn_visited(m, 0);
212   }
213 }
214
215 /**********************************************************************/
216 /* The loop datastructure.                                           **/
217 /**********************************************************************/
218
219 /* Allocates a new loop as son of current_loop.  Sets current_loop
220    to the new loop and returns the father. */
221 static ir_loop *new_loop (void) {
222   ir_loop *father, *son;
223
224   father = current_loop;
225
226   son = (ir_loop *) obstack_alloc (outermost_ir_graph->obst, sizeof (ir_loop));
227   memset (son, 0, sizeof (ir_loop));
228   son->kind = k_ir_loop;
229   son->sons = NEW_ARR_F (ir_loop *, 0);
230   son->nodes = NEW_ARR_F (ir_node *, 0);
231   if (father) {
232     son->outer_loop = father;
233     add_loop_son(father, son);
234     son->depth = father->depth+1;
235   } else {  /* The root loop */
236     son->outer_loop = son;
237     son->depth = 0;
238   }
239
240   current_loop = son;
241   return father;
242 }
243
244 #if 0
245 /* Finishes the datastructures, copies the arrays to the obstack
246    of current_ir_graph. */
247 static void mature_loop (ir_loop *loop) {
248   ir_loop **new_sons;
249
250   new_sons = NEW_ARR_D (ir_loop *, current_ir_graph->obst, ARR_LEN(loop->sons));
251   memcpy (new_sons, loop->sons, sizeof (ir_loop *) * ARR_LEN(loop->sons));
252   DEL_ARR_F(loop->sons);
253   loop->sons = new_sons;
254 }
255 #endif
256
257 /* Returns outer loop, itself if outermost. */
258 ir_loop *get_loop_outer_loop (ir_loop *loop) {
259   assert(loop && loop->kind == k_ir_loop);
260   return loop->outer_loop;
261 }
262
263 /* Returns nesting depth of this loop */
264 int get_loop_depth (ir_loop *loop) {
265   assert(loop); assert(loop->kind == k_ir_loop);
266   return loop->depth;
267 }
268
269 /* Returns the number of inner loops */
270 int      get_loop_n_sons (ir_loop *loop) {
271   assert(loop && loop->kind == k_ir_loop);
272   return ARR_LEN(loop->sons);
273 }
274 ir_loop *get_loop_son (ir_loop *loop, int pos) {
275   assert(loop && loop->kind == k_ir_loop);
276   return loop->sons[pos];
277 }
278 static INLINE void
279 add_loop_son(ir_loop *loop, ir_loop *son) {
280   assert(loop && loop->kind == k_ir_loop);
281   ARR_APP1 (ir_loop *, loop->sons, son);
282 }
283
284 /* Returns the number of nodes in the loop */
285 int      get_loop_n_nodes (ir_loop *loop) {
286   assert(loop); assert(loop->kind == k_ir_loop);
287   return ARR_LEN(loop->nodes);
288 }
289 ir_node *get_loop_node (ir_loop *loop, int pos) {
290   assert(loop && loop->kind == k_ir_loop);
291   return loop->nodes[pos];
292 }
293 static INLINE void
294 add_loop_node(ir_loop *loop, ir_node *n) {
295   assert(loop && loop->kind == k_ir_loop);
296   ARR_APP1 (ir_node *, loop->nodes, n);
297 }
298
299 /* The outermost loop is remarked in the surrounding graph. */
300 void     set_irg_loop(ir_graph *irg, ir_loop *loop) {
301   assert(irg);
302   irg->loop = loop;
303 }
304 ir_loop *get_irg_loop(ir_graph *irg) {
305   assert(irg);
306   return irg->loop;
307 }
308
309 /**********************************************************************/
310 /* Constructing and destructing the loop/backedge information.       **/
311 /**********************************************************************/
312
313 /* Initialization steps. **********************************************/
314
315 static INLINE void
316 init_node (ir_node *n, void *env) {
317   set_irn_link (n, new_scc_info());
318   clear_backedges(n);
319 #if 0
320   /* Also init nodes not visible in intraproc_view. */
321     /* @@@ init_node is called for too many nodes -- this wastes memory!.
322        The mem is not lost as its on the obstack. */
323   if (get_irn_op(n) == op_Filter) {
324     for (i = 0; i < get_Filter_n_cg_preds(n); i++)
325       init_node(get_Filter_cg_pred(n, i), NULL);
326   }
327   if (get_irn_op(n) == op_Block) {
328     for (i = 0; i < get_Block_cg_n_cfgpreds(n); i++) {
329       init_node(get_Block_cg_cfgpred(n, i), NULL);
330     }
331   }
332   /* The following pattern matches only after a call from above pattern. */
333   if ((get_irn_op(n) == op_Proj) /*&& (get_Proj_proj(n) == 0)*/) {
334     /* @@@ init_node is called for every proj -- this wastes memory!.
335        The mem is not lost as its on the obstack. */
336     ir_node *cb = get_Proj_pred(n);
337     if ((get_irn_op(cb) == op_CallBegin) ||
338         (get_irn_op(cb) == op_EndReg) ||
339         (get_irn_op(cb) == op_EndExcept)) {
340       init_node(cb, NULL);
341       init_node(get_nodes_Block(cb), NULL);
342     }
343 #endif
344 }
345
346 static INLINE void
347 init_scc (ir_graph *irg) {
348   current_dfn = 1;
349   loop_node_cnt = 0;
350   init_stack();
351   irg_walk_graph (irg, init_node, NULL, NULL);
352   /*
353   irg_walk (irg, link_to_reg_end, NULL, NULL);
354   */
355 }
356
357 static INLINE void
358 init_ip_scc (void) {
359   current_dfn = 1;
360   loop_node_cnt = 0;
361   init_stack();
362   cg_walk (init_node, NULL, NULL);
363 }
364
365 #if 0
366 Works, but is inefficient.
367 static INLINE void
368 init_ip_scc (void) {
369   int i;
370   interprocedural_view = 1;
371   current_dfn = 1;
372   loop_node_cnt = 0;
373   init_stack();
374   for (i = 0; i < get_irp_n_irgs(); i++) {
375     current_ir_graph = get_irp_irg(i);
376     irg_walk_graph (current_ir_graph, init_node, NULL, NULL);
377     /* @@@ decrease max_visited to avoide double walks */
378   }
379 }
380 #endif
381
382 /* Condition for breaking the recursion. */
383 static bool is_outermost_Start(ir_node *n) {
384   /* Test whether this is the outermost Start node.  If so
385      recursion must end. */
386   if ((get_irn_op(n) == op_Block)     &&
387       (get_Block_n_cfgpreds(n) == 1)  &&
388       (get_irn_op(skip_Proj(get_Block_cfgpred(n, 0))) == op_Start) &&
389       (get_nodes_Block(skip_Proj(get_Block_cfgpred(n, 0))) == n)) {
390     return true;
391   }
392 #if 0
393   /*  @@@ Bad condition:
394       not possible in interprocedural view as outermost_graph is
395       not necessarily the only with a dead-end start block.
396       Besides current_ir_graph is not set properly. */
397   if ((get_irn_op(n) == op_Block) &&
398       (n == get_irg_start_block(current_ir_graph))) {
399     if ((!interprocedural_view)  ||
400         (current_ir_graph == outermost_ir_graph))
401       return true;
402   }
403 #endif
404   return false;
405 }
406
407 /* Don't walk from nodes to blocks except for Control flow operations. */
408 static INLINE int
409 get_start_index(ir_node *n) {
410   if (is_cfop(n) || is_fragile_op(n) || get_irn_op(n) == op_Start)
411     return -1;
412   else
413     return 0;
414 }
415
416 /* Returns current_ir_graph and set it to the irg of predecessor index
417    of node n. */
418 static INLINE ir_graph *
419 switch_irg (ir_node *n, int index) {
420   ir_graph *old_current = current_ir_graph;
421
422   if (interprocedural_view) {
423     /* Only Filter and Block nodes can have predecessors in other graphs. */
424     if (get_irn_op(n) == op_Filter)
425       n = get_nodes_Block(n);
426     if (get_irn_op(n) == op_Block) {
427       ir_node *cfop = skip_Proj(get_Block_cfgpred(n, index));
428       if (is_ip_cfop(cfop)) {
429         current_ir_graph = get_irn_irg(cfop);
430         set_irg_visited(current_ir_graph, get_max_irg_visited());
431       }
432     }
433   }
434
435   return old_current;
436 }
437
438 /* Walks up the stack passing n and then finding the node
439    where we walked into the irg n is contained in.
440    Here we switch the irg. */
441 static ir_graph *
442 find_irg_on_stack (ir_node *n) {
443   ir_node *m;
444   ir_graph *old_current = current_ir_graph;
445   int i;
446
447   if (interprocedural_view) {
448     for (i = tos; i >= 0; i--) {
449       if (stack[i] == n) break;
450     }
451     if (i < 0) i = tos;
452
453     //printf(" Here\n");
454
455     assert (i >= 0);
456     for (; i >= 0; i--) {
457       m = stack[i];
458       //printf(" Visiting %d ", i); DDMN(m);
459       if (is_ip_cfop(m)) {
460         current_ir_graph = get_irn_irg(m);
461         break;
462       }
463       if (get_irn_op(m) == op_Filter) {
464         /* Find the corresponding ip_cfop */
465         ir_node *pred = stack[i+1];
466         int j;
467         for (j = 0; j < get_Filter_n_cg_preds(m); j++)
468           if (get_Filter_cg_pred(m, j) == pred) break;
469         if (j >= get_Filter_n_cg_preds(m))
470           /* It is a filter we didn't pass as the predecessors are marked. */
471           continue;
472         assert(get_Filter_cg_pred(m, j) == pred);
473         switch_irg(m, j);
474         break;
475       }
476     }
477   }
478
479   return old_current;
480 }
481
482 #if 0
483 static void test(ir_node *pred, ir_node *root, ir_node *this) {
484   int i;
485   if (get_irn_uplink(pred) >= get_irn_uplink(root)) return;
486
487   printf("this: %d ", get_irn_uplink(this)); DDMN(this);
488   printf("pred: %d ", get_irn_uplink(pred)); DDMN(pred);
489   printf("root: %d ", get_irn_uplink(root)); DDMN(root);
490
491   printf("tos: %d\n", tos);
492
493   for (i = tos; i >= 0; i--) {
494     ir_node *n = stack[i];
495     if (!n) continue;
496     printf(" uplink: %d, pos: %d ", get_irn_uplink(n), i); DDMN(n);
497   }
498 }
499 #endif
500
501 /* Returns true if n is a loop header, i.e., it is a Block, Phi
502    or Filter node and has predecessors within the loop and out
503    of the loop. */
504 static bool
505 is_head (ir_node *n, ir_node *root)
506 {
507   int i;
508   int some_outof_loop = 0,  some_in_loop = 0;
509
510   /* Test for legal loop header */
511   if (!((get_irn_op(n) == op_Block) ||
512         (get_irn_op(n) == op_Phi) ||
513         ((get_irn_op(n) == op_Filter) && interprocedural_view)))
514     return false;
515
516   if (!is_outermost_Start(n)) {
517     for (i = get_start_index(n); i < get_irn_arity(n); i++) {
518       ir_node *pred = get_irn_n(n, i);
519       assert(pred);
520       if (is_backedge(n, i)) continue;
521       if (!irn_is_in_stack(pred)) {
522         some_outof_loop = 1;
523       } else {
524         assert(get_irn_uplink(pred) >= get_irn_uplink(root));
525         some_in_loop = 1;
526       }
527     }
528   }
529   return some_outof_loop && some_in_loop;
530 }
531
532 /* Returns index of the predecessor with the smallest dfn number
533    greater-equal than limit. */
534 static int
535 smallest_dfn_pred (ir_node *n, int limit)
536 {
537   int i, index = -2, min = -1;
538
539   if (!is_outermost_Start(n)) {
540     for (i = get_start_index(n); i < get_irn_arity(n); i++) {
541       ir_node *pred = get_irn_n(n, i);
542       assert(pred);
543       if (is_backedge(n, i) || !irn_is_in_stack(pred)) continue;
544       if (get_irn_dfn(pred) >= limit
545         && (min == -1 || get_irn_dfn(pred) < min)) {
546         index = i;
547         min = get_irn_dfn(pred);
548       }
549     }
550   }
551   return index;
552 }
553
554 /* Returns index of the predecessor with the largest dfn number. */
555 static int
556 largest_dfn_pred (ir_node *n)
557 {
558   int i, index = -2, max = -1;
559
560   if (!is_outermost_Start(n)) {
561     for (i = get_start_index(n); i < get_irn_arity(n); i++) {
562       ir_node *pred = get_irn_n(n, i);
563       if (is_backedge (n, i) || !irn_is_in_stack(pred)) continue;
564       if (get_irn_dfn(pred) > max) {
565         index = i;
566         max = get_irn_dfn(pred);
567       }
568     }
569   }
570   return index;
571 }
572
573 /* Searches the stack for possible loop heads.  Tests these for backedges.
574    If it finds a head with an unmarked backedge it marks this edge and
575    returns the tail of the loop.
576    If it finds no backedge returns NULL. */
577 static ir_node *
578 find_tail (ir_node *n) {
579   ir_node *m;
580   int i, res_index = -2;
581
582   /*
583     if (!icfg && rm_cyclic_phis && remove_cyclic_phis (n)) return NULL;
584   */
585
586   m = stack[tos-1];
587   if (is_head (m, n)) {
588     res_index = smallest_dfn_pred(m, 0);
589     if ((res_index == -2) &&  /* no smallest dfn pred found. */
590         (n == m))
591       return NULL;
592   } else {
593     if (m == n) return NULL;
594     for (i = tos-2; ; --i) {
595       m = stack[i];
596       if (is_head (m, n)) {
597         res_index = smallest_dfn_pred (m, get_irn_dfn(m) + 1);
598         if (res_index == -2)  /* no smallest dfn pred found. */
599           res_index = largest_dfn_pred (m);
600         break;
601       }
602     }
603   }
604   assert (res_index > -2);
605
606   set_backedge (m, res_index);
607   return is_outermost_Start(n) ? NULL : get_irn_n(m, res_index);
608 }
609
610
611 /* The core algorithm. *****************************************/
612
613 static void scc (ir_node *n) {
614   int i;
615   ir_graph *rem;
616
617   if (irn_visited(n)) return;
618   mark_irn_visited(n);
619   //printf("mark: %d ", get_irn_visited(n)); DDMN(n);
620   //DDME(get_irg_ent(current_ir_graph));
621
622   /* Initialize the node */
623   set_irn_dfn(n, current_dfn);      /* Depth first number for this node */
624   set_irn_uplink(n, current_dfn);   /* ... is default uplink. */
625   set_irn_loop_tmp(n, NULL);
626   current_dfn ++;
627
628   /* What's this good for?
629   n->ana.scc.section = NULL;
630   */
631
632   push(n);
633
634   if (!is_outermost_Start(n)) {
635     for (i = get_start_index(n); i < get_irn_arity(n); i++) {
636       ir_node *m;
637       if (is_backedge(n, i)) continue;
638
639       m = get_irn_n(n, i); //get_irn_ip_pred(n, i);
640       if ((!m) || (get_irn_op(m) == op_Unknown)) continue;
641       scc (m);
642       //return_recur(n, i);
643
644       if (irn_is_in_stack(m)) {
645         /* Uplink of m is smaller if n->m is a backedge.
646            Propagate the uplink to mark the loop. */
647         if (get_irn_uplink(m) < get_irn_uplink(n))
648           set_irn_uplink(n, get_irn_uplink(m));
649       }
650     }
651   }
652   if (get_irn_dfn(n) == get_irn_uplink(n)) {
653     /* This condition holds for the node with the incoming backedge. */
654     ir_node *tail = find_tail(n);
655     if (tail) {
656       /* We found a new loop! */
657       ir_loop *l = new_loop();
658       /* Remove the loop from the stack ... */
659       pop_scc_unmark_visit (n);
660       /* and recompute it in a better order; and so that it goes into
661          the new loop. */
662       rem = find_irg_on_stack(tail);
663       scc (tail);
664       current_ir_graph = rem;
665
666       assert (irn_visited(n));
667
668       current_loop = l;
669     } else {
670       pop_scc_to_loop(n);
671     }
672   }
673 }
674
675 /* Constructs backedge information for irg. In interprocedural view constructs
676    backedges for all methods called by irg, too. */
677 void construct_backedges(ir_graph *irg) {
678   ir_graph *rem = current_ir_graph;
679   ir_loop *head_rem;
680   int i;
681
682   assert(!interprocedural_view &&
683          "not implemented, use construct_ip_backedges");
684
685   current_ir_graph = irg;
686   outermost_ir_graph = irg;
687
688   init_scc(irg);
689
690   current_loop = NULL;
691   new_loop();  /* sets current_loop */
692   head_rem = current_loop; /* Just for assertion */
693
694   if (interprocedural_view) {
695     set_irg_visited(irg, inc_max_irg_visited());
696     init_ip_walk ();
697   } else {
698     inc_irg_visited(irg);
699   }
700
701   scc(get_irg_end(irg));
702   for (i = 0; i < get_End_n_keepalives(get_irg_end(irg)); i++)
703     scc(get_End_keepalive(get_irg_end(irg), i));
704
705   if (interprocedural_view) finish_ip_walk();
706
707   assert(head_rem == current_loop);
708   set_irg_loop(irg, current_loop);
709   assert(get_irg_loop(irg)->kind == k_ir_loop);
710   /*
711   irg->loops = current_loop;
712   if (icfg == 1) {
713     int count = 0;
714     int depth = 0;
715     count_loop (the_loop, &count, &depth);
716     }
717   }
718   */
719   current_ir_graph = rem;
720 }
721
722
723
724 void construct_ip_backedges (void) {
725   ir_graph *rem = current_ir_graph;
726   int rem_ipv = interprocedural_view;
727   int i, j;
728
729   outermost_ir_graph = get_irp_main_irg();
730
731   init_ip_scc();
732
733   current_loop = NULL;
734   new_loop();  /* sets current_loop */
735   interprocedural_view = 1;
736
737   inc_max_irg_visited();
738   for (i = 0; i < get_irp_n_irgs(); i++)
739     set_irg_visited(get_irp_irg(i), get_max_irg_visited());
740
741   for (i = 0; i < get_irp_n_irgs(); i++) {
742     ir_node *sb;
743     current_ir_graph = get_irp_irg(i);
744     //DDME(get_irg_ent(current_ir_graph));
745     /* Find real entry points */
746     sb = get_irg_start_block(current_ir_graph);
747     if ((get_Block_n_cfgpreds(sb) > 1) ||
748         (get_nodes_Block(get_Block_cfgpred(sb, 0)) != sb)) continue;
749     //    printf("running scc for "); DDME(get_irg_ent(current_ir_graph));
750     /* Compute scc for this graph */
751     outermost_ir_graph = current_ir_graph;
752     set_irg_visited(outermost_ir_graph, get_max_irg_visited());
753     scc(get_irg_end(current_ir_graph));
754     for (j = 0; j < get_End_n_keepalives(get_irg_end(outermost_ir_graph)); j++)
755       scc(get_End_keepalive(get_irg_end(outermost_ir_graph), j));
756   }
757
758   set_irg_loop(outermost_ir_graph, current_loop);
759   assert(get_irg_loop(outermost_ir_graph)->kind == k_ir_loop);
760
761   current_ir_graph = rem;
762   interprocedural_view = rem_ipv;
763 }