- Changed keep logic: all nodes can be keeped yet, thi is necessary to fix fehler152
[libfirm] / ir / ir / irgraph.c
index 9f93e14..81d2de5 100644 (file)
@@ -166,6 +166,10 @@ void irg_set_nloc(ir_graph *res, int n_loc) {
                                               the store. This is not the number of parameters
                                               to the procedure!  */
        }
+       if (res->loc_descriptions) {
+               xfree(res->loc_descriptions);
+               res->loc_descriptions = NULL;
+       }
 }
 
 /* Allocates a list of nodes:
@@ -485,7 +489,7 @@ ir_graph *create_irg_copy(ir_graph *irg) {
 
        res->phase_state = irg->phase_state;
 
-       set_using_irn_link(irg);
+       ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
 
        /* copy all nodes from the graph irg to the new graph res */
        irg_walk_anchors(irg, copy_all_nodes, set_all_preds, res);
@@ -512,7 +516,7 @@ ir_graph *create_irg_copy(ir_graph *irg) {
           is different from the original one. */
        res->estimated_node_count = irg->estimated_node_count;
 
-       clear_using_irn_link(irg);
+       ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
 
        return res;
 }
@@ -529,6 +533,8 @@ ir_graph *create_irg_copy(ir_graph *irg) {
 void free_ir_graph(ir_graph *irg) {
        assert(is_ir_graph(irg));
 
+       edges_deactivate(irg);
+
        hook_free_graph(irg);
        if (irg->outs_state != outs_none)
                free_irg_outs(irg);
@@ -1041,62 +1047,21 @@ void *get_irg_loc_description(ir_graph *irg, int n) {
 }
 
 #ifndef NDEBUG
-void set_using_block_visited(ir_graph *irg) {
-       assert(irg->using_block_visited == 0);
-       irg->using_block_visited = 1;
-}
-
-void clear_using_block_visited(ir_graph *irg) {
-       assert(irg->using_block_visited == 1);
-       irg->using_block_visited = 0;
-}
-
-int using_block_visited(const ir_graph *irg) {
-       return irg->using_block_visited;
-}
-
-
-void set_using_irn_visited(ir_graph *irg) {
-       assert(irg->using_irn_visited == 0);
-       irg->using_irn_visited = 1;
-}
-
-void clear_using_irn_visited(ir_graph *irg) {
-       assert(irg->using_irn_visited == 1);
-       irg->using_irn_visited = 0;
-}
-
-int using_irn_visited(const ir_graph *irg) {
-       return irg->using_irn_visited;
-}
-
-
-void set_using_irn_link(ir_graph *irg) {
-       assert(irg->using_irn_link == 0);
-       irg->using_irn_link = 1;
-}
-
-void clear_using_irn_link(ir_graph *irg) {
-       assert(irg->using_irn_link == 1);
-       irg->using_irn_link = 0;
-}
-
-int using_irn_link(const ir_graph *irg) {
-       return irg->using_irn_link;
-}
-
-void set_using_block_mark(ir_graph *irg) {
-       assert(irg->using_block_mark == 0);
-       irg->using_block_mark = 1;
+void ir_reserve_resources(ir_graph *irg, ir_resources_t resources)
+{
+       assert((irg->reserved_resources & resources) == 0);
+       irg->reserved_resources |= resources;
 }
 
-void clear_using_block_mark(ir_graph *irg) {
-       assert(irg->using_block_mark == 1);
-       irg->using_block_mark = 0;
+void ir_free_resources(ir_graph *irg, ir_resources_t resources)
+{
+       assert((irg->reserved_resources & resources) == resources);
+       irg->reserved_resources &= ~resources;
 }
 
-int using_block_mark(const ir_graph *irg) {
-       return irg->using_block_mark;
+ir_resources_t ir_resources_reserved(const ir_graph *irg)
+{
+       return irg->reserved_resources;
 }
 #endif /* NDEBUG */