summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/nv50/nv50_pc.c4
-rw-r--r--src/gallium/drivers/nv50/nv50_pc_regalloc.c5
-rw-r--r--src/gallium/drivers/nv50/nv50_shader_state.c2
-rw-r--r--src/gallium/drivers/nv50/nv50_tgsi_to_nc.c16
4 files changed, 19 insertions, 8 deletions
diff --git a/src/gallium/drivers/nv50/nv50_pc.c b/src/gallium/drivers/nv50/nv50_pc.c
index e063888eb5f..26ad9b4e3db 100644
--- a/src/gallium/drivers/nv50/nv50_pc.c
+++ b/src/gallium/drivers/nv50/nv50_pc.c
@@ -237,6 +237,7 @@ nv_pc_free_refs(struct nv_pc *pc)
int i;
for (i = 0; i < pc->num_refs; i += 64)
FREE(pc->refs[i]);
+ FREE(pc->refs);
}
static const char *
@@ -525,7 +526,8 @@ out:
for (i = 0; i < pc->num_blocks; ++i)
FREE(pc->bb_list[i]);
-
+ if (pc->root)
+ FREE(pc->root);
if (ret) { /* on success, these will be referenced by nv50_program */
if (pc->emit)
FREE(pc->emit);
diff --git a/src/gallium/drivers/nv50/nv50_pc_regalloc.c b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
index 2998343db52..b9d5ba5ef67 100644
--- a/src/gallium/drivers/nv50/nv50_pc_regalloc.c
+++ b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
@@ -888,6 +888,10 @@ nv_pc_pass1(struct nv_pc *pc, struct nv_basic_block *root)
ctx->pc = pc;
ctx->insns = CALLOC(NV_PC_MAX_INSTRUCTIONS, sizeof(struct nv_instruction *));
+ if (!ctx->insns) {
+ FREE(ctx);
+ return -1;
+ }
pc->pass_seq++;
ret = pass_generate_phi_movs(ctx, root);
@@ -941,6 +945,7 @@ nv_pc_pass1(struct nv_pc *pc, struct nv_basic_block *root)
NV50_DBGMSG("REGISTER ALLOCATION - leaving\n");
out:
+ FREE(ctx->insns);
FREE(ctx);
return ret;
}
diff --git a/src/gallium/drivers/nv50/nv50_shader_state.c b/src/gallium/drivers/nv50/nv50_shader_state.c
index f187a074e6b..564f7e53246 100644
--- a/src/gallium/drivers/nv50/nv50_shader_state.c
+++ b/src/gallium/drivers/nv50/nv50_shader_state.c
@@ -44,7 +44,7 @@ nv50_transfer_constbuf(struct nv50_context *nv50,
if (!map)
return;
- count = buf->width0; /* MIN2(buf->width0, size); */
+ count = (buf->width0 + 3) / 4;
start = 0;
while (count) {
diff --git a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
index 6fd749b35f8..5994d1c27e9 100644
--- a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
+++ b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
@@ -39,7 +39,7 @@
#define BLD_MAX_PREDS 4
#define BLD_MAX_IMMDS 128
-#define BLD_MAX_COND_NESTING 4
+#define BLD_MAX_COND_NESTING 8
#define BLD_MAX_LOOP_NESTING 4
#define BLD_MAX_CALL_NESTING 2
@@ -70,14 +70,14 @@ bld_vals_del_val(struct bld_value_stack *stk, struct nv_value *val)
{
unsigned i;
- for (i = stk->size - 1; i >= 0; --i)
- if (stk->body[i] == val)
+ for (i = stk->size; i > 0; --i)
+ if (stk->body[i - 1] == val)
break;
- if (i < 0)
+ if (!i)
return FALSE;
- if (i != stk->size - 1)
- stk->body[i] = stk->body[stk->size - 1];
+ if (i != stk->size)
+ stk->body[i - 1] = stk->body[stk->size - 1];
--stk->size; /* XXX: old size in REALLOC */
return TRUE;
@@ -1643,6 +1643,8 @@ bld_instruction(struct bld_context *bld,
{
struct nv_basic_block *b = new_basic_block(bld->pc);
+ assert(bld->cond_lvl < BLD_MAX_COND_NESTING);
+
nvbb_attach_block(bld->pc->current_block, b, CFG_EDGE_FORWARD);
bld->join_bb[bld->cond_lvl] = bld->pc->current_block;
@@ -1695,6 +1697,8 @@ bld_instruction(struct bld_context *bld,
struct nv_basic_block *bl = new_basic_block(bld->pc);
struct nv_basic_block *bb = new_basic_block(bld->pc);
+ assert(bld->loop_lvl < BLD_MAX_LOOP_NESTING);
+
bld->loop_bb[bld->loop_lvl] = bl;
bld->brkt_bb[bld->loop_lvl] = bb;