nir: Free instructions more often
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 19 Mar 2019 13:16:41 +0000 (14:16 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 30 Aug 2022 18:21:44 +0000 (18:21 +0000)
commit9d9b891f940a8797492bfc04b0108d398959a8ce
treebe0d531c7221deb50568add705934aaaf580cdbf
parent8f159a8576efbb7bb3755d215a54b87c4c99a0d2
nir: Free instructions more often

Soon we'll be allocating instructions out of a per-shader pool, which
means that if we don't free too many instructions during the main
optimization loop, the final nir_sweep() call will create holes which
can't be filled. By freeing instructions more aggressively, we can
allocate more instructions from the freelist which will reduce the final
memory usage.

Modified from Connor Abbott's original patch to rebase on top of
refactored DCE and so that the use-after-free in nir_algebraic_impl() is
fixed.

Co-authored-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12910>
src/compiler/nir/nir_opt_dce.c
src/compiler/nir/nir_search.c
src/compiler/nir/nir_search.h