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