Let collect_nodes cope with Bad nodes
[libfirm] / ir / ir / irgraph.c
index ba6e16e..423eed1 100644 (file)
@@ -154,7 +154,7 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc)
 {
        ir_graph *res;
        ir_node  *first_block;
-       ir_node  *end, *start, *start_block, *initial_mem, *projX, *bad;
+       ir_node  *start, *start_block, *initial_mem, *projX;
 
        res = alloc_graph();
 
@@ -212,13 +212,10 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc)
 
        /*-- Nodes needed in every graph --*/
        set_irg_end_block (res, new_r_immBlock(res));
-       end = new_r_End(res, 0, NULL);
-       set_irg_end(res, end);
+       set_irg_end(res, new_r_End(res, 0, NULL));
 
        start_block = new_r_Block_noopt(res, 0, NULL);
        set_irg_start_block(res, start_block);
-       bad = new_r_Bad(res);
-       set_irg_bad        (res, bad);
        set_irg_no_mem     (res, new_r_NoMem(res));
        start = new_r_Start(res);
        set_irg_start      (res, start);
@@ -262,7 +259,6 @@ ir_graph *new_ir_graph(ir_entity *ent, int n_loc)
 ir_graph *new_const_code_irg(void)
 {
        ir_graph *res = alloc_graph();
-       ir_node  *bad;
        ir_node  *body_block;
        ir_node  *end;
        ir_node  *end_block;
@@ -305,8 +301,6 @@ ir_graph *new_const_code_irg(void)
        /* -- The start block -- */
        start_block = new_r_Block_noopt(res, 0, NULL);
        set_irg_start_block(res, start_block);
-       bad = new_r_Bad(res);
-       set_irg_bad(res, bad);
        no_mem = new_r_NoMem(res);
        set_irg_no_mem(res, no_mem);
        start = new_r_Start(res);
@@ -325,7 +319,6 @@ ir_graph *new_const_code_irg(void)
        set_Block_block_visited(body_block, -1);
        set_Block_block_visited(start_block, -1);
        set_irn_visited(start_block, -1);
-       set_irn_visited(bad, -1);
        set_irn_visited(no_mem, -1);
 
        return res;
@@ -403,7 +396,7 @@ ir_graph *create_irg_copy(ir_graph *irg)
        new_identities(res);
 
        /* clone the frame type here for safety */
-       irp_reserve_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_reserve_resources(irp, IRP_RESOURCE_ENTITY_LINK);
        res->frame_type  = clone_frame_type(irg->frame_type);
 
        res->phase_state = irg->phase_state;
@@ -422,7 +415,6 @@ ir_graph *create_irg_copy(ir_graph *irg)
 
        /* -- The start block -- */
        set_irg_start_block(res, get_new_node(get_irg_start_block(irg)));
-       set_irg_bad        (res, get_new_node(get_irg_bad(irg)));
        set_irg_no_mem     (res, get_new_node(get_irg_no_mem(irg)));
        set_irg_start      (res, get_new_node(get_irg_start(irg)));
 
@@ -434,7 +426,7 @@ ir_graph *create_irg_copy(ir_graph *irg)
        res->estimated_node_count = irg->estimated_node_count;
 
        ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
-       irp_free_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_free_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 
        return res;
 }
@@ -499,7 +491,7 @@ size_t get_irg_idx(const ir_graph *irg)
        return irg->index;
 }
 
-ir_node *(get_idx_irn)(ir_graph *irg, unsigned idx)
+ir_node *(get_idx_irn)(const ir_graph *irg, unsigned idx)
 {
        return _get_idx_irn(irg, idx);
 }
@@ -584,16 +576,6 @@ void (set_irg_args)(ir_graph *irg, ir_node *node)
        _set_irg_args(irg, node);
 }
 
-ir_node *(get_irg_bad)(const ir_graph *irg)
-{
-       return _get_irg_bad(irg);
-}
-
-void (set_irg_bad)(ir_graph *irg, ir_node *node)
-{
-       _set_irg_bad(irg, node);
-}
-
 ir_node *(get_irg_no_mem)(const ir_graph *irg)
 {
        return _get_irg_no_mem(irg);
@@ -624,14 +606,6 @@ void (set_irg_frame_type)(ir_graph *irg, ir_type *ftp)
        _set_irg_frame_type(irg, ftp);
 }
 
-/* Returns the value parameter type of an IR graph. */
-ir_type *get_irg_value_param_type(ir_graph *irg)
-{
-       ir_entity *ent = get_irg_entity(irg);
-       ir_type   *mtp = get_entity_type(ent);
-       return get_method_value_param_type(mtp);
-}
-
 int get_irg_n_locs(ir_graph *irg)
 {
        return irg->n_loc - 1;
@@ -648,7 +622,7 @@ struct obstack *
  *
  * Implementation is GLIBC specific as is uses the internal _obstack_chunk implementation.
  */
-int node_is_in_irgs_storage(ir_graph *irg, ir_node *n)
+int node_is_in_irgs_storage(const ir_graph *irg, const ir_node *n)
 {
        struct _obstack_chunk *p;
 
@@ -901,7 +875,6 @@ void irg_invalidate_phases(ir_graph *irg)
 #ifndef NDEBUG
 void ir_reserve_resources(ir_graph *irg, ir_resources_t resources)
 {
-       assert((resources & ~IR_RESOURCE_LOCAL_MASK) == 0);
        assert((irg->reserved_resources & resources) == 0);
        irg->reserved_resources |= resources;
 }