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