nir/phi_builder: Don't recurse in value_get_block_def
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 25 Aug 2016 04:49:10 +0000 (21:49 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 25 Aug 2016 21:08:07 +0000 (14:08 -0700)
commit78715c7211aa81a1b189c3a29df4b2b98d2e0fc3
treecf4f557248e8b2d5362bf8d498ceeadc70eabd8e
parent3eddf5219e3ac17e46403849b40bfd217eb6e9d8
nir/phi_builder: Don't recurse in value_get_block_def

In some programs, we can have very deep dominance trees and the recursion
can cause us to risk stack overflows.  Instead, we replace the recursion
with a pair of loops, one at the start and one at the end.  This is
functionally equivalent to what we had before and it's actually a bit
easier to read in the new form without the recursion.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97225
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/compiler/nir/nir_phi_builder.c