Commit 1f0e7894 authored by Michael Beck's avatar Michael Beck
Browse files

Fixed bad memory leak:

The obstack inside a chordal_env was overwritten with an old version, causing lost allocated blocks

[r13480]
parent 32c52ed3
......@@ -109,10 +109,10 @@ static INLINE border_t *border_add(be_chordal_env_t *env, struct list_head *head
if(!is_def) {
border_t *def;
b = obstack_alloc(&env->obst, sizeof(*b));
b = obstack_alloc(env->obst, sizeof(*b));
/* also allocate the def and tie it to the use. */
def = obstack_alloc(&env->obst, sizeof(*def));
def = obstack_alloc(env->obst, sizeof(*def));
memset(def, 0, sizeof(*def));
b->other_end = def;
def->other_end = b;
......@@ -206,7 +206,7 @@ static be_insn_t *chordal_scan_insn(be_chordal_env_t *env, ir_node *irn)
ie.ignore_colors = env->ignore_colors;
ie.aenv = env->birg->main_env->arch_env;
ie.obst = &env->obst;
ie.obst = env->obst;
ie.cls = env->cls;
return be_scan_insn(&ie, irn);
}
......@@ -328,7 +328,7 @@ static ir_node *prepare_constr_insn(be_chordal_env_t *env, ir_node *irn)
}
end:
obstack_free(&env->obst, insn);
obstack_free(env->obst, insn);
return insn->next_insn;
}
......@@ -443,7 +443,7 @@ static ir_node *pre_process_constraints(be_chordal_alloc_env_t *alloc_env,
the live sets may change.
*/
// be_liveness_recompute(lv);
obstack_free(&env->obst, insn);
obstack_free(env->obst, insn);
*the_insn = insn = chordal_scan_insn(env, insn->irn);
/*
......@@ -480,7 +480,7 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env, ir_node *i
ir_node *perm = NULL;
int match_res, cost;
be_chordal_env_t *env = alloc_env->chordal_env;
void *base = obstack_base(&env->obst);
void *base = obstack_base(env->obst);
be_insn_t *insn = chordal_scan_insn(env, irn);
ir_node *res = insn->next_insn;
int be_silent = *silent;
......@@ -658,7 +658,7 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env, ir_node *i
pmap_destroy(partners);
end:
obstack_free(&env->obst, base);
obstack_free(env->obst, base);
return res;
}
......@@ -724,7 +724,7 @@ static void pressure(ir_node *block, void *env_ptr)
bitset_clear_all(live);
/* Set up the border list in the block info */
head = obstack_alloc(&env->obst, sizeof(*head));
head = obstack_alloc(env->obst, sizeof(*head));
INIT_LIST_HEAD(head);
assert(pmap_get(env->border_heads, block) == NULL);
pmap_insert(env->border_heads, block, head);
......
......@@ -544,6 +544,7 @@ static void be_ra_chordal_main(be_irg_t *birg)
be_options_t *main_opts = main_env->options;
int j, m;
be_chordal_env_t chordal_env;
struct obstack obst;
BE_TIMER_INIT(main_opts);
BE_TIMER_PUSH(ra_timer.t_other);
......@@ -552,6 +553,7 @@ static void be_ra_chordal_main(be_irg_t *birg)
be_assure_dom_front(birg);
be_assure_liveness(birg);
chordal_env.obst = &obst;
chordal_env.opts = &options;
chordal_env.irg = irg;
chordal_env.birg = birg;
......@@ -559,7 +561,7 @@ static void be_ra_chordal_main(be_irg_t *birg)
chordal_env.ifg = NULL;
chordal_env.ignore_colors = NULL;
obstack_init(&chordal_env.obst);
obstack_init(&obst);
BE_TIMER_POP(ra_timer.t_prolog);
......@@ -612,7 +614,7 @@ static void be_ra_chordal_main(be_irg_t *birg)
lower_nodes_after_ra(birg, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
obstack_free(&chordal_env.obst, NULL);
obstack_free(&obst, NULL);
be_invalidate_liveness(birg);
BE_TIMER_POP(ra_timer.t_epilog);
......
......@@ -57,7 +57,7 @@ struct border_t {
* Environment for each of the chordal register allocator phases
*/
struct be_chordal_env_t {
struct obstack obst; /**< An obstack for temporary storage. */
struct obstack *obst; /**< An obstack for temporary storage. */
be_ra_chordal_opts_t *opts; /**< A pointer to the chordal ra options. */
be_irg_t *birg; /**< Back-end IRG session. */
ir_graph *irg; /**< The graph under examination. */
......
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