2d82a8f416f5493b048c0a3c0fa666f849e58fc0
[libfirm] / ir / be / bechordal_main.c
1 /**
2  * @file   bechordal_main.c
3  * @date   29.11.2005
4  * @author Sebastian Hack
5  *
6  * Copyright (C) 2005 Universitaet Karlsruhe
7  * Released under the GPL
8  *
9  * Driver for the chordal register allocator.
10  */
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14
15 #include "obst.h"
16 #include "pset.h"
17 #include "list.h"
18 #include "bitset.h"
19 #include "iterator.h"
20 #include "firm_config.h"
21
22 #ifdef WITH_LIBCORE
23 #include <libcore/lc_opts.h>
24 #include <libcore/lc_opts_enum.h>
25 #include <libcore/lc_timing.h>
26 #endif /* WITH_LIBCORE */
27
28 #include "irmode_t.h"
29 #include "irgraph_t.h"
30 #include "irprintf_t.h"
31 #include "irgwalk.h"
32 #include "irdump.h"
33 #include "irdom.h"
34 #include "irbitset.h"
35 #include "debug.h"
36 #include "xmalloc.h"
37 #include "execfreq.h"
38
39 #include "bechordal_t.h"
40 #include "beabi.h"
41 #include "beutil.h"
42 #include "besched.h"
43 #include "benumb_t.h"
44 #include "besched_t.h"
45 #include "belive_t.h"
46 #include "bearch.h"
47 #include "beifg_t.h"
48 #include "beifg_impl.h"
49
50 #include "bespillbelady.h"
51 #include "bespillmorgan.h"
52 #include "belower.h"
53
54 #ifdef WITH_ILP
55 #include "bespillilp.h"
56 #include "bespillremat.h"
57 #endif /* WITH_ILP */
58
59 #include "becopystat.h"
60 #include "becopyopt.h"
61 #include "bessadestr.h"
62 #include "beverify.h"
63
64 void be_ra_chordal_check(be_chordal_env_t *chordal_env) {
65         const arch_env_t *arch_env = chordal_env->birg->main_env->arch_env;
66         struct obstack ob;
67         pmap_entry *pme;
68         ir_node **nodes, *n1, *n2;
69         int i, o;
70         DEBUG_ONLY(firm_dbg_module_t *dbg = chordal_env->dbg;)
71
72         /* Collect all irns */
73         obstack_init(&ob);
74         pmap_foreach(chordal_env->border_heads, pme) {
75                 border_t *curr;
76                 struct list_head *head = pme->value;
77                 list_for_each_entry(border_t, curr, head, list)
78                         if (curr->is_def && curr->is_real)
79                                 if (arch_get_irn_reg_class(arch_env, curr->irn, -1) == chordal_env->cls)
80                                         obstack_ptr_grow(&ob, curr->irn);
81         }
82         obstack_ptr_grow(&ob, NULL);
83         nodes = (ir_node **) obstack_finish(&ob);
84
85         /* Check them */
86         for (i = 0, n1 = nodes[i]; n1; n1 = nodes[++i]) {
87                 const arch_register_t *n1_reg, *n2_reg;
88
89                 n1_reg = arch_get_irn_register(arch_env, n1);
90                 if (!arch_reg_is_allocatable(arch_env, n1, -1, n1_reg)) {
91                         DBG((dbg, 0, "Register %s assigned to %+F is not allowed\n", n1_reg->name, n1));
92                         assert(0 && "Register constraint does not hold");
93                 }
94                 for (o = i+1, n2 = nodes[o]; n2; n2 = nodes[++o]) {
95                         n2_reg = arch_get_irn_register(arch_env, n2);
96                         if (values_interfere(n1, n2) && n1_reg == n2_reg) {
97                                 DBG((dbg, 0, "Values %+F and %+F interfere and have the same register assigned: %s\n", n1, n2, n1_reg->name));
98                                 assert(0 && "Interfering values have the same color!");
99                         }
100                 }
101         }
102         obstack_free(&ob, NULL);
103 }
104
105 int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node *b)
106 {
107         if(env->ifg)
108                 return be_ifg_connected(env->ifg, a, b);
109         else
110                 return values_interfere(a, b);
111 }
112
113
114 static be_ra_chordal_opts_t options = {
115         BE_CH_DUMP_NONE,
116         BE_CH_SPILL_BELADY,
117         BE_CH_COPYMIN_HEUR2,
118         BE_CH_IFG_STD,
119         BE_CH_LOWER_PERM_SWAP,
120         BE_CH_VRFY_WARN,
121 };
122
123 static be_ra_timer_t ra_timer = {
124         NULL,
125         NULL,
126         NULL,
127         NULL,
128         NULL,
129         NULL,
130         NULL,
131         NULL,
132         NULL,
133         NULL,
134 };
135
136 #ifdef WITH_LIBCORE
137 static const lc_opt_enum_int_items_t spill_items[] = {
138         { "morgan", BE_CH_SPILL_MORGAN },
139         { "belady", BE_CH_SPILL_BELADY },
140 #ifdef WITH_ILP
141         { "ilp",    BE_CH_SPILL_ILP },
142         { "remat",  BE_CH_SPILL_REMAT },
143 #endif /* WITH_ILP */
144         { NULL, 0 }
145 };
146
147 static const lc_opt_enum_int_items_t copymin_items[] = {
148         { "none",  BE_CH_COPYMIN_NONE      },
149         { "heur1", BE_CH_COPYMIN_HEUR1     },
150         { "heur2", BE_CH_COPYMIN_HEUR2     },
151         { "stat",  BE_CH_COPYMIN_STAT      },
152         { "park",  BE_CH_COPYMIN_PARK_MOON },
153 #ifdef WITH_ILP
154         { "ilp1",  BE_CH_COPYMIN_ILP1 },
155         { "ilp2",  BE_CH_COPYMIN_ILP2 },
156 #endif /* WITH_ILP */
157         { NULL, 0 }
158 };
159
160 static const lc_opt_enum_int_items_t ifg_flavor_items[] = {
161         { "std",     BE_CH_IFG_STD     },
162         { "fast",    BE_CH_IFG_FAST    },
163         { "clique",  BE_CH_IFG_CLIQUE  },
164         { "pointer", BE_CH_IFG_POINTER },
165         { "list",    BE_CH_IFG_LIST    },
166         { "check",   BE_CH_IFG_CHECK   },
167         { NULL,      0                 }
168 };
169
170 static const lc_opt_enum_int_items_t lower_perm_items[] = {
171         { "copy", BE_CH_LOWER_PERM_COPY },
172         { "swap", BE_CH_LOWER_PERM_SWAP },
173         { NULL, 0 }
174 };
175
176 static const lc_opt_enum_int_items_t lower_perm_stat_items[] = {
177         { NULL, 0 }
178 };
179
180 static const lc_opt_enum_int_items_t dump_items[] = {
181         { "spill",    BE_CH_DUMP_SPILL     },
182         { "live",     BE_CH_DUMP_LIVE      },
183         { "color",    BE_CH_DUMP_COLOR     },
184         { "copymin",  BE_CH_DUMP_COPYMIN   },
185         { "ssadestr", BE_CH_DUMP_SSADESTR  },
186         { "tree",     BE_CH_DUMP_TREE_INTV },
187         { "constr",   BE_CH_DUMP_CONSTR    },
188         { "lower",    BE_CH_DUMP_LOWER     },
189         { "all",      BE_CH_DUMP_ALL       },
190         { NULL, 0 }
191 };
192
193 static const lc_opt_enum_int_items_t be_ch_vrfy_items[] = {
194         { "off",    BE_CH_VRFY_OFF    },
195         { "warn",   BE_CH_VRFY_WARN   },
196         { "assert", BE_CH_VRFY_ASSERT },
197         { NULL, 0 }
198 };
199
200 static lc_opt_enum_int_var_t spill_var = {
201         &options.spill_method, spill_items
202 };
203
204 static lc_opt_enum_int_var_t copymin_var = {
205         &options.copymin_method, copymin_items
206 };
207
208 static lc_opt_enum_int_var_t ifg_flavor_var = {
209         &options.ifg_flavor, ifg_flavor_items
210 };
211
212 static lc_opt_enum_int_var_t lower_perm_var = {
213         &options.lower_perm_opt, lower_perm_items
214 };
215
216 static lc_opt_enum_int_var_t dump_var = {
217         &options.dump_flags, dump_items
218 };
219
220 static lc_opt_enum_int_var_t be_ch_vrfy_var = {
221         &options.vrfy_option, be_ch_vrfy_items
222 };
223
224 static int be_copymin_stats = 0;
225
226 /** Assumed loop iteration count for execution frequency estimation. */
227 static int be_loop_weight = 9;
228
229 static const lc_opt_table_entry_t be_chordal_options[] = {
230         LC_OPT_ENT_ENUM_INT ("spill",           "spill method (belady, ilp, remat or appel)", &spill_var),
231         LC_OPT_ENT_ENUM_PTR ("copymin",       "copymin method (none, heur1, heur2, ilp1, ilp2 or stat)", &copymin_var),
232         LC_OPT_ENT_ENUM_PTR ("ifg",           "interference graph flavour (std, fast, clique, pointer, list, check)", &ifg_flavor_var),
233         LC_OPT_ENT_ENUM_PTR ("perm",          "perm lowering options (copy or swap)", &lower_perm_var),
234         LC_OPT_ENT_ENUM_MASK("dump",          "select dump phases", &dump_var),
235         LC_OPT_ENT_ENUM_PTR ("vrfy",          "verify options (off, warn, assert)", &be_ch_vrfy_var),
236         LC_OPT_ENT_BOOL     ("copymin_stats", "dump statistics of copy minimization", &be_copymin_stats),
237         LC_OPT_ENT_INT      ("loop_weight",   "assumed amount of loop iterations for guessing the execution frequency", &be_loop_weight),
238         { NULL }
239 };
240
241 static void be_ra_chordal_register_options(lc_opt_entry_t *grp)
242 {
243         static int run_once = 0;
244         lc_opt_entry_t *chordal_grp;
245
246         if (! run_once) {
247                 run_once    = 1;
248                 chordal_grp = lc_opt_get_grp(grp, "chordal");
249
250                 lc_opt_add_table(chordal_grp, be_chordal_options);
251         }
252
253         co_register_options(chordal_grp);
254 }
255 #endif /* WITH_LIBCORE */
256
257 static void dump(unsigned mask, ir_graph *irg,
258                                  const arch_register_class_t *cls,
259                                  const char *suffix,
260                                  void (*dump_func)(ir_graph *, const char *))
261 {
262         if((options.dump_flags & mask) == mask) {
263                 if (cls) {
264                         char buf[256];
265                         snprintf(buf, sizeof(buf), "-%s%s", cls->name, suffix);
266                         be_dump(irg, buf, dump_func);
267                 }
268                 else
269                         be_dump(irg, suffix, dump_func);
270         }
271 }
272
273 static void put_ignore_colors(be_chordal_env_t *chordal_env)
274 {
275         int n_colors = chordal_env->cls->n_regs;
276         int i;
277
278         bitset_clear_all(chordal_env->ignore_colors);
279         be_abi_put_ignore_regs(chordal_env->birg->abi, chordal_env->cls, chordal_env->ignore_colors);
280         for(i = 0; i < n_colors; ++i)
281                 if(arch_register_type_is(&chordal_env->cls->regs[i], ignore))
282                         bitset_set(chordal_env->ignore_colors, i);
283 }
284
285 FILE *be_chordal_open(const be_chordal_env_t *env, const char *prefix, const char *suffix)
286 {
287         char buf[1024];
288
289         ir_snprintf(buf, sizeof(buf), "%s%F_%s.%s", prefix, env->irg, env->cls->name, suffix);
290         return fopen(buf, "wt");
291 }
292
293 void check_ifg_implementations(be_chordal_env_t *chordal_env)
294 {
295         FILE *f;
296
297         f = be_chordal_open(chordal_env, "std", "log");
298         chordal_env->ifg = be_ifg_std_new(chordal_env);
299         be_ifg_check_sorted_to_file(chordal_env->ifg, f);
300         fclose(f);
301
302         f = be_chordal_open(chordal_env, "list", "log");
303         be_ifg_free(chordal_env->ifg);
304         chordal_env->ifg = be_ifg_list_new(chordal_env);
305         be_ifg_check_sorted_to_file(chordal_env->ifg, f);
306         fclose(f);
307
308         f = be_chordal_open(chordal_env, "clique", "log");
309         be_ifg_free(chordal_env->ifg);
310         chordal_env->ifg = be_ifg_clique_new(chordal_env);
311         be_ifg_check_sorted_to_file(chordal_env->ifg, f);
312         fclose(f);
313
314         f = be_chordal_open(chordal_env, "pointer", "log");
315         be_ifg_free(chordal_env->ifg);
316         chordal_env->ifg = be_ifg_pointer_new(chordal_env);
317         be_ifg_check_sorted_to_file(chordal_env->ifg, f);
318         fclose(f);
319
320         chordal_env->ifg = NULL;
321 };
322
323 static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi)
324 {
325         const be_main_env_t *main_env  = bi->main_env;
326         const arch_isa_t    *isa       = arch_env_get_isa(main_env->arch_env);
327         ir_graph            *irg       = bi->irg;
328         be_options_t        *main_opts = main_env->options;
329         copy_opt_t          *co;
330
331         int j, m;
332         be_chordal_env_t chordal_env;
333
334         if (main_opts->timing == BE_TIME_ON) {
335                 ra_timer.t_prolog  = lc_timer_register("prolog",   "regalloc prolog");
336                 ra_timer.t_epilog  = lc_timer_register("epilog",   "regalloc epilog");
337                 ra_timer.t_live    = lc_timer_register("liveness", "be liveness");
338                 ra_timer.t_spill   = lc_timer_register("spill",    "spiller");
339                 ra_timer.t_color   = lc_timer_register("color",    "graph coloring");
340                 ra_timer.t_ifg     = lc_timer_register("ifg",      "interference graph");
341                 ra_timer.t_copymin = lc_timer_register("copymin",  "copy minimization");
342                 ra_timer.t_ssa     = lc_timer_register("ssadestr", "ssa destruction");
343                 ra_timer.t_verify  = lc_timer_register("verify",   "graph verification");
344                 ra_timer.t_other   = lc_timer_register("other",    "other time");
345
346                 LC_STOP_AND_RESET_TIMER(ra_timer.t_prolog);
347                 LC_STOP_AND_RESET_TIMER(ra_timer.t_epilog);
348                 LC_STOP_AND_RESET_TIMER(ra_timer.t_live);
349                 LC_STOP_AND_RESET_TIMER(ra_timer.t_spill);
350                 LC_STOP_AND_RESET_TIMER(ra_timer.t_color);
351                 LC_STOP_AND_RESET_TIMER(ra_timer.t_ifg);
352                 LC_STOP_AND_RESET_TIMER(ra_timer.t_copymin);
353                 LC_STOP_AND_RESET_TIMER(ra_timer.t_ssa);
354                 LC_STOP_AND_RESET_TIMER(ra_timer.t_verify);
355                 LC_STOP_AND_RESET_TIMER(ra_timer.t_other);
356         }
357
358 #define BE_TIMER_PUSH(timer)  if (main_opts->timing == BE_TIME_ON) lc_timer_push(timer)
359 #define BE_TIMER_POP()        if (main_opts->timing == BE_TIME_ON) lc_timer_pop()
360
361         BE_TIMER_PUSH(ra_timer.t_other);
362         BE_TIMER_PUSH(ra_timer.t_prolog);
363
364         compute_doms(irg);
365
366         chordal_env.opts      = &options;
367         chordal_env.irg       = irg;
368         chordal_env.birg      = bi;
369         chordal_env.dom_front = be_compute_dominance_frontiers(irg);
370         chordal_env.exec_freq = compute_execfreq(irg, be_loop_weight);
371         FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
372
373         obstack_init(&chordal_env.obst);
374
375         BE_TIMER_POP();
376
377         /* Perform the following for each register class. */
378         for(j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) {
379                 FILE *f;
380                 chordal_env.cls           = arch_isa_get_reg_class(isa, j);
381                 chordal_env.border_heads  = pmap_create();
382                 chordal_env.ignore_colors = bitset_malloc(chordal_env.cls->n_regs);
383
384                 BE_TIMER_PUSH(ra_timer.t_live);
385
386                 /* put all ignore registers into the ignore register set. */
387                 put_ignore_colors(&chordal_env);
388
389                 be_liveness(irg);
390
391                 BE_TIMER_POP();
392
393                 dump(BE_CH_DUMP_LIVE, irg, chordal_env.cls, "-live", dump_ir_block_graph_sched);
394
395                 BE_TIMER_PUSH(ra_timer.t_spill);
396
397                 /* spilling */
398                 switch(options.spill_method) {
399                 case BE_CH_SPILL_MORGAN:
400                         be_spill_morgan(&chordal_env);
401                         break;
402                 case BE_CH_SPILL_BELADY:
403                         be_spill_belady(&chordal_env);
404                         break;
405 #ifdef WITH_ILP
406                 case BE_CH_SPILL_ILP:
407                         be_spill_ilp(&chordal_env);
408                         break;
409                 case BE_CH_SPILL_REMAT:
410                         be_spill_remat(&chordal_env);
411                         break;
412 #endif /* WITH_ILP */
413                 default:
414                         fprintf(stderr, "no valid spiller selected. falling back to belady\n");
415                         be_spill_belady(&chordal_env);
416                 }
417
418                 BE_TIMER_POP();
419
420                 dump(BE_CH_DUMP_SPILL, irg, chordal_env.cls, "-spill", dump_ir_block_graph_sched);
421                 be_abi_fix_stack_nodes(bi->abi);
422
423                 BE_TIMER_PUSH(ra_timer.t_verify);
424
425                 /* verify schedule and register pressure */
426                 if (options.vrfy_option == BE_CH_VRFY_WARN) {
427                         be_verify_schedule(irg);
428                         be_verify_register_pressure(chordal_env.birg->main_env->arch_env, chordal_env.cls, irg);
429                 }
430                 else if (options.vrfy_option == BE_CH_VRFY_ASSERT) {
431                         assert(be_verify_schedule(irg) && "Schedule verification failed");
432                         assert(be_verify_register_pressure(chordal_env.birg->main_env->arch_env, chordal_env.cls, irg)
433                                 && "Register pressure verification failed");
434                 }
435
436                 BE_TIMER_POP();
437                 BE_TIMER_PUSH(ra_timer.t_live);
438                 be_liveness(irg);
439                 BE_TIMER_POP();
440                 BE_TIMER_PUSH(ra_timer.t_color);
441
442                 /* Color the graph. */
443                 be_ra_chordal_color(&chordal_env);
444
445                 BE_TIMER_POP();
446
447                 dump(BE_CH_DUMP_CONSTR, irg, chordal_env.cls, "-color", dump_ir_block_graph_sched);
448
449                 BE_TIMER_PUSH(ra_timer.t_ifg);
450
451                 /* Create the ifg with the selected flavor */
452                 switch (options.ifg_flavor) {
453                         default:
454                                 fprintf(stderr, "no valid ifg flavour selected. falling back to std\n");
455                         case BE_CH_IFG_STD:
456                         case BE_CH_IFG_FAST:
457                                 chordal_env.ifg = be_ifg_std_new(&chordal_env);
458                                 break;
459                         case BE_CH_IFG_CLIQUE:
460                                 chordal_env.ifg = be_ifg_clique_new(&chordal_env);
461                                 break;
462                         case BE_CH_IFG_POINTER:
463                                 chordal_env.ifg = be_ifg_pointer_new(&chordal_env);
464                                 break;
465                         case BE_CH_IFG_LIST:
466                                 chordal_env.ifg = be_ifg_list_new(&chordal_env);
467                                 break;
468                         case BE_CH_IFG_CHECK:
469                                 check_ifg_implementations(&chordal_env);
470                                 /* Build the interference graph. */
471                                 chordal_env.ifg = be_ifg_std_new(&chordal_env);
472                                 break;
473                 }
474
475
476 #if 0
477                 {
478                         be_ifg_t *std = be_ifg_std_new(&chordal_env);
479                         f = be_chordal_open(&chordal_env, "std", "csv");
480                         be_ifg_check_sorted_to_file(std, f);
481                         be_ifg_free(std);
482                         fclose(f);
483                 }
484
485                 f = be_chordal_open(&chordal_env, "clique", "csv");
486                 be_ifg_check_sorted_to_file(chordal_env.ifg, f);
487                 fclose(f);
488 #endif
489                 BE_TIMER_POP();
490
491                 BE_TIMER_PUSH(ra_timer.t_verify);
492
493                 if (options.vrfy_option != BE_CH_VRFY_OFF)
494                         be_ra_chordal_check(&chordal_env);
495
496 //              be_ifg_check_sorted(chordal_env.ifg);
497                 BE_TIMER_POP();
498                 BE_TIMER_PUSH(ra_timer.t_copymin);
499
500                 /* copy minimization */
501                 co = NULL;
502                 if (options.copymin_method != BE_CH_COPYMIN_NONE && options.copymin_method != BE_CH_COPYMIN_STAT) {
503                         FILE *f;
504                         co = new_copy_opt(&chordal_env, co_get_costs_loop_depth);
505                         co_build_ou_structure(co);
506                         co_build_graph_structure(co);
507                         if(be_copymin_stats) {
508                                 ir_printf("%40F %20s\n", current_ir_graph, chordal_env.cls->name);
509                                 printf("max copy costs:         %d\n", co_get_max_copy_costs(co));
510                                 printf("init copy costs:        %d\n", co_get_copy_costs(co));
511                                 printf("inevit copy costs:      %d\n", co_get_inevit_copy_costs(co));
512                                 printf("copy costs lower bound: %d\n", co_get_lower_bound(co));
513                         }
514
515 #if 0
516                         f = be_chordal_open(&chordal_env, "appel-", "apl");
517                         co_dump_appel_graph(co, f);
518                         fclose(f);
519                         f = be_chordal_open(&chordal_env, "appel-clique-", "p");
520                         co_dump_appel_graph_cliques(co, f);
521                         fclose(f);
522 #endif
523                 }
524
525                 switch(options.copymin_method) {
526                         case BE_CH_COPYMIN_HEUR1:
527                                 co_solve_heuristic(co);
528                                 break;
529                         case BE_CH_COPYMIN_HEUR2:
530                                 co_solve_heuristic_new(co);
531                                 break;
532                         case BE_CH_COPYMIN_PARK_MOON:
533                                 co_solve_park_moon(co);
534                                 break;
535                         case BE_CH_COPYMIN_STAT:
536                                 co_compare_solvers(&chordal_env);
537                                 break;
538 #ifdef WITH_ILP
539                         case BE_CH_COPYMIN_ILP1:
540                                 printf("FIXME: %s:%d ILP1 not yet implemented!\n", __FILE__, __LINE__);
541                                 co_solve_ilp1(co, 60.0);
542                                 break;
543                         case BE_CH_COPYMIN_ILP2:
544                                 co_solve_ilp2(co, 60.0);
545                                 break;
546 #endif /* WITH_ILP */
547                         case BE_CH_COPYMIN_NONE:
548                         default:
549                                 break;
550                 }
551
552                 if (co) {
553                         if(be_copymin_stats) {
554                                 printf("final copy costs      : %d\n", co_get_copy_costs(co));
555                         }
556                         co_free_graph_structure(co);
557                         co_free_ou_structure(co);
558                         free_copy_opt(co);
559                 }
560
561                 BE_TIMER_POP();
562
563                 dump(BE_CH_DUMP_COPYMIN, irg, chordal_env.cls, "-copymin", dump_ir_block_graph_sched);
564
565                 BE_TIMER_PUSH(ra_timer.t_verify);
566
567                 if (options.vrfy_option != BE_CH_VRFY_OFF)
568                         be_ra_chordal_check(&chordal_env);
569
570                 BE_TIMER_POP();
571                 BE_TIMER_PUSH(ra_timer.t_ssa);
572
573                 /* ssa destruction */
574                 be_ssa_destruction(&chordal_env);
575
576                 BE_TIMER_POP();
577
578                 dump(BE_CH_DUMP_SSADESTR, irg, chordal_env.cls, "-ssadestr", dump_ir_block_graph_sched);
579
580                 BE_TIMER_PUSH(ra_timer.t_verify);
581                 if (options.vrfy_option != BE_CH_VRFY_OFF) {
582                         be_ssa_destruction_check(&chordal_env);
583                         be_ra_chordal_check(&chordal_env);
584                 }
585                 BE_TIMER_POP();
586
587                 if (options.copymin_method == BE_CH_COPYMIN_STAT)
588                         copystat_dump(irg);
589
590                 be_ifg_free(chordal_env.ifg);
591                 pmap_destroy(chordal_env.border_heads);
592                 bitset_free(chordal_env.ignore_colors);
593         }
594
595         BE_TIMER_PUSH(ra_timer.t_epilog);
596
597         be_compute_spill_offsets(&chordal_env);
598
599         dump(BE_CH_DUMP_LOWER, irg, NULL, "-spilloff", dump_ir_block_graph_sched);
600
601         lower_nodes_after_ra(&chordal_env, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
602         dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
603
604         obstack_free(&chordal_env.obst, NULL);
605         be_free_dominance_frontiers(chordal_env.dom_front);
606         free_execfreq(chordal_env.exec_freq);
607
608         BE_TIMER_POP();
609         BE_TIMER_POP();
610
611 #undef BE_TIMER_PUSH
612 #undef BE_TIMER_POP
613
614         return main_opts->timing == BE_TIME_ON ? &ra_timer : NULL;
615 }
616
617 const be_ra_t be_ra_chordal_allocator = {
618 #ifdef WITH_LIBCORE
619         be_ra_chordal_register_options,
620 #endif
621         be_ra_chordal_main
622 };