diff options
author | Rob Clark <[email protected]> | 2014-03-02 08:48:08 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2014-03-02 11:26:35 -0500 |
commit | ecb71cfa66f4257661579a0afa5f9c56c7dbfce2 (patch) | |
tree | 7f7c4a96e61a330a802e02f2633328b5ef5af003 /src/gallium/drivers | |
parent | e0007f733dfffff2b5c3729546d6c16ecba6faa9 (diff) |
freedreno/a3xx/compiler: overflow in trans_endif
The logic to count number of block outputs was out of sync with the
actual array construction. But to simplify / make things less fragile,
we can just allocate the arrays for worst case size.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_compiler.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c index 7450fac23c1..9b644742615 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c @@ -1427,19 +1427,9 @@ trans_endif(const struct instr_translater *t, if (!elseb) elseb = ifb->parent; - /* count up number of outputs for each block: */ - for (i = 0; i < ifb->ntemporaries; i++) { - if (ifb->temporaries[i]) - ifnout++; - if (elseb->temporaries[i]) - elsenout++; - } - for (i = 0; i < ifb->noutputs; i++) { - if (ifb->outputs[i]) - ifnout++; - if (elseb->outputs[i]) - elsenout++; - } + /* worst case sizes: */ + ifnout = ifb->ntemporaries + ifb->noutputs; + elsenout = elseb->ntemporaries + elseb->noutputs; ifout = ir3_alloc(ctx->ir, sizeof(ifb->outputs[0]) * ifnout); if (elseb != ifb->parent) @@ -1480,6 +1470,8 @@ trans_endif(const struct instr_translater *t, } } + compile_assert(ctx, ifb->noutputs == elseb->noutputs); + /* .. and any outputs written: */ for (i = 0; i < ifb->noutputs; i++) { struct ir3_instruction *a = ifb->outputs[i]; |