Make fehler159 compilable.
[libfirm] / ir / ana / irouts.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Compute and access out edges (also called def-use edges).
23  * @author   Goetz Lindenmaier, Michael Beck
24  * @date     1.2002
25  * @version  $Id$
26  */
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #ifdef HAVE_STRING_H
32 #include <string.h>
33 #endif
34
35 #include "xmalloc.h"
36 #include "irouts.h"
37 #include "irnode_t.h"
38 #include "irgraph_t.h"
39 #include "irprog_t.h"
40 #include "irgwalk.h"
41 #include "irtools.h"
42 #include "irprintf.h"
43 #include "error.h"
44
45 #ifdef DEBUG_libfirm
46 /* Note:  ir_node.out_valid and ir_graph.n_outs are only present when DEBUG_libfirm is defined */
47 /* Accesses to out_valid and n_outs are fenced out to avoid breakage
48    when compiling with neither DEBUG_libfirm or NDEBUG defined */
49 #endif /* defined DEBUG_libfirm */
50
51 /*--------------------------------------------------------------------*/
52 /** Accessing the out datastructures                                 **/
53 /*--------------------------------------------------------------------*/
54
55 #ifdef DEBUG_libfirm
56 /** Clear the outs of a node */
57 static void reset_outs(ir_node *node, void *unused) {
58         (void) unused;
59         node->out       = NULL;
60         node->out_valid = 0;
61 }
62 #endif
63
64 int get_irn_outs_computed(const ir_node *node)
65 {
66         return node->out != NULL;
67 }
68
69 /* returns the number of successors of the node: */
70 int get_irn_n_outs(const ir_node *node) {
71         assert(node && node->kind == k_ir_node);
72 #ifdef DEBUG_libfirm
73         /* assert(node->out_valid); */
74 #endif /* defined DEBUG_libfirm */
75         /* we misuse the first for the size info of the out array */
76         return node->out[0].pos;
77 }
78
79 /* Access successor n */
80 ir_node *get_irn_out(const ir_node *def, int pos) {
81         assert(pos >= 0 && pos < get_irn_n_outs(def));
82 #ifdef DEBUG_libfirm
83         /* assert(def->out_valid); */
84 #endif /* defined DEBUG_libfirm */
85         return def->out[pos+1].use;
86 }
87
88 /* Access successor n */
89 ir_node *get_irn_out_ex(const ir_node *def, int pos, int *in_pos) {
90         assert(pos >= 0 && pos < get_irn_n_outs(def));
91 #ifdef DEBUG_libfirm
92         /* assert(def->out_valid); */
93 #endif /* defined DEBUG_libfirm */
94         *in_pos = def->out[pos+1].pos;
95         return def->out[pos+1].use;
96 }
97
98 void set_irn_out(ir_node *def, int pos, ir_node *use, int in_pos) {
99         assert(def && use);
100         assert(pos >= 0 && pos < get_irn_n_outs(def));
101 #ifdef DEBUG_libfirm
102         def->out_valid = 1;          /* assume that this function is used correctly */
103 #endif /* defined DEBUG_libfirm */
104         def->out[pos+1].use = use;
105         def->out[pos+1].pos = in_pos;
106 }
107
108 /* Return the number of control flow successors, ignore keep-alives. */
109 int get_Block_n_cfg_outs(const ir_node *bl) {
110         int i, n_cfg_outs = 0;
111         assert(bl && is_Block(bl));
112 #ifdef DEBUG_libfirm
113         assert(bl->out_valid);
114 #endif /* defined DEBUG_libfirm */
115         for (i = 1; i <= bl->out[0].pos; ++i) {
116                 ir_node *succ = bl->out[i].use;
117                 if (get_irn_mode(succ) == mode_X && !is_End(succ))
118                         n_cfg_outs += succ->out[0].pos;
119         }
120         return n_cfg_outs;
121 }
122
123 /* Return the number of control flow successors, honor keep-alives. */
124 int get_Block_n_cfg_outs_ka(const ir_node *bl) {
125         int i, n_cfg_outs = 0;
126         assert(bl && is_Block(bl));
127 #ifdef DEBUG_libfirm
128         assert(bl->out_valid);
129 #endif /* defined DEBUG_libfirm */
130         for (i = 1; i <= bl->out[0].pos; ++i) {
131                 ir_node *succ = bl->out[i].use;
132                 if (get_irn_mode(succ) == mode_X) {
133
134                         if (is_End(succ)) {
135                                 /* ignore End if we are in the Endblock */
136                                 if (get_nodes_block(succ) == bl)
137                                         continue;
138                                 else /* count Keep-alive as one */
139                                         n_cfg_outs += 1;
140                         } else
141                                 n_cfg_outs += succ->out[0].pos;
142                 }
143         }
144         return n_cfg_outs;
145 }
146
147 /* Access predecessor n, ignore keep-alives. */
148 ir_node *get_Block_cfg_out(const ir_node *bl, int pos) {
149         int i;
150         assert(bl && is_Block(bl));
151 #ifdef DEBUG_libfirm
152         assert(bl->out_valid);
153 #endif /* defined DEBUG_libfirm */
154         for (i = 1; i <= bl->out[0].pos; ++i) {
155                 ir_node *succ = bl->out[i].use;
156                 if (get_irn_mode(succ) == mode_X && !is_End(succ)) {
157                         int n_outs = succ->out[0].pos;
158                         if (pos < n_outs)
159                                 return succ->out[pos + 1].use;
160                         else
161                                 pos -= n_outs;
162                 }
163         }
164         return NULL;
165 }
166
167 /* Access predecessor n, honor keep-alives. */
168 ir_node *get_Block_cfg_out_ka(const ir_node *bl, int pos) {
169         int i, n_outs;
170         assert(bl && is_Block(bl));
171 #ifdef DEBUG_libfirm
172         assert (bl->out_valid);
173 #endif /* defined DEBUG_libfirm */
174         for (i = 1; i <= bl->out[0].pos; ++i) {
175                 ir_node *succ = bl->out[i].use;
176                 if (get_irn_mode(succ) == mode_X) {
177                         if (is_End(succ)) {
178                                 ir_node *end_bl = get_nodes_block(succ);
179                                 if (end_bl == bl) {
180                                         /* ignore End if we are in the Endblock */
181                                         continue;
182                                 }
183                                 if (pos == 0) {
184                                         /* handle keep-alive here: return the Endblock instead of the End node */
185                                         return end_bl;
186                                 } else
187                                         --pos;
188                         } else {
189                                 n_outs = succ->out[0].pos;
190                                 if (pos < n_outs)
191                                         return succ->out[pos + 1].use;
192                                 else
193                                         pos -= n_outs;
194                         }
195                 }
196         }
197         return NULL;
198 }
199
200 static void irg_out_walk_2(ir_node *node, irg_walk_func *pre,
201             irg_walk_func *post, void *env) {
202         int     i, n;
203         ir_node *succ;
204
205         assert(node);
206         assert(get_irn_visited(node) < get_irg_visited(current_ir_graph));
207
208         set_irn_visited(node, get_irg_visited(current_ir_graph));
209
210         if (pre) pre(node, env);
211
212         for (i = 0, n = get_irn_n_outs(node); i < n; ++i) {
213                 succ = get_irn_out(node, i);
214                 if (get_irn_visited(succ) < get_irg_visited(current_ir_graph))
215                         irg_out_walk_2(succ, pre, post, env);
216         }
217
218         if (post) post(node, env);
219 }
220
221 void irg_out_walk(ir_node *node,
222                   irg_walk_func *pre, irg_walk_func *post,
223                   void *env) {
224         assert(node);
225         if (get_irg_outs_state(current_ir_graph) != outs_none) {
226                 inc_irg_visited (current_ir_graph);
227                 irg_out_walk_2(node, pre, post, env);
228         }
229 }
230
231 static void irg_out_block_walk2(ir_node *bl,
232                                 irg_walk_func *pre, irg_walk_func *post,
233                                 void *env) {
234         int i, n;
235
236         if (!Block_block_visited(bl)) {
237                 mark_Block_block_visited(bl);
238
239                 if (pre)
240                         pre(bl, env);
241
242                 for (i = 0, n =  get_Block_n_cfg_outs(bl); i < n; ++i) {
243                         /* find the corresponding predecessor block. */
244                         ir_node *pred = get_Block_cfg_out(bl, i);
245                         /* recursion */
246                         irg_out_block_walk2(pred, pre, post, env);
247                 }
248
249                 if (post)
250                         post(bl, env);
251         }
252 }
253
254 /* Walks only over Block nodes in the graph.  Has it's own visited
255    flag, so that it can be interleaved with the other walker.         */
256 void irg_out_block_walk(ir_node *node,
257                         irg_walk_func *pre, irg_walk_func *post,
258                         void *env) {
259
260         assert(is_Block(node) || (get_irn_mode(node) == mode_X));
261
262         inc_irg_block_visited(current_ir_graph);
263
264         if (get_irn_mode(node) == mode_X) {
265                 int i, n;
266
267                 for (i = 0, n = get_irn_n_outs(node); i < n; ++i) {
268                         ir_node *succ = get_irn_out(node, i);
269                         if (get_irn_visited(succ) < get_irg_visited(current_ir_graph))
270                                 irg_out_walk_2(succ, pre, post, env);
271                 }
272         }
273         else {
274                 irg_out_block_walk2(node, pre, post, env);
275         }
276 }
277
278 /*--------------------------------------------------------------------*/
279 /** Building and Removing the out datastructure                      **/
280 /**                                                                  **/
281 /** The outs of a graph are allocated in a single, large array.      **/
282 /** This allows to allocate and deallocate the memory for the outs   **/
283 /** on demand.  The large array is separated into many small ones    **/
284 /** for each node.  Only a single field to reference the out array   **/
285 /** is stored in each node and a field referencing the large out     **/
286 /** array in irgraph.  The 0 field of each out array contains the    **/
287 /** size of this array.  This saves memory in the irnodes themselves.**/
288 /** The construction does two passes over the graph.  The first pass **/
289 /** counts the overall number of outs and the outs of each node.  It **/
290 /** stores the outs of each node in the out reference of the node.   **/
291 /** Then the large array is allocated.  The second iteration chops   **/
292 /** the large array into smaller parts, sets the out edges and       **/
293 /** recounts the out edges.                                          **/
294 /** Removes Tuple nodes!                                             **/
295 /*--------------------------------------------------------------------*/
296
297
298 /** Returns the amount of out edges for not yet visited successors. */
299 static int _count_outs(ir_node *n) {
300         int start, i, res, irn_arity;
301
302         mark_irn_visited(n);
303         n->out = INT_TO_PTR(1);     /* Space for array size. */
304
305         start = is_Block(n) ? 0 : -1;
306         irn_arity = get_irn_arity(n);
307         res = irn_arity - start + 1;  /* --1 or --0; 1 for array size. */
308
309         for (i = start; i < irn_arity; ++i) {
310                 /* Optimize Tuples.  They annoy if walking the cfg. */
311                 ir_node *pred         = get_irn_n(n, i);
312                 ir_node *skipped_pred = skip_Tuple(pred);
313
314                 if (skipped_pred != pred) {
315                         set_irn_n(n, i, skipped_pred);
316                 }
317
318                 /* count Def-Use edges for predecessors */
319                 if (!irn_visited(skipped_pred))
320                         res += _count_outs(skipped_pred);
321
322                 /*count my Def-Use edges */
323                 skipped_pred->out = INT_TO_PTR(PTR_TO_INT(skipped_pred->out) + 1);
324         }
325         return res;
326 }
327
328
329 /** Returns the amount of out edges for not yet visited successors.
330  *  This version handles some special nodes like irg_frame, irg_args etc.
331  */
332 static int count_outs(ir_graph *irg) {
333         ir_node *n;
334         int     i, res;
335
336         inc_irg_visited(irg);
337         res = _count_outs(get_irg_end(irg));
338
339         /* Now handle anchored nodes. We need the out count of those
340            even if they are not visible. */
341         for (i = anchor_last - 1; i >= 0; --i) {
342                 n = get_irg_anchor(irg, i);
343                 if (!irn_visited_else_mark(n)) {
344                         n->out = INT_TO_PTR(1);
345                         ++res;
346                 }
347         }
348         return res;
349 }
350
351 /**
352  * Enter memory for the outs to a node.
353  *
354  * @param use    current node
355  * @param free   current free address in the chunk allocated for the outs
356  *
357  * @return The next free address
358  */
359 static ir_def_use_edge *_set_out_edges(ir_node *use, ir_def_use_edge *free) {
360         int     n_outs, start, i, irn_arity, pos;
361
362         mark_irn_visited(use);
363
364         /* Allocate my array */
365         n_outs = PTR_TO_INT(use->out);
366         use->out = free;
367 #ifdef DEBUG_libfirm
368         use->out_valid = 1;
369 #endif /* defined DEBUG_libfirm */
370         free += n_outs;
371         /* We count the successors again, the space will be sufficient.
372            We use this counter to remember the position for the next back
373            edge. */
374         use->out[0].pos = 0;
375
376         start = is_Block(use) ? 0 : -1;
377         irn_arity = get_irn_arity(use);
378
379         for (i = start; i < irn_arity; ++i) {
380                 ir_node *def = get_irn_n(use, i);
381
382                 /* Recursion */
383                 if (!irn_visited(def))
384                         free = _set_out_edges(def, free);
385
386                 /* Remember this Def-Use edge */
387                 pos = def->out[0].pos + 1;
388                 def->out[pos].use = use;
389                 def->out[pos].pos = i;
390
391                 /* increase the number of Def-Use edges so far */
392                 def->out[0].pos = pos;
393         }
394         return free;
395 }
396
397 /**
398  * Enter memory for the outs to a node. Handles special nodes
399  *
400  * @param irg    the graph
401  * @param free   current free address in the chunk allocated for the outs
402  *
403  * @return The next free address
404  */
405 static ir_def_use_edge *set_out_edges(ir_graph *irg, ir_def_use_edge *free) {
406         ir_node *n;
407         int     i, n_outs;
408
409         inc_irg_visited(irg);
410         free = _set_out_edges(get_irg_end(irg), free);
411
412         /* handle anchored nodes */
413         for (i = anchor_last - 1; i >= 0; --i) {
414                 n = get_irg_anchor(irg, i);
415                 if (!irn_visited_else_mark(n)) {
416                         n_outs = PTR_TO_INT(n->out);
417                         n->out = free;
418 #ifdef DEBUG_libfirm
419                         n->out_valid = 1;
420 #endif /* defined DEBUG_libfirm */
421                         free += n_outs;
422                 }
423         }
424
425         return free;
426 }
427
428
429 /**
430  * We want that the out of ProjX from Start contains the next block at
431  * position 0, the Start block at position 1.  This is necessary for
432  * the out block walker.
433  */
434 static INLINE void fix_start_proj(ir_graph *irg) {
435         ir_node *startbl = get_irg_start_block(irg);
436
437         if (get_Block_n_cfg_outs(startbl)) {
438                 ir_node *proj = get_irg_initial_exec(irg);
439                 ir_node *irn;
440                 int     block_pos, other_pos;
441
442                 if (get_irn_n_outs(proj) == 2) {
443                         if (get_irn_out_ex(proj, 0, &block_pos) == startbl) {
444                                 irn = get_irn_out_ex(proj, 1, &other_pos);
445                                 set_irn_out(proj, 0, irn, other_pos);
446                                 set_irn_out(proj, 1, startbl, block_pos);
447                         }
448                 } else {
449                         assert(get_irg_phase_state(irg) == phase_backend);
450                 }
451         }
452 }
453
454 /* compute the outs for a given graph */
455 void compute_irg_outs(ir_graph *irg) {
456         ir_graph        *rem = current_ir_graph;
457         int             n_out_edges = 0;
458         ir_def_use_edge *end = NULL;         /* Only for debugging */
459
460         current_ir_graph = irg;
461
462         /* Update graph state */
463         assert(get_irg_phase_state(current_ir_graph) != phase_building);
464
465         if (current_ir_graph->outs_state != outs_none)
466                 free_irg_outs(current_ir_graph);
467
468         /* This first iteration counts the overall number of out edges and the
469            number of out edges for each node. */
470         n_out_edges = count_outs(irg);
471
472         /* allocate memory for all out edges. */
473         irg->outs = XMALLOCNZ(ir_def_use_edge, n_out_edges);
474 #ifdef DEBUG_libfirm
475         irg->n_outs = n_out_edges;
476 #endif /* defined DEBUG_libfirm */
477
478         /* The second iteration splits the irg->outs array into smaller arrays
479            for each node and writes the back edges into this array. */
480         end = set_out_edges(irg, irg->outs);
481
482         /* Check how much memory we have used */
483         assert (end == (irg->outs + n_out_edges));
484
485         /* We want that the out of ProjX from Start contains the next block at
486            position 0, the Start block at position 1.  This is necessary for
487            code placement (place_early() ONLY if started GCSE on graphs with dead blocks) */
488         fix_start_proj(irg);
489
490         current_ir_graph->outs_state = outs_consistent;
491         current_ir_graph = rem;
492 }
493
494 void assure_irg_outs(ir_graph *irg) {
495         if (get_irg_outs_state(irg) != outs_consistent)
496                 compute_irg_outs(irg);
497 }
498
499 void compute_irp_outs(void) {
500         int i;
501         for (i = get_irp_n_irgs() -1; i >= 0; --i)
502                 compute_irg_outs(get_irp_irg(i));
503 }
504
505 void free_irp_outs(void) {
506         int i;
507         for (i = get_irp_n_irgs() -1; i >= 0; --i)
508                 free_irg_outs(get_irp_irg(i));
509 }
510
511
512 /*------------------------------------------------------------*
513  *  This computes the outedges for in interprocedural graph.  *
514  *  There is one quirk:                                       *
515  *  The number of the outedges for each node is saved in      *
516  *  the first member of the ir_node** array. Maybe we should  *
517  *  change this to make it more portable...                   *
518  *------------------------------------------------------------*/
519
520
521 #ifdef INTERPROCEDURAL_VIEW
522 /**
523  * Inits the number of outedges for each node
524  * before counting.
525  */
526 static void init_count(ir_node * node, void *env) {
527         (void) env;
528         node->out = (ir_node **) 1; /* 1 for the array size */
529 }
530
531
532 /**
533  * Adjusts the out edge count for its predecessors
534  * and adds the current arity to the overall count,
535  * which is saved in "env"
536  */
537 static void node_arity_count(ir_node * node, void * env) {
538         int *anz = (int *) env, arity, n_outs, i, start;
539         ir_node *succ;
540
541         arity = get_irn_arity(node);
542         start = (is_Block(node)) ? 0 : -1;
543
544         n_outs = 1 + arity + (-start);  // ((is_Block(node)) ? 0 : 1);   // Why + 1??
545         *anz += n_outs;
546
547         for(i = start; i < arity; i++) {
548                 succ = get_irn_n(node, i);
549                 succ->out = (ir_node **)INT_TO_PTR(PTR_TO_INT(succ->out) + 1);
550         }
551 }
552
553 /*
554  * Inits all nodes for setting the outedges
555  * Returns the overall count of edges
556  */
557 int count_ip_outs(void) {
558         int res = 0;
559
560         cg_walk(init_count, node_arity_count, &res);
561
562         return(res);
563 }
564
565 static int dummy_count = 0, global_count; /* Only for debugging */
566
567 /**
568  * For each node: Sets the pointer to array
569  * in which the outedges are written later.
570  * The current array start is transported in env
571  */
572 static void set_array_pointer(ir_node *node, void *env) {
573         int n_outs;
574         ir_node ***free = (ir_node ***) env;
575
576         /* Allocate my array */
577         n_outs = PTR_TO_INT(node->out);  /* We wrote the count here in count_ip_outs */
578         dummy_count += n_outs;
579         assert(dummy_count <= global_count && "More outedges than initially counted!");
580         node -> out = *free;
581         *free = &((*free)[n_outs]);
582         /* We count the successors again, the space will be sufficient.
583            We use this counter to remember the position for the next back
584            edge. */
585         node -> out[0] = (ir_node *) 0;
586 }
587
588
589 /**
590  * Adds an outedge from the predecessor to the
591  * current node.
592  */
593 static void set_out_pointer(ir_node * node, void *env) {
594         int i, arity = get_irn_arity(node);
595         ir_node *succ;
596         int start = (!is_Block(node)) ? -1 : 0;
597         (void) env;
598
599         for (i = start; i < arity; ++i) {
600                 succ = get_irn_n(node, i);
601                 succ->out[get_irn_n_outs(succ)+1] = node;
602                 succ->out[0] = INT_TO_PTR(get_irn_n_outs(succ) + 1);
603         }
604 }
605
606
607 /*
608  * Sets the outedges for all nodes.
609  */
610 void set_ip_outs(void) {
611         ir_node **outedge_array = get_irp_ip_outedges();
612         cg_walk(set_array_pointer, set_out_pointer, (void *) &outedge_array);
613 }
614
615
616
617 /*
618  * Counts the outedges, allocates memory to save the
619  * outedges and fills this outedge array in interprocedural
620  * view!
621  */
622 void compute_ip_outs(void) {
623         int n_out_edges;
624         ir_node **out_edges;
625
626         assert(get_irp_ip_view_state() == ip_view_valid &&
627          "Cannot construct outs for invalid ip view.");
628
629         if (irp->outs_state != outs_none) {
630                 free_ip_outs();
631         }
632
633         global_count = n_out_edges = count_ip_outs();
634         out_edges    = XMALLOCNZ(ir_node*, n_out_edges);
635         set_irp_ip_outedges(out_edges);
636         set_ip_outs();
637 }
638
639 void free_ip_outs(void) {
640         ir_node **out_edges = get_irp_ip_outedges();
641         if (out_edges != NULL) {
642                 free(out_edges);
643                 set_irp_ip_outedges(NULL);
644         }
645         irp->outs_state = outs_none;
646 }
647 #endif
648
649
650 void free_irg_outs(ir_graph *irg) {
651         /*   current_ir_graph->outs_state = outs_none; */
652         irg->outs_state = outs_none;
653
654         if (irg->outs) {
655 #ifdef DEBUG_libfirm
656                 memset(irg->outs, 0, irg->n_outs);
657 #endif /* defined DEBUG_libfirm */
658                 free(irg->outs);
659                 irg->outs = NULL;
660 #ifdef DEBUG_libfirm
661                 irg->n_outs = 0;
662 #endif /* defined DEBUG_libfirm */
663         }
664
665 #ifdef DEBUG_libfirm
666         /* when debugging, *always* reset all nodes' outs!  irg->outs might
667            have been lying to us */
668         irg_walk_graph (irg, reset_outs, NULL, NULL);
669 #endif /* defined DEBUG_libfirm */
670 }
671
672 static void check_out_edges(ir_node *irn, void *env) {
673         int i, j, pos;
674         int *pError = env;
675         int error = *pError;
676         int last = is_Block(irn) ? 0 : -1;
677
678         /* check forward: every input must have an out edge */
679         for (i = get_irn_arity(irn) - 1; i >= last; --i) {
680                 ir_node *pred = get_irn_n(irn, i);
681
682                 for (j = get_irn_n_outs(pred) - 1; j >= 0; --j) {
683                         ir_node *user = get_irn_out_ex(pred, j, &pos);
684
685                         if (user == irn && pos == i) {
686                                 break;
687                         }
688                 }
689                 if (j < 0) {
690                         ir_fprintf(stderr, "Missing out edge from %+F input %d to %+F", irn, i, pred);
691                         ++error;
692                 }
693         }
694
695         /* checking backward */
696         for (i = get_irn_n_outs(irn) - 1; i >= 0; --i) {
697                 ir_node *user = get_irn_out_ex(irn, i, &pos);
698
699                 if (get_irn_n(user, pos) != irn) {
700                         ir_fprintf(stderr, "Spurious out edge from %+F output %d to %+F", irn, i, user);
701                         ++error;
702                 }
703         }
704         *pError = error;
705 }
706
707 /* verify outs edges. */
708 void verify_outs(ir_graph *irg) {
709         int errors = 0;
710         irg_walk_graph(irg, NULL, check_out_edges, &errors);
711         if (errors > 0)
712                 panic("Out edges are corrupt");
713 }