2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief MIN-algorithm with some twists (aka belady spiller v3)
23 * @author Matthias Braun
28 * - handle phis correctly, decide whether we should spill them ~ok
29 * - merge multiple start worksets of blocks ~ok
30 * - how to and when to do the tentative phase...
44 #include "iredges_t.h"
52 #include "bespilloptions.h"
53 #include "besched_t.h"
56 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
58 typedef struct loop_edge_t loop_edge_t;
65 typedef struct loop_info_t loop_info_t;
67 loop_edge_t *entry_edges;
68 loop_edge_t *exit_edges;
69 size_t max_register_pressure;
72 typedef struct worklist_entry_t worklist_entry_t;
73 struct worklist_entry_t {
74 struct list_head head;
76 ir_node *reload_point;
77 worklist_entry_t *next_reload;
80 typedef struct worklist_t worklist_t;
82 struct list_head live_values;
86 typedef struct block_info_t block_info_t;
88 worklist_t *start_worklist;
89 worklist_t *end_worklist;
92 static const arch_env_t *arch_env;
93 static const arch_register_class_t *cls;
94 static struct obstack obst;
95 static spill_env_t *senv;
97 static size_t max_register_pressure;
98 static bool tentative_mode;
99 static bool should_have_reached_fixpoint;
100 static ir_exec_freq *exec_freq;
102 static worklist_t *new_worklist(void)
104 worklist_t *worklist = obstack_alloc(&obst, sizeof(worklist[0]));
106 INIT_LIST_HEAD(&worklist->live_values);
107 worklist->n_live_values = 0;
112 static void mark_irn_not_visited(ir_node *node)
114 set_irn_visited(node, get_irg_visited(current_ir_graph) - 1);
117 static bool worklist_contains(const ir_node *node)
119 return irn_visited(node);
122 static block_info_t *get_block_info(ir_node *block)
124 block_info_t *info = get_irn_link(block);
128 info = obstack_alloc(&obst, sizeof(info[0]));
129 memset(info, 0, sizeof(info[0]));
130 set_irn_link(block, info);
134 static void deactivate_worklist(const worklist_t *worklist)
136 struct list_head *entry;
138 list_for_each(entry, &worklist->live_values) {
139 worklist_entry_t *wl_entry
140 = list_entry(entry, worklist_entry_t, head);
141 assert(worklist_contains(wl_entry->value));
142 mark_irn_not_visited(wl_entry->value);
143 set_irn_link(wl_entry->value, NULL);
147 static void activate_worklist(const worklist_t *worklist)
149 struct list_head *entry;
151 list_for_each(entry, &worklist->live_values) {
152 worklist_entry_t *wl_entry
153 = list_entry(entry, worklist_entry_t, head);
154 assert(!worklist_contains(wl_entry->value));
155 mark_irn_visited(wl_entry->value);
156 set_irn_link(wl_entry->value, wl_entry);
161 * duplicate a worklist and directly activates it
163 static worklist_t *duplicate_activate_worklist(const worklist_t *worklist,
164 ir_node *block, ir_node *succ_block, int succ_pos)
166 ir_node *reload_point = NULL;
167 size_t n_live_values = 0;
168 worklist_t *new_worklist;
169 struct list_head *entry;
171 if (succ_block != NULL &&
172 (get_Block_n_cfgpreds(succ_block) > 1
173 || get_irn_n_edges_kind(block, EDGE_KIND_BLOCK) > 1)) {
174 reload_point = be_get_end_of_block_insertion_point(block);
177 new_worklist = obstack_alloc(&obst, sizeof(new_worklist[0]));
178 INIT_LIST_HEAD(&new_worklist->live_values);
180 list_for_each(entry, &worklist->live_values) {
181 worklist_entry_t *wl_entry = list_entry(entry, worklist_entry_t, head);
182 ir_node *value = wl_entry->value;
183 worklist_entry_t *new_entry;
185 if (is_Phi(value) && get_nodes_block(value) == succ_block) {
186 value = get_Phi_pred(value, succ_pos);
188 /* can happen for unknown phi preds */
189 if (!arch_irn_consider_in_reg_alloc(arch_env, cls, value))
193 new_entry = obstack_alloc(&obst, sizeof(new_entry[0]));
194 new_entry->value = value;
195 if (reload_point != NULL) {
196 new_entry->reload_point = reload_point;
198 new_entry->reload_point = wl_entry->reload_point;
200 new_entry->next_reload = NULL;
202 if (irn_not_visited(value)) {
203 list_add_tail(&new_entry->head, &new_worklist->live_values);
206 mark_irn_visited(value);
207 set_irn_link(value, new_entry);
211 /* the only way we might visit a value again, is when we get it as
213 assert(is_Phi(wl_entry->value)
214 && get_nodes_block(wl_entry->value) == succ_block);
218 new_worklist->n_live_values = n_live_values;
223 static worklist_t *duplicate_worklist(const worklist_t *worklist)
225 worklist_t *new_worklist;
226 struct list_head *entry;
228 new_worklist = obstack_alloc(&obst, sizeof(new_worklist[0]));
229 INIT_LIST_HEAD(&new_worklist->live_values);
230 new_worklist->n_live_values = worklist->n_live_values;
232 list_for_each(entry, &worklist->live_values) {
233 worklist_entry_t *wl_entry = list_entry(entry, worklist_entry_t, head);
234 worklist_entry_t *new_entry
235 = obstack_alloc(&obst, sizeof(new_entry[0]));
237 memcpy(new_entry, wl_entry, sizeof(new_entry[0]));
238 list_add_tail(&new_entry->head, &new_worklist->live_values);
245 static void print_worklist(const worklist_t *worklist, int level)
247 struct list_head *entry;
249 DB((dbg, level, "%d values: ", worklist->n_live_values));
250 list_for_each(entry, &worklist->live_values) {
251 worklist_entry_t *wl_entry
252 = list_entry(entry, worklist_entry_t, head);
254 DB((dbg, level, "%+F ", wl_entry->value));
261 static void clear_loop_info(ir_loop *loop)
263 int n_elements = get_loop_n_elements(loop);
267 for (i = 0; i < n_elements; ++i) {
268 loop_element element = get_loop_element(loop, i);
269 if (*element.kind != k_ir_loop)
272 clear_loop_info(element.son);
276 static loop_info_t *get_loop_info(ir_loop *loop)
278 loop_info_t *info = loop->link;
282 info = obstack_alloc(&obst, sizeof(info[0]));
283 memset(info, 0, sizeof(info[0]));
289 * constructs loop in+out edges when called in a block walker
291 static void construct_loop_edges(ir_node *block, void *data)
293 int n_cfgpreds = get_Block_n_cfgpreds(block);
294 ir_loop *loop = get_irn_loop(block);
299 for (i = 0; i < n_cfgpreds; ++i) {
300 ir_node *cfgpred_block = get_Block_cfgpred_block(block, i);
301 ir_loop *cfgpred_loop = get_irn_loop(cfgpred_block);
306 if (cfgpred_loop == loop)
309 /* critical edges are splitted, so we can't jump from 1 loop
310 * directly into another without going out of it */
311 assert(get_loop_depth(cfgpred_loop) != get_loop_depth(loop));
313 /* edge out of loop */
314 if (get_loop_depth(cfgpred_loop) > get_loop_depth(loop)) {
319 is_exit_edge = false;
324 /* this might be a jump out/in multiple loops */
326 loop_info_t *l_info = get_loop_info(l);
328 edge = obstack_alloc(&obst, sizeof(edge[0]));
329 memset(edge, 0, sizeof(edge[0]));
334 ir_fprintf(stderr, "Loop %p exit edge %+F:%d\n",
336 edge->next = l_info->exit_edges;
337 l_info->exit_edges = edge;
338 assert(get_loop_depth(loop) < get_loop_depth(l));
340 ir_fprintf(stderr, "Loop %p entry edge %+F:%d\n",
342 edge->next = l_info->entry_edges;
343 l_info->entry_edges = edge;
344 assert(get_loop_depth(cfgpred_loop) < get_loop_depth(l));
346 l = get_loop_outer_loop(l);
354 static void place_reload(worklist_entry_t *entry)
359 /* walk list of reload points */
361 DB((dbg, LEVEL_1, "reload of %+F before %+F\n", entry->value,
362 entry->reload_point));
363 assert(entry->reload_point != NULL);
364 be_add_reload(senv, entry->value, entry->reload_point, cls, 1);
365 entry->reload_point = NULL;
367 entry = entry->next_reload;
368 } while(entry != NULL);
373 * does stuff required for non-active worklists: spills all values not live
374 * in the active worklist; links live values to the current worklist
376 static void process_non_active_worklist(const worklist_t *worklist,
377 worklist_t *current_worklist)
379 struct list_head *entry;
381 list_for_each(entry, &worklist->live_values) {
382 worklist_entry_t *wl_entry = list_entry(entry, worklist_entry_t, head);
383 ir_node *value = wl_entry->value;
385 if (!worklist_contains(value)) {
386 /* if we still have room in the worklist, then we can simply take
388 if (current_worklist->n_live_values < n_regs) {
389 worklist_entry_t *new_entry
390 = obstack_alloc(&obst, sizeof(new_entry[0]));
392 new_entry->value = value;
393 new_entry->reload_point = wl_entry->reload_point;
394 new_entry->next_reload = wl_entry->next_reload;
395 set_irn_link(value, new_entry);
396 mark_irn_visited(value);
397 list_add(&new_entry->head, ¤t_worklist->live_values);
398 ++current_worklist->n_live_values;
400 /* value is not in current worklist, place reloads */
401 place_reload(wl_entry);
404 /* value is in current worklist, link it with the reload point
406 worklist_entry_t *active_entry = get_irn_link(value);
407 wl_entry->next_reload = active_entry->next_reload;
408 active_entry->next_reload = wl_entry;
415 * makes sure the worklist contains not more than n_regs - room_needed entries
417 static void make_room(worklist_t *worklist, size_t room_needed)
421 struct list_head *entry;
423 spills_needed = worklist->n_live_values + room_needed - n_regs;
424 if (spills_needed <= 0)
427 entry = worklist->live_values.next;
428 for(i = spills_needed; i > 0; --i) {
429 struct list_head *next = entry->next;
430 worklist_entry_t *wl_entry
431 = list_entry(entry, worklist_entry_t, head);
433 assert(worklist_contains(wl_entry->value));
434 mark_irn_not_visited(wl_entry->value);
435 place_reload(wl_entry);
440 worklist->n_live_values -= spills_needed;
444 * a value was used, so bring it to the back of the worklist (which might
445 * result in a spill of another value).
447 static void val_used(worklist_t *worklist, ir_node *value, ir_node *sched_point)
449 /* already in the worklist? move around, otherwise add at back */
450 worklist_entry_t *entry = get_irn_link(value);
452 assert(arch_irn_consider_in_reg_alloc(arch_env, cls, value));
454 if (worklist_contains(value)) {
455 assert(entry != NULL);
457 list_del(&entry->head);
460 entry = obstack_alloc(&obst, sizeof(entry[0]));
461 entry->value = value;
462 set_irn_link(value, entry);
465 ++worklist->n_live_values;
466 mark_irn_visited(value);
469 entry->reload_point = sched_point;
470 entry->next_reload = NULL;
471 list_add_tail(&entry->head, &worklist->live_values);
474 static void worklist_remove(worklist_t *worklist, ir_node *value)
476 worklist_entry_t *entry = get_irn_link(value);
477 assert(entry != NULL);
478 list_del(&entry->head);
479 --worklist->n_live_values;
481 assert(worklist_contains(value));
482 mark_irn_not_visited(value);
485 static void update_max_pressure(worklist_t *worklist)
487 if (worklist->n_live_values > max_register_pressure)
488 max_register_pressure = worklist->n_live_values;
491 static void do_spilling(ir_node *block, worklist_t *worklist)
495 assert(worklist != NULL);
497 sched_foreach_reverse(block, node) {
501 DB((dbg, LEVEL_2, "\t%+F... ", node));
502 update_max_pressure(worklist);
506 /* TODO: if we have some free registers, then we could decide to
507 * not spill some phis (but not for phis where at least 1 input is
510 /* we have to spill all phis that are not live */
511 sched_foreach_reverse_from(node, node2) {
512 assert(is_Phi(node2));
514 if (worklist_contains(node2))
516 if (!arch_irn_consider_in_reg_alloc(arch_env, cls, node2))
520 be_spill_phi(senv, node2);
522 DB((dbg, LEVEL_2, "\n"));
526 /* remove values defined by this instruction from the workset. Values
527 * defined but not in the workset need free registers */
528 if (get_irn_mode(node) == mode_T) {
529 const ir_edge_t *edge;
531 foreach_out_edge(node, edge) {
532 ir_node *proj = get_edge_src_irn(edge);
533 if (!arch_irn_consider_in_reg_alloc(arch_env, cls, proj))
535 if (worklist_contains(proj)) {
536 worklist_remove(worklist, proj);
541 } else if (arch_irn_consider_in_reg_alloc(arch_env, cls, node)) {
542 if (worklist_contains(node)) {
543 worklist_remove(worklist, node);
549 /* make sure we have enough free registers for the spills */
550 make_room(worklist, n_defs);
552 /* put all values used by the instruction into the workset */
553 arity = get_irn_arity(node);
554 for(i = 0; i < arity; ++i) {
555 ir_node *use = get_irn_n(node, i);
557 if (!arch_irn_consider_in_reg_alloc(arch_env, cls, use))
560 val_used(worklist, use, node);
563 /* we might have too many values in the worklist now and need to spill
565 make_room(worklist, 0);
568 print_worklist(worklist, LEVEL_2);
569 DB((dbg, LEVEL_2, "\n"));
573 update_max_pressure(worklist);
576 DB((dbg, LEVEL_1, "worklist at begin of %+F:", block));
577 print_worklist(worklist, LEVEL_1);
578 DB((dbg, LEVEL_1, "\n"));
582 static bool worklists_equal(const worklist_t *wl1, const worklist_t *wl2)
584 const struct list_head *i1 = &wl1->live_values;
585 const struct list_head *i2 = &wl2->live_values;
587 for ( ; i1 != &wl1->live_values && i2 != &wl2->live_values;
588 i1 = i1->next, i2 = i2->next) {
589 worklist_entry_t *entry1 = list_entry(i1, worklist_entry_t, head);
590 worklist_entry_t *entry2 = list_entry(i2, worklist_entry_t, head);
592 if (entry1->value != entry2->value)
595 /* both lists at the end */
596 if (i1 != &wl1->live_values || i2 != &wl2->live_values)
602 static void process_block(ir_node *block, void *env)
604 block_info_t *block_info = NULL;
605 worklist_t *worklist = NULL;
606 double best_execfreq = -1;
607 ir_node *best_succ_block = NULL;
610 const ir_edge_t *edge;
613 DB((dbg, LEVEL_1, "Processing %+F\n", block));
615 /* construct worklist */
616 foreach_block_succ(block, edge) {
617 ir_node *succ_block = get_edge_src_irn(edge);
618 double execfreq = get_block_execfreq(exec_freq, succ_block);
620 if (execfreq > best_execfreq) {
621 block_info_t *block_info = get_block_info(succ_block);
622 worklist_t *succ_worklist = block_info->start_worklist;
623 if (succ_worklist != NULL) {
624 best_execfreq = execfreq;
625 worklist = succ_worklist;
626 best_succ_block = succ_block;
627 best_pos = get_edge_src_pos(edge);
631 if (worklist == NULL) {
632 /* at least 1 successor block must have been processed unless it was
634 assert(tentative_mode || block == get_irg_end_block(get_irn_irg(block)));
636 worklist = new_worklist();
638 worklist = duplicate_activate_worklist(worklist, block, best_succ_block,
641 /* handle this in fix_blocks later... */
643 /* now we could have live values in the succ worklists that are not
644 * live anymore in the worklist we picked. We need reloads for them. */
645 foreach_block_succ(block, edge) {
646 ir_node *succ_block = get_edge_src_irn(edge);
647 block_info_t *block_info = get_block_info(succ_block);
648 worklist_t *succ_worklist = block_info->start_worklist;
650 if (succ_block == best_succ_block)
653 process_non_active_worklist(succ_worklist, worklist);
658 block_info = get_block_info(block);
661 DB((dbg, LEVEL_1, "worklist at end of %+F:", block));
662 print_worklist(worklist, LEVEL_1);
663 DB((dbg, LEVEL_1, "\n"));
665 if (should_have_reached_fixpoint) {
666 assert(worklists_equal(block_info->end_worklist, worklist));
669 block_info->end_worklist = duplicate_worklist(worklist);
671 do_spilling(block, worklist);
672 deactivate_worklist(worklist);
675 if (should_have_reached_fixpoint) {
676 assert(worklists_equal(block_info->start_worklist, worklist));
679 block_info->start_worklist = worklist;
681 /* we shouldn't have any live values left at the start block */
682 n_preds = get_Block_n_cfgpreds(block);
683 assert(n_preds != 0 || worklist->n_live_values == 0);
686 typedef struct block_or_loop_t block_or_loop_t;
687 struct block_or_loop_t {
695 static block_or_loop_t *loop_blocks;
696 static ir_loop *current_loop;
698 static void find_blocks(ir_node *block);
700 static void find_in_loop(ir_loop *loop, ir_node *entry)
702 loop_info_t *loop_info = get_loop_info(loop);
703 block_or_loop_t block_or_loop;
706 /* simply mark 1 block in the loop to indicate that the loop was already
708 ir_node *some_block = loop_info->entry_edges->block;
709 if (Block_block_visited(some_block))
712 block_or_loop.v.loop = loop;
713 block_or_loop.is_loop = true;
714 ARR_APP1(block_or_loop_t, loop_blocks, block_or_loop);
718 /* we should be 1 of the entry blocks */
719 loop_edge_t *edge = loop_info->entry_edges;
721 for ( ; edge != NULL; edge = edge->next) {
722 if (edge->block == entry)
728 /* check all loop successors */
729 for (edge = loop_info->exit_edges; edge != NULL; edge = edge->next) {
730 ir_node *succ = edge->block;
731 ir_loop *succ_loop = get_irn_loop(succ);
733 if (succ_loop == current_loop) {
736 assert(get_loop_depth(succ_loop) < get_loop_depth(current_loop));
741 static void find_blocks(ir_node *block)
743 const ir_edge_t *edge;
744 block_or_loop_t block_or_loop;
746 if (Block_block_visited(block))
749 block_or_loop.v.block = block;
750 block_or_loop.is_loop = false;
752 ARR_APP1(block_or_loop_t, loop_blocks, block_or_loop);
753 mark_Block_block_visited(block);
755 foreach_block_succ(block, edge) {
756 ir_node *succ = get_edge_src_irn(edge);
758 /* is it part of the current loop? */
759 ir_loop *loop = get_irn_loop(succ);
760 if (loop != current_loop) {
762 if (get_loop_depth(loop) > get_loop_depth(current_loop)) {
763 find_in_loop(loop, succ);
765 /* parent loop: we're not interested in the block */
773 static void process_block_or_loop(const block_or_loop_t *block_or_loop)
775 if (block_or_loop->is_loop) {
776 loop_info_t *loop_info = get_loop_info(block_or_loop->v.loop);
778 if (loop_info->max_register_pressure > max_register_pressure)
779 max_register_pressure = loop_info->max_register_pressure;
781 /* TODO: push unused livethroughs... */
784 process_block(block_or_loop->v.block, NULL);
787 static void process_loop(ir_loop *loop)
789 int n_elements = get_loop_n_elements(loop);
791 loop_info_t *loop_info;
795 /* first handle all sub-loops */
796 for (i = 0; i < n_elements; ++i) {
797 loop_element element = get_loop_element(loop, i);
798 if (*element.kind != k_ir_loop)
801 process_loop(element.son);
804 /* create a postorder of the blocks */
805 loop_info = get_loop_info(loop);
806 edge = loop_info->entry_edges;
808 some_block = edge->block;
810 assert(loop == get_irg_loop(current_ir_graph));
811 some_block = get_irg_start_block(current_ir_graph);
814 loop_blocks = NEW_ARR_F(block_or_loop_t,0);
817 ir_reserve_resources(current_ir_graph, IR_RESOURCE_BLOCK_VISITED);
818 inc_irg_block_visited(current_ir_graph);
819 find_blocks(some_block);
820 /* for endless loops the end-block might be unreachable */
821 if (loop == get_irg_loop(current_ir_graph)) {
822 find_blocks(get_irg_end_block(current_ir_graph));
824 ir_free_resources(current_ir_graph, IR_RESOURCE_BLOCK_VISITED);
826 fprintf(stderr, "Block List for loop %p\n", loop);
827 len = ARR_LEN(loop_blocks);
828 for (i = 0; i < len; ++i) {
829 block_or_loop_t *block_or_loop = &loop_blocks[i];
830 if (block_or_loop->is_loop) {
831 ir_fprintf(stderr, " L-%p", block_or_loop->v.loop);
833 ir_fprintf(stderr, " B-%+F", block_or_loop->v.block);
836 fprintf(stderr, "\n");
838 max_register_pressure = 0;
840 /* run1: tentative phase */
841 tentative_mode = true;
842 for (i = len-1; i >= 0; --i) {
843 process_block_or_loop(&loop_blocks[i]);
846 /* run2: tentative phase - should reach fixpoint */
847 tentative_mode = true;
848 for (i = len-1; i >= 0; --i) {
849 process_block_or_loop(&loop_blocks[i]);
853 /* run3: tentative phase - check fixpoint */
854 tentative_mode = true;
855 should_have_reached_fixpoint = true;
856 for (i = len-1; i >= 0; --i) {
857 process_block_or_loop(&loop_blocks[i]);
859 should_have_reached_fixpoint = false;
862 /* run4: add spills/reloads */
863 tentative_mode = false;
864 for (i = len-1; i >= 0; --i) {
865 process_block_or_loop(&loop_blocks[i]);
868 loop_info->max_register_pressure = max_register_pressure;
869 ir_fprintf(stderr, "Regpressure in loop %p: %u\n", loop,
870 (unsigned) max_register_pressure);
872 DEL_ARR_F(loop_blocks);
875 static void fix_block_borders(ir_node *block, void *data)
877 block_info_t *block_info = get_block_info(block);
878 worklist_t *start_worklist = block_info->start_worklist;
879 int n_cfgpreds = get_Block_n_cfgpreds(block);
883 assert(start_worklist != NULL);
885 for (i = 0; i < n_cfgpreds; ++i) {
886 ir_node *pred_block = get_Block_cfgpred_block(block, i);
887 block_info_t *pred_block_info = get_block_info(pred_block);
888 worklist_t *end_worklist = pred_block_info->end_worklist;
889 struct list_head *entry;
891 assert(end_worklist != NULL);
893 /* reload missing values */
894 activate_worklist(end_worklist);
896 list_for_each(entry, &start_worklist->live_values) {
897 worklist_entry_t *wl_entry
898 = list_entry(entry, worklist_entry_t, head);
899 ir_node *value = wl_entry->value;
901 if (is_Phi(value) && get_nodes_block(value) == block) {
902 value = get_irn_n(value, i);
904 /* we might have unknowns as argument for the phi */
905 if (!arch_irn_consider_in_reg_alloc(arch_env, cls, value))
909 if (worklist_contains(value))
912 be_add_reload_on_edge(senv, value, block, i, cls, 1);
915 deactivate_worklist(end_worklist);
919 static void be_spill_belady3(be_irg_t *birg, const arch_register_class_t *ncls)
921 ir_graph *irg = be_get_birg_irg(birg);
924 n_regs = cls->n_regs - be_put_ignore_regs(birg, cls, NULL);
926 /* shortcut for register classes with ignore regs only */
930 arch_env = be_get_birg_arch_env(birg);
931 exec_freq = be_get_birg_exec_freq(birg);
934 ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED | IR_RESOURCE_IRN_LINK
935 | IR_RESOURCE_LOOP_LINK);
936 inc_irg_visited(irg);
939 senv = be_new_spill_env(birg);
942 clear_loop_info(get_irg_loop(irg));
943 irg_block_walk_graph(irg, construct_loop_edges, NULL, NULL);
945 process_loop(get_irg_loop(current_ir_graph));
948 /* do a post-order walk over the CFG to make sure we have a maximum number
949 * of preds processed before entering a block */
951 irg_block_edges_walk(get_irg_start_block(irg), NULL, process_block, NULL);
954 irg_block_edges_walk(get_irg_start_block(irg), NULL, process_block, NULL);
957 irg_block_edges_walk(get_irg_start_block(irg), NULL, process_block, NULL);
960 irg_block_walk_graph(irg, fix_block_borders, NULL, NULL);
962 ir_free_resources(irg, IR_RESOURCE_IRN_VISITED | IR_RESOURCE_IRN_LINK
963 | IR_RESOURCE_LOOP_LINK);
965 be_insert_spills_reloads(senv);
967 obstack_free(&obst, NULL);
970 be_delete_spill_env(senv);
973 void be_init_spillbelady3(void)
975 static be_spiller_t belady3_spiller = {
979 be_register_spiller("belady3", &belady3_spiller);
980 FIRM_DBG_REGISTER(dbg, "firm.be.spill.belady3");
983 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spillbelady3);