This fixes a memory leak on i965 context destruction.
NOTE: This is a candidate for the 8.0 branch.
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);
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);
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);
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);
* 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);