Commit f645052c authored by Christoph Mallon's avatar Christoph Mallon
Browse files

irgraph: Put the obstack into ir_graph instead of delegating it.

parent d72b7e3a
......@@ -379,10 +379,8 @@ void be_transform_graph(ir_graph *irg, arch_pretrans_nodes *func)
current_ir_graph = irg;
/* create a new obstack */
struct obstack *old_obst = irg->obst;
struct obstack *new_obst = XMALLOC(struct obstack);
obstack_init(new_obst);
irg->obst = new_obst;
struct obstack old_obst = irg->obst;
obstack_init(&irg->obst);
irg->last_node_idx = 0;
free_vrp_data(irg);
......@@ -394,8 +392,7 @@ void be_transform_graph(ir_graph *irg, arch_pretrans_nodes *func)
transform_nodes(irg, func);
/* free the old obstack */
obstack_free(old_obst, 0);
xfree(old_obst);
obstack_free(&old_obst, 0);
/* restore state */
current_ir_graph = old_current_ir_graph;
......
......@@ -150,8 +150,7 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc)
/*-- initialized for each graph. --*/
res->kind = k_ir_graph;
res->obst = XMALLOC(struct obstack);
obstack_init(res->obst);
obstack_init(&res->obst);
/* graphs are in construction mode by default */
add_irg_constraints(res, IR_GRAPH_CONSTRAINT_CONSTRUCTION);
......@@ -244,8 +243,7 @@ ir_graph *new_const_code_irg(void)
res->n_loc = 1; /* Only the memory. */
res->visited = 0; /* visited flag, for the ir walker */
res->block_visited = 0; /* visited flag, for the 'block'-walker */
res->obst = XMALLOC(struct obstack);
obstack_init(res->obst);
obstack_init(&res->obst);
res->last_node_idx = 0;
......@@ -348,8 +346,7 @@ ir_graph *create_irg_copy(ir_graph *irg)
res->n_loc = 0;
res->visited = 0; /* visited flag, for the ir walker */
res->block_visited = 0; /* visited flag, for the 'block'-walker */
res->obst = XMALLOC(struct obstack);
obstack_init(res->obst);
obstack_init(&res->obst);
res->last_node_idx = 0;
......@@ -403,8 +400,7 @@ void free_ir_graph(ir_graph *irg)
}
free_End(get_irg_end(irg));
obstack_free(irg->obst, NULL);
free(irg->obst);
obstack_free(&irg->obst, NULL);
if (irg->loc_descriptions)
free(irg->loc_descriptions);
irg->kind = k_BAD;
......@@ -555,11 +551,9 @@ int get_irg_n_locs(ir_graph *irg)
int node_is_in_irgs_storage(const ir_graph *irg, const ir_node *n)
{
struct _obstack_chunk *p;
/* Check whether the ir_node pointer is on the obstack.
* A more sophisticated check would test the "whole" ir_node. */
for (p = irg->obst->chunk; p; p = p->prev) {
for (struct _obstack_chunk const *p = irg->obst.chunk; p; p = p->prev) {
if (((char *)p->contents <= (char *)n) && ((char *)n < (char *)p->limit))
return 1;
}
......
......@@ -127,10 +127,10 @@ static inline void set_irg_pinned(ir_graph *irg, op_pin_state p)
}
/** Returns the obstack associated with the graph. */
static inline struct obstack *get_irg_obstack(const ir_graph *irg)
static inline struct obstack *get_irg_obstack(ir_graph *const irg)
{
assert(obstack_object_size(irg->obst) == 0);
return irg->obst;
assert(obstack_object_size(&irg->obst) == 0);
return &irg->obst;
}
......@@ -380,7 +380,7 @@ static inline void irg_kill_node(ir_graph *irg, ir_node *n)
if (idx + 1 == irg->last_node_idx)
--irg->last_node_idx;
irg->idx_irn_map[idx] = NULL;
obstack_free(irg->obst, n);
obstack_free(&irg->obst, n);
}
/**
......
......@@ -511,7 +511,7 @@ struct ir_graph {
ir_type *frame_type; /**< A class type representing the stack frame.
Can include "inner" methods. */
ir_node *anchor; /**< Pointer to the anchor node of this graph. */
struct obstack *obst; /**< The obstack where all of the ir_nodes live. */
struct obstack obst; /**< The obstack where all of the ir_nodes live. */
ir_node *current_block; /**< Current block for newly gen_*()-erated ir_nodes. */
/* -- Fields indicating different states of irgraph -- */
......
......@@ -95,9 +95,6 @@ static void copy_graph_env(ir_graph *irg)
*/
void dead_node_elimination(ir_graph *irg)
{
struct obstack *graveyard_obst = NULL;
struct obstack *rebirth_obst = NULL;
edges_deactivate(irg);
/* inform statistics that we started a dead-node elimination run */
......@@ -113,12 +110,10 @@ void dead_node_elimination(ir_graph *irg)
/* A quiet place, where the old obstack can rest in peace,
until it will be cremated. */
graveyard_obst = irg->obst;
struct obstack graveyard_obst = irg->obst;
/* A new obstack, where the reachable nodes will be copied to. */
rebirth_obst = XMALLOC(struct obstack);
irg->obst = rebirth_obst;
obstack_init(irg->obst);
obstack_init(&irg->obst);
irg->last_node_idx = 0;
/* We also need a new value table for CSE */
......@@ -128,8 +123,7 @@ void dead_node_elimination(ir_graph *irg)
copy_graph_env(irg);
/* Free memory from old unoptimized obstack */
obstack_free(graveyard_obst, 0); /* First empty the obstack ... */
xfree(graveyard_obst); /* ... then free it. */
obstack_free(&graveyard_obst, 0); /* First empty the obstack ... */
/* inform statistics that the run is over */
hook_dead_node_elim(irg, 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment