Because otherwise we confuse users with free_ir_graph vs.
remove_irp_irg. Change it so that free_ir_graph also removes the graph
from the irp list.
/** Sets the main routine of the compiled program. */
FIRM_API void set_irp_main_irg(ir_graph *main_irg);
-/** Adds irg to the list of ir graphs in the current irp. */
-FIRM_API void add_irp_irg(ir_graph *irg);
-
-/** Removes irg from the list of irgs and
- shrinks the list by one. */
-FIRM_API void remove_irp_irg_from_list(ir_graph *irg);
-/** Removes irg from the list of irgs, deallocates it and
- shrinks the list by one. */
-FIRM_API void remove_irp_irg(ir_graph *irg);
-
/** returns the biggest not used irg index number */
FIRM_API size_t get_irp_last_idx(void);
assert(is_ir_graph(irg));
edges_deactivate(irg);
+ remove_irp_irg(irg);
hook_free_graph(irg);
free_irg_outs(irg);
void free_ir_prog(void)
{
+ if (irp == NULL)
+ return;
+
size_t i;
/* must iterate backwards here */
for (i = get_irp_n_irgs(); i > 0;)
ARR_APP1(ir_graph *, irp->graphs, irg);
}
-void remove_irp_irg_from_list(ir_graph *irg)
+void remove_irp_irg(ir_graph *irg)
{
size_t i, l;
}
}
-void remove_irp_irg(ir_graph *irg)
-{
- free_ir_graph(irg);
- remove_irp_irg_from_list(irg);
-}
-
size_t (get_irp_n_irgs)(void)
{
return get_irp_n_irgs_();
shrinks the list by one. */
void remove_irp_type(ir_type *typ);
+/** Adds irg to the list of ir graphs in the current irp. */
+FIRM_API void add_irp_irg(ir_graph *irg);
+
+/** Removes irg from the list of irgs and
+ shrinks the list by one. */
+FIRM_API void remove_irp_irg(ir_graph *irg);
+
/* Inline functions. */
#define get_irp_n_irgs() get_irp_n_irgs_()
#define get_irp_irg(pos) get_irp_irg_(pos)
}
/* remove graphs of non-visited functions
- * (we have to count backwards so we can safely call remove_irp_irg
- * while iterating) */
+ * (we have to count backwards, because freeing the graph moves the last
+ * graph in the list to the free position) */
for (i = get_irp_n_irgs(); i > 0;) {
ir_graph *irg = get_irp_irg(--i);
ir_entity *entity = get_irg_entity(irg);
continue;
DB((dbg, LEVEL_1, " freeing method %+F\n", entity));
- remove_irp_irg(irg);
+ free_ir_graph(irg);
}
/* we can now remove all non-visited (global) entities */
void gc_irgs(size_t n_keep, ir_entity ** keep_arr)
{
void * MARK = &MARK; /* @@@ gefaehrlich!!! Aber wir markieren hoechstens zu viele ... */
- size_t i, n;
FIRM_DBG_REGISTER(dbg, "firm.opt.cgopt");
}
/* clean */
- for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
+ for (size_t i = get_irp_n_irgs()-1; i-- > 0; ) {
ir_graph *irg = get_irp_irg(i);
ir_entity *ent = get_irg_entity(irg);
continue;
DB((dbg, LEVEL_1, " freeing method %+F\n", ent));
- remove_irp_irg(irg);
-
- free_entity(ent);
+ free_ir_graph(irg);
}
}