Add a rule to transform x .op. (x .op. y) into y .op. (x .op. x) for commutative...
[libfirm] / ir / opt / tailrec.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   Tail-recursion call optimization.
23  * @date    08.06.2004
24  * @author  Michael Beck
25  * @version $Id$
26  */
27 #include "config.h"
28
29 #include <string.h>
30 #include <assert.h>
31
32 #include "debug.h"
33 #include "iroptimize.h"
34 #include "scalar_replace.h"
35 #include "array_t.h"
36 #include "irprog_t.h"
37 #include "irgwalk.h"
38 #include "irgmod.h"
39 #include "irop.h"
40 #include "irnode_t.h"
41 #include "irgraph_t.h"
42 #include "ircons.h"
43 #include "irflag.h"
44 #include "trouts.h"
45 #include "irouts.h"
46 #include "irhooks.h"
47 #include "ircons_t.h"
48 #include "irpass.h"
49
50 DEBUG_ONLY(static firm_dbg_module_t *dbg);
51
52 /**
53  * the environment for collecting data
54  */
55 typedef struct _collect_t {
56         ir_node *proj_X;      /**< initial exec proj */
57         ir_node *block;       /**< old first block */
58         int     blk_idx;      /**< cfgpred index of the initial exec in block */
59         ir_node *proj_m;      /**< memory from start proj's */
60         ir_node *proj_data;   /**< linked list of all parameter access proj's */
61 } collect_t;
62
63 /**
64  * walker for collecting data, fills a collect_t environment
65  */
66 static void collect_data(ir_node *node, void *env) {
67         collect_t *data = env;
68         ir_node *pred;
69         ir_op *op;
70
71         switch (get_irn_opcode(node)) {
72         case iro_Proj:
73                 pred = get_Proj_pred(node);
74
75                 op = get_irn_op(pred);
76                 if (op == op_Proj) {
77                         ir_node *start = get_Proj_pred(pred);
78
79                         if (is_Start(start)) {
80                                 if (get_Proj_proj(pred) == pn_Start_T_args) {
81                                         /* found Proj(ProjT(Start)) */
82                                         set_irn_link(node, data->proj_data);
83                                         data->proj_data = node;
84                                 }
85                         }
86                 } else if (op == op_Start) {
87                         if (get_Proj_proj(node) == pn_Start_X_initial_exec) {
88                                 /* found ProjX(Start) */
89                                 data->proj_X = node;
90                         }
91                 }
92                 break;
93         case iro_Block: {
94                 int i, n_pred = get_Block_n_cfgpreds(node);
95
96                 /*
97                  * the first block has the initial exec as cfg predecessor
98                  */
99                 if (node != get_irg_start_block(current_ir_graph)) {
100                         for (i = 0; i < n_pred; ++i) {
101                                 if (get_Block_cfgpred(node, i) == data->proj_X) {
102                                         data->block   = node;
103                                         data->blk_idx = i;
104                                         break;
105                                 }
106                         }
107                 }
108                 break;
109         }
110         default:
111                 break;
112         }
113 }
114
115 typedef enum tail_rec_variants {
116         TR_DIRECT,  /**< direct return value, i.e. return func(). */
117         TR_ADD,     /**< additive return value, i.e. return x +/- func() */
118         TR_MUL,     /**< multiplicative return value, i.e. return x * func() or return -func() */
119         TR_BAD,     /**< any other transformation */
120         TR_UNKNOWN  /**< during construction */
121 } tail_rec_variants;
122
123 typedef struct tr_env {
124         int               n_tail_calls;  /**< number of tail calls found */
125         int               n_ress;        /**< number of return values */
126         tail_rec_variants *variants;     /**< return value variants */
127         ir_node           *rets;         /**< list of returns that can be transformed */
128 } tr_env;
129
130
131 /**
132  * do the graph reconstruction for tail-recursion elimination
133  *
134  * @param irg           the graph that will reconstructed
135  * @param rets          linked list of all rets
136  * @param n_tail_calls  number of tail-recursion calls
137  */
138 static void do_opt_tail_rec(ir_graph *irg, tr_env *env) {
139         ir_node *end_block = get_irg_end_block(irg);
140         ir_node *block, *jmp, *call, *calls;
141         ir_node **in;
142         ir_node **phis;
143         ir_node ***call_params;
144         ir_node *p, *n;
145         int i, j, n_params, n_locs;
146         collect_t data;
147         int rem            = get_optimize();
148         ir_entity *ent     = get_irg_entity(irg);
149         ir_type *method_tp = get_entity_type(ent);
150         ir_graph *old      = current_ir_graph;
151
152         current_ir_graph = irg;
153
154         assert(env->n_tail_calls > 0);
155
156         /* we add new nodes, so the outs are inconsistent */
157         set_irg_outs_inconsistent(irg);
158
159         /* we add new blocks and change the control flow */
160         set_irg_doms_inconsistent(irg);
161         set_irg_extblk_inconsistent(irg);
162
163         /* we add a new loop */
164         set_irg_loopinfo_inconsistent(irg);
165
166         /* calls are removed */
167         set_trouts_inconsistent();
168
169         /* we must build some new nodes WITHOUT CSE */
170         set_optimize(0);
171
172         /* collect needed data */
173         data.proj_X    = NULL;
174         data.block     = NULL;
175         data.blk_idx   = -1;
176         data.proj_m    = get_irg_initial_mem(irg);
177         data.proj_data = NULL;
178         irg_walk_graph(irg, NULL, collect_data, &data);
179
180         /* check number of arguments */
181         call = get_irn_link(end_block);
182         n_params = get_Call_n_params(call);
183
184         assert(data.proj_X && "Could not find initial exec from Start");
185         assert(data.block  && "Could not find first block");
186         assert(data.proj_m && "Could not find initial memory");
187         assert((data.proj_data || n_params == 0) && "Could not find Proj(ProjT(Start)) of non-void function");
188
189         /* allocate in's for phi and block construction */
190         NEW_ARR_A(ir_node *, in, env->n_tail_calls + 1);
191
192         in[0] = data.proj_X;
193
194         /* turn Return's into Jmp's */
195         for (i = 1, p = env->rets; p; p = n) {
196                 ir_node *block = get_nodes_block(p);
197
198                 n = get_irn_link(p);
199                 in[i++] = new_r_Jmp(block);
200
201                 // exchange(p, new_r_Bad(irg));
202
203                 /* we might generate an endless loop, so add
204                  * the block to the keep-alive list */
205                 add_End_keepalive(get_irg_end(irg), block);
206         }
207
208         /* create a new block at start */
209         block = new_r_Block(irg, env->n_tail_calls + 1, in);
210         jmp   = new_r_Jmp(block);
211
212         /* the old first block is now the second one */
213         set_Block_cfgpred(data.block, data.blk_idx, jmp);
214
215         /* allocate phi's, position 0 contains the memory phi */
216         NEW_ARR_A(ir_node *, phis, n_params + 1);
217
218         /* build the memory phi */
219         i = 0;
220         in[i] = new_r_Proj(get_irg_start_block(irg), get_irg_start(irg), mode_M, pn_Start_M);
221         set_irg_initial_mem(irg, in[i]);
222         ++i;
223
224         for (calls = call; calls; calls = get_irn_link(calls)) {
225                 in[i] = get_Call_mem(calls);
226                 ++i;
227         }
228         assert(i == env->n_tail_calls + 1);
229
230         phis[0] = new_r_Phi(block, env->n_tail_calls + 1, in, mode_M);
231
232         /* build the data Phi's */
233         if (n_params > 0) {
234                 ir_node *calls;
235                 ir_node *args;
236                 ir_node *args_bl;
237
238                 NEW_ARR_A(ir_node **, call_params, env->n_tail_calls);
239
240                 /* collect all parameters */
241                 for (i = 0, calls = call; calls; calls = get_irn_link(calls)) {
242                         call_params[i] = get_Call_param_arr(calls);
243                         ++i;
244                 }
245
246                 /* build new Proj's and Phi's */
247                 args    = get_irg_args(irg);
248                 args_bl = get_nodes_block(args);
249                 for (i = 0; i < n_params; ++i) {
250                         ir_mode *mode = get_type_mode(get_method_param_type(method_tp, i));
251
252                         in[0] = new_r_Proj(args_bl, args, mode, i);
253                         for (j = 0; j < env->n_tail_calls; ++j)
254                                 in[j + 1] = call_params[j][i];
255
256                         phis[i + 1] = new_r_Phi(block, env->n_tail_calls + 1, in, mode);
257                 }
258         }
259
260         /*
261          * ok, we are here, so we have build and collected all needed Phi's
262          * now exchange all Projs into links to Phi
263          */
264         exchange(data.proj_m, phis[0]);
265         for (p = data.proj_data; p; p = n) {
266                 long proj = get_Proj_proj(p);
267
268                 assert(0 <= proj && proj < n_params);
269                 n = get_irn_link(p);
270                 exchange(p, phis[proj + 1]);
271         }
272
273         /* tail recursion was done, all info is invalid */
274         set_irg_doms_inconsistent(irg);
275         set_irg_outs_inconsistent(irg);
276         set_irg_extblk_inconsistent(irg);
277         set_irg_loopinfo_state(current_ir_graph, loopinfo_cf_inconsistent);
278         set_trouts_inconsistent();
279         set_irg_callee_info_state(irg, irg_callee_info_inconsistent);
280
281         set_optimize(rem);
282
283         /* check if we need new values */
284         n_locs = 0;
285         for (i = 0; i < env->n_ress; ++i) {
286                 if (env->variants[i] != TR_DIRECT)
287                         ++n_locs;
288         }
289
290         if (n_locs > 0) {
291                 ir_node *bad, *start_block;
292                 ir_node **in;
293                 ir_mode **modes;
294
295                 NEW_ARR_A(ir_node *, in, n_locs);
296                 NEW_ARR_A(ir_mode *, modes, n_locs);
297                 ssa_cons_start(irg, n_locs);
298
299                 start_block = get_irg_start_block(irg);
300                 set_cur_block(start_block);
301
302                 for (i = 0; i < env->n_ress; ++i) {
303                         ir_type *tp = get_method_res_type(method_tp, i);
304                         ir_mode *mode = get_type_mode(tp);
305
306                         modes[i] = mode;
307                         if (env->variants[i] == TR_ADD) {
308                                 set_value(i, new_Const(get_mode_null(mode)));
309                         } else if (env->variants[i] == TR_MUL) {
310                                 set_value(i, new_Const(get_mode_one(mode)));
311                         }
312                 }
313                 mature_immBlock(start_block);
314
315                 /* no: we can kill all returns */
316                 bad = get_irg_bad(irg);
317
318                 for (p = env->rets; p; p = n) {
319                         ir_node *block = get_nodes_block(p);
320                         ir_node *call, *mem, *jmp, *tuple;
321
322                         set_cur_block(block);
323                         n = get_irn_link(p);
324
325                         call = skip_Proj(get_Return_mem(p));
326                         assert(is_Call(call));
327
328                         mem = get_Call_mem(call);
329
330                         /* create a new jump, free of CSE */
331                         set_optimize(0);
332                         jmp = new_Jmp();
333                         set_optimize(rem);
334
335                         for (i = 0; i < env->n_ress; ++i) {
336                                 if (env->variants[i] != TR_DIRECT) {
337                                         in[i] = get_value(i, modes[i]);
338                                 } else {
339                                         in[i] = bad;
340                                 }
341                         }
342                         /* create a new tuple for the return values */
343                         tuple = new_Tuple(env->n_ress, in);
344
345                         turn_into_tuple(call, pn_Call_max);
346                         set_Tuple_pred(call, pn_Call_M,                mem);
347                         set_Tuple_pred(call, pn_Call_X_regular,        jmp);
348                         set_Tuple_pred(call, pn_Call_X_except,         bad);
349                         set_Tuple_pred(call, pn_Call_T_result,         tuple);
350                         set_Tuple_pred(call, pn_Call_P_value_res_base, bad);
351
352                         for (i = 0; i < env->n_ress; ++i) {
353                                 ir_node *res = get_Return_res(p, i);
354                                 if (env->variants[i] != TR_DIRECT) {
355                                         set_value(i, res);
356                                 }
357                         }
358
359                         exchange(p, bad);
360                 }
361
362                 /* finally fix all other returns */
363                 end_block = get_irg_end_block(irg);
364                 for (i = get_Block_n_cfgpreds(end_block) - 1; i >= 0; --i) {
365                         ir_node *ret = get_Block_cfgpred(end_block, i);
366
367                         /* search all Returns of a block */
368                         if (! is_Return(ret))
369                                 continue;
370
371                         set_cur_block(get_nodes_block(ret));
372                         for (j = 0; j < env->n_ress; ++j) {
373                                 ir_node *pred = get_Return_res(ret, j);
374                                 ir_node *n;
375
376                                 switch (env->variants[j]) {
377                                 case TR_DIRECT:
378                                         continue;
379
380                                 case TR_ADD:
381                                         n = get_value(j, modes[j]);
382                                         n = new_Add(n, pred, modes[j]);
383                                         set_Return_res(ret, j, n);
384                                         break;
385
386                                 case TR_MUL:
387                                         n = get_value(j, modes[j]);
388                                         n = new_Mul(n, pred, modes[j]);
389                                         set_Return_res(ret, j, n);
390                                         break;
391
392                                 default:
393                                         assert(!"unexpected tail recursion variant");
394                                 }
395                         }
396                 }
397                 ssa_cons_finish(irg);
398         } else {
399                 ir_node *bad = get_irg_bad(irg);
400
401                 /* no: we can kill all returns */
402                 for (p = env->rets; p; p = n) {
403                         n = get_irn_link(p);
404                         exchange(p, bad);
405                 }
406         }
407         current_ir_graph = old;
408 }
409
410 /**
411  * Check the lifetime of locals in the given graph.
412  * Tail recursion can only be done, if we can prove that
413  * the lifetime of locals end with the recursive call.
414  * We do this by checking that no address of a local variable is
415  * stored or transmitted as an argument to a call.
416  *
417  * @return non-zero if it's ok to do tail recursion
418  */
419 static int check_lifetime_of_locals(ir_graph *irg) {
420         ir_node *irg_frame;
421         int i;
422         ir_type *frame_tp = get_irg_frame_type(irg);
423
424         irg_frame = get_irg_frame(irg);
425         for (i = get_irn_n_outs(irg_frame) - 1; i >= 0; --i) {
426                 ir_node *succ = get_irn_out(irg_frame, i);
427
428                 if (is_Sel(succ)) {
429                         /* Check if we have compound arguments.
430                            For now, we cannot handle them, */
431                         if (get_entity_owner(get_Sel_entity(succ)) != frame_tp)
432                                 return 0;
433
434                         if (is_address_taken(succ))
435                                 return 0;
436                 }
437         }
438         return 1;
439 }
440
441 /**
442  * Examine irn and detect the recursion variant.
443  */
444 static tail_rec_variants find_variant(ir_node *irn, ir_node *call) {
445         ir_node           *a, *b;
446         tail_rec_variants va, vb, res;
447
448         if (skip_Proj(skip_Proj(irn)) == call) {
449                 /* found it */
450                 return TR_DIRECT;
451         }
452         switch (get_irn_opcode(irn)) {
453         case iro_Add:
454                 /* try additive */
455                 a = get_Add_left(irn);
456                 if (get_irn_MacroBlock(a) != get_irn_MacroBlock(call)) {
457                         /* we are outside, ignore */
458                         va = TR_UNKNOWN;
459                 } else {
460                         va = find_variant(a, call);
461                         if (va == TR_BAD)
462                                 return TR_BAD;
463                 }
464                 b = get_Add_right(irn);
465                 if (get_irn_MacroBlock(b) != get_irn_MacroBlock(call)) {
466                         /* we are outside, ignore */
467                         vb = TR_UNKNOWN;
468                 } else {
469                         vb = find_variant(b, call);
470                         if (vb == TR_BAD)
471                                 return TR_BAD;
472                 }
473                 if (va == vb) {
474                         res = va;
475                 }
476                 else if (va == TR_UNKNOWN)
477                         res = vb;
478                 else if (vb == TR_UNKNOWN)
479                         res = va;
480                 else {
481                         /* they are different but none is TR_UNKNOWN -> incompatible */
482                         return TR_BAD;
483                 }
484                 if (res == TR_DIRECT || res == TR_ADD)
485                         return TR_ADD;
486                 /* not compatible */
487                 return TR_BAD;
488
489         case iro_Sub:
490                 /* try additive, but return value must be left */
491                 a = get_Sub_left(irn);
492                 if (get_irn_MacroBlock(a) != get_irn_MacroBlock(call)) {
493                         /* we are outside, ignore */
494                         va = TR_UNKNOWN;
495                 } else {
496                         va = find_variant(a, call);
497                         if (va == TR_BAD)
498                                 return TR_BAD;
499                 }
500                 b = get_Sub_right(irn);
501                 if (get_irn_MacroBlock(b) != get_irn_MacroBlock(call)) {
502                         /* we are outside, ignore */
503                         vb = TR_UNKNOWN;
504                 } else {
505                         vb = find_variant(b, call);
506                         if (vb != TR_UNKNOWN)
507                                 return TR_BAD;
508                 }
509                 res = va;
510                 if (res == TR_DIRECT || res == TR_ADD)
511                         return res;
512                 /* not compatible */
513                 return TR_BAD;
514
515         case iro_Mul:
516                 /* try multiplicative */
517                 a = get_Mul_left(irn);
518                 if (get_irn_MacroBlock(a) != get_irn_MacroBlock(call)) {
519                         /* we are outside, ignore */
520                         va = TR_UNKNOWN;
521                 } else {
522                         va = find_variant(a, call);
523                         if (va == TR_BAD)
524                                 return TR_BAD;
525                 }
526                 b = get_Mul_right(irn);
527                 if (get_irn_MacroBlock(b) != get_irn_MacroBlock(call)) {
528                         /* we are outside, ignore */
529                         vb = TR_UNKNOWN;
530                 } else {
531                         vb = find_variant(b, call);
532                         if (vb == TR_BAD)
533                                 return TR_BAD;
534                 }
535                 if (va == vb) {
536                         res = va;
537                 }
538                 else if (va == TR_UNKNOWN)
539                         res = vb;
540                 else if (vb == TR_UNKNOWN)
541                         res = va;
542                 else {
543                         /* they are different but none is TR_UNKNOWN -> incompatible */
544                         return TR_BAD;
545                 }
546                 if (res == TR_DIRECT || res == TR_MUL)
547                         return TR_MUL;
548                 /* not compatible */
549                 return TR_BAD;
550
551         case iro_Minus:
552                 /* try multiplicative */
553                 a = get_Minus_op(irn);
554                 res =  find_variant(a, call);
555                 if (res == TR_DIRECT)
556                         return TR_MUL;
557                 if (res == TR_MUL || res == TR_UNKNOWN)
558                         return res;
559                 /* not compatible */
560                 return TR_BAD;
561
562         default:
563                 return TR_UNKNOWN;
564         }
565 }
566
567
568 /*
569  * convert simple tail-calls into loops
570  */
571 int opt_tail_rec_irg(ir_graph *irg) {
572         tr_env            env;
573         ir_node           *end_block;
574         int               i, n_ress, n_tail_calls = 0;
575         ir_node           *rets = NULL;
576         ir_type           *mtd_type, *call_type;
577         ir_entity         *ent;
578
579         assure_irg_outs(irg);
580
581         if (! check_lifetime_of_locals(irg))
582                 return 0;
583
584
585         ent      = get_irg_entity(irg);
586         mtd_type = get_entity_type(ent);
587     n_ress   = get_method_n_ress(mtd_type);
588
589         env.variants = NULL;
590         env.n_ress   = n_ress;
591
592         if (n_ress > 0) {
593                 NEW_ARR_A(tail_rec_variants, env.variants, n_ress);
594
595                 for (i = 0; i < n_ress; ++i)
596                         env.variants[i] = TR_DIRECT;
597         }
598
599         /*
600          * This tail recursion optimization works best
601          * if the Returns are normalized.
602          */
603         normalize_n_returns(irg);
604
605         end_block = get_irg_end_block(irg);
606         set_irn_link(end_block, NULL);
607
608         for (i = get_Block_n_cfgpreds(end_block) - 1; i >= 0; --i) {
609                 ir_node *ret = get_Block_cfgpred(end_block, i);
610                 ir_node *call, *call_ptr;
611                 int j;
612                 ir_node **ress;
613
614                 /* search all Returns of a block */
615                 if (! is_Return(ret))
616                         continue;
617
618                 /* check, if it's a Return self() */
619                 call = skip_Proj(get_Return_mem(ret));
620                 if (! is_Call(call))
621                         continue;
622
623                 /* the call must be in the same block as the return */
624                 if (get_nodes_block(call) != get_nodes_block(ret))
625                         continue;
626
627                 /* check if it's a recursive call */
628                 call_ptr = get_Call_ptr(call);
629
630                 if (! is_Global(call_ptr))
631                         continue;
632
633                 ent = get_Global_entity(call_ptr);
634                 if (!ent || get_entity_irg(ent) != irg)
635                         continue;
636
637                 /*
638                  * Check, that the types match. At least in C
639                  * this might fail.
640                  */
641                 mtd_type  = get_entity_type(ent);
642                 call_type = get_Call_type(call);
643
644                 if (mtd_type != call_type) {
645                         /*
646                          * Hmm, the types did not match, bad.
647                          * This can happen in C when no prototype is given
648                          * or K&R style is used.
649                          */
650 #if 0
651                         printf("Warning: Tail recursion fails because of different method and call types:\n");
652                         dump_type(mtd_type);
653                         dump_type(call_type);
654 #endif
655                         continue;
656                 }
657
658                 /* ok, mem is routed to a recursive call, check return args */
659                 ress = get_Return_res_arr(ret);
660                 for (j = get_Return_n_ress(ret) - 1; j >= 0; --j) {
661                         tail_rec_variants var = find_variant(ress[j], call);
662
663                         if (var >= TR_BAD) {
664                                 /* cannot be transformed */
665                                 break;
666                         }
667                         if (var == TR_DIRECT)
668                                 var = env.variants[j];
669                         else if (env.variants[j] == TR_DIRECT)
670                                 env.variants[j] = var;
671                         if (env.variants[j] != var) {
672                                 /* not compatible */
673                                 break;
674                         }
675                 }
676                 if (j >= 0)
677                         continue;
678
679                 /* here, we have found a call */
680                 set_irn_link(call, get_irn_link(end_block));
681                 set_irn_link(end_block, call);
682                 ++n_tail_calls;
683
684                 /* link all returns, we will need this */
685                 set_irn_link(ret, rets);
686                 rets = ret;
687         }
688
689         /* now, end_block->link contains the list of all tail calls */
690         if (n_tail_calls <= 0)
691                 return 0;
692
693         DB((dbg, LEVEL_2, "  Performing tail recursion for graph %s and %d Calls\n",
694             get_entity_ld_name(get_irg_entity(irg)), n_tail_calls));
695
696         hook_tail_rec(irg, n_tail_calls);
697
698         env.n_tail_calls = n_tail_calls;
699         env.rets         = rets;
700         do_opt_tail_rec(irg, &env);
701
702         return n_tail_calls;
703 }
704
705 ir_graph_pass_t *opt_tail_rec_irg_pass(const char *name)
706 {
707         return def_graph_pass_ret(name ? name : "tailrec", opt_tail_rec_irg);
708 }
709
710 /*
711  * optimize tail recursion away
712  */
713 void opt_tail_recursion(void) {
714         int i;
715         int n_opt_applications = 0;
716         ir_graph *irg;
717
718         FIRM_DBG_REGISTER(dbg, "firm.opt.tailrec");
719
720         for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
721                 irg = get_irp_irg(i);
722
723                 current_ir_graph = irg;
724
725                 ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
726                 if (opt_tail_rec_irg(irg))
727                         ++n_opt_applications;
728
729                 ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
730         }
731
732         DB((dbg, LEVEL_1, "Performed tail recursion for %d of %d graphs\n",
733             n_opt_applications, get_irp_n_irgs()));
734 }
735
736 ir_prog_pass_t *opt_tail_recursion_pass(const char *name)
737 {
738         return def_prog_pass(name ? name : "tailrec", opt_tail_recursion);
739 }