mesa: Make the register allocator allocation take a ralloc context.
This fixes a memory leak on i965 context destruction. NOTE: This is a candidate for the 8.0 branch.
This commit is contained in:
parent
a9eda41539
commit
b972744c78
|
@ -547,7 +547,7 @@ static void do_advanced_regalloc(struct regalloc_state * s)
|
|||
struct ra_graph * graph;
|
||||
|
||||
/* Allocate the main ra data structure */
|
||||
regs = ra_alloc_reg_set(s->C->max_temp_regs * RC_MASK_XYZW);
|
||||
regs = ra_alloc_reg_set(NULL, s->C->max_temp_regs * RC_MASK_XYZW);
|
||||
|
||||
/* Get list of program variables */
|
||||
variables = rc_get_variables(s->C);
|
||||
|
|
|
@ -88,7 +88,7 @@ brw_alloc_reg_set_for_classes(struct brw_context *brw,
|
|||
ralloc_free(brw->wm.ra_reg_to_grf);
|
||||
brw->wm.ra_reg_to_grf = ralloc_array(brw, uint8_t, ra_reg_count);
|
||||
ralloc_free(brw->wm.regs);
|
||||
brw->wm.regs = ra_alloc_reg_set(ra_reg_count);
|
||||
brw->wm.regs = ra_alloc_reg_set(brw, ra_reg_count);
|
||||
ralloc_free(brw->wm.classes);
|
||||
brw->wm.classes = ralloc_array(brw, int, class_count + 1);
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ brw_alloc_reg_set_for_classes(struct brw_context *brw,
|
|||
ralloc_free(brw->vs.ra_reg_to_grf);
|
||||
brw->vs.ra_reg_to_grf = ralloc_array(brw, uint8_t, ra_reg_count);
|
||||
ralloc_free(brw->vs.regs);
|
||||
brw->vs.regs = ra_alloc_reg_set(ra_reg_count);
|
||||
brw->vs.regs = ra_alloc_reg_set(brw, ra_reg_count);
|
||||
ralloc_free(brw->vs.classes);
|
||||
brw->vs.classes = ralloc_array(brw, int, class_count + 1);
|
||||
|
||||
|
|
|
@ -154,13 +154,19 @@ struct ra_graph {
|
|||
unsigned int stack_count;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a set of registers for the allocator.
|
||||
*
|
||||
* mem_ctx is a ralloc context for the allocator. The reg set may be freed
|
||||
* using ralloc_free().
|
||||
*/
|
||||
struct ra_regs *
|
||||
ra_alloc_reg_set(unsigned int count)
|
||||
ra_alloc_reg_set(void *mem_ctx, unsigned int count)
|
||||
{
|
||||
unsigned int i;
|
||||
struct ra_regs *regs;
|
||||
|
||||
regs = rzalloc(NULL, struct ra_regs);
|
||||
regs = rzalloc(mem_ctx, struct ra_regs);
|
||||
regs->count = count;
|
||||
regs->regs = rzalloc_array(regs, struct ra_reg, count);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct ra_regs;
|
|||
* registers, such as aligned register pairs that conflict with the
|
||||
* two real registers from which they are composed.
|
||||
*/
|
||||
struct ra_regs *ra_alloc_reg_set(unsigned int count);
|
||||
struct ra_regs *ra_alloc_reg_set(void *mem_ctx, unsigned int count);
|
||||
unsigned int ra_alloc_reg_class(struct ra_regs *regs);
|
||||
void ra_add_reg_conflict(struct ra_regs *regs,
|
||||
unsigned int r1, unsigned int r2);
|
||||
|
|
Loading…
Reference in New Issue