From: Iago Toral Quiroga Date: Wed, 5 Jul 2023 08:38:07 +0000 (+0200) Subject: broadcom/compiler: don't leak v3d_compile when finding a new best strategy X-Git-Tag: upstream/23.3.3~6007 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be91133f8767cd37325403f599038a5841370f68;p=platform%2Fupstream%2Fmesa.git broadcom/compiler: don't leak v3d_compile when finding a new best strategy If we had selected a best strategy and find an even better one we need to make sure we free the previous one. Reviewed-by: Alejandro PiƱeiro Part-of: --- diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index f091873..82c21f9 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -1790,6 +1790,15 @@ skip_compile_strategy(struct v3d_compile *c, uint32_t idx) return false; }; } + +static inline void +set_best_compile(struct v3d_compile **best, struct v3d_compile *c) +{ + if (*best) + vir_compile_destroy(*best); + *best = c; +} + uint64_t *v3d_compile(const struct v3d_compiler *compiler, struct v3d_key *key, struct v3d_prog_data **out_prog_data, @@ -1854,11 +1863,11 @@ uint64_t *v3d_compile(const struct v3d_compiler *compiler, if (c->spills == 0 || strategies[strat].min_threads == 4 || V3D_DBG(OPT_COMPILE_TIME)) { - best_c = c; + set_best_compile(&best_c, c); break; } else if (c->spills + c->fills < best_spill_fill_count) { - best_c = c; + set_best_compile(&best_c, c); best_spill_fill_count = c->spills + c->fills; } @@ -1888,10 +1897,8 @@ uint64_t *v3d_compile(const struct v3d_compiler *compiler, } /* If the best strategy was not the last, choose that */ - if (best_c && c != best_c) { - vir_compile_destroy(c); - c = best_c; - } + if (best_c && c != best_c) + set_best_compile(&c, best_c); if (V3D_DBG(PERF) && c->compilation_result !=