X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fgarbage_collect.c;h=4892264a86a773af53a0e10a5147fbba2f800c57;hb=6be797281b157f8f71b9c47d28b3d09f2a7918cc;hp=9f32c64e902bca898c274ef12515a4bc5dbd19d7;hpb=1c4973a049cd4a443446fcd77b1d3a4b43b46d95;p=libfirm diff --git a/ir/opt/garbage_collect.c b/ir/opt/garbage_collect.c index 9f32c64e9..4892264a8 100644 --- a/ir/opt/garbage_collect.c +++ b/ir/opt/garbage_collect.c @@ -21,7 +21,6 @@ * @file * @brief Removal of unreachable methods. * @author Matthias Braun - * @version $Id$ */ #include "config.h" @@ -36,7 +35,7 @@ #include "error.h" #include "debug.h" -DEBUG_ONLY(static firm_dbg_module_t *dbg); +DEBUG_ONLY(static firm_dbg_module_t *dbg;) static void visit_entity(ir_entity *entity); @@ -101,13 +100,6 @@ static void visit_entity(ir_entity *entity) if (entity->initializer != NULL) { visit_initializer(entity->initializer); - } else if (entity_has_compound_ent_values(entity)) { - size_t i; - size_t n_members = get_compound_ent_n_values(entity); - for (i = 0; i < n_members; ++i) { - ir_node *node = get_compound_ent_value(entity, i); - start_visit_node(node); - } } irg = get_entity_irg(entity); @@ -123,8 +115,9 @@ static void visit_segment(ir_type *segment) for (i = 0; i < n_entities; ++i) { ir_entity *entity = get_compound_member(segment, i); - if (get_entity_visibility(entity) != ir_visibility_default - && !(get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER)) + if (get_entity_visibility(entity) != ir_visibility_external + && !(get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER) + && !(get_entity_linkage(entity) & IR_LINKAGE_NO_CODEGEN)) continue; visit_entity(entity); @@ -149,13 +142,13 @@ static void garbage_collect_in_segment(ir_type *segment) void garbage_collect_entities(void) { - size_t i, n; + size_t i; ir_segment_t s; FIRM_DBG_REGISTER(dbg, "firm.opt.garbagecollect"); /* start a type walk for all externally visible entities */ - irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED); + irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED); inc_master_type_visited(); inc_max_irg_visited(); @@ -167,17 +160,17 @@ void garbage_collect_entities(void) } /* remove graphs of non-visited functions - * (we have to count backwards so we can safely call remove_irp_irg - * while iterating) */ - for (i = 0, n = get_irp_n_irgs(); i < n; ++i) { - ir_graph *irg = get_irp_irg(i); + * (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); if (entity_visited(entity)) 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 */ @@ -185,7 +178,7 @@ void garbage_collect_entities(void) ir_type *type = get_segment_type(s); garbage_collect_in_segment(type); } - irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED); + irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED); } ir_prog_pass_t *garbage_collect_entities_pass(const char *name)