OSDN Git Service

nir: Walk blocks in source code order in lower_vars_to_ssa.
authorMatt Turner <mattst88@gmail.com>
Thu, 25 Aug 2016 02:25:58 +0000 (19:25 -0700)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 1 Sep 2016 10:39:46 +0000 (11:39 +0100)
commit9aa4e400d24ea85b69326cc38ad73e1bcce7ecd1
tree73eecd631968c86ae3d9ebb098b956b7ff247f65
parentb061b2e3ebd97e444de049edcf9dda3c56b3f572
nir: Walk blocks in source code order in lower_vars_to_ssa.

Prior to this commit rename_variables_block() is recursively called,
performing a depth-first traversal of the control flow graph. The
function uses a non-trivial amount of stack space for local variables,
which puts us in danger of smashing the stack, given a sufficiently deep
dominance tree.

XCOM: Enemy Within contains a shader with such a dominance tree (1574
nir_blocks in total, depth of at least 143).

Jason tells me that he believes that any walk over the nir_blocks that
respects dominance is sufficient (a DFS might have been necessary prior
to the introduction of nir_phi_builder).

In fact, the introduction of nir_phi_builder made the problem worse:
rename_variables_block(), walks to the bottom of the dominance tree
before calling nir_phi_builder_value_get_block_def() which walks back to
the top of the dominance tree...

In any case, this patch ensures we avoid that problem as well.

Cc: mesa-stable@lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97225
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
(cherry picked from commit e53130cc27b966a09d48be53cb51e09ea7ad0649)
src/compiler/nir/nir_lower_vars_to_ssa.c
src/compiler/nir/nir_phi_builder.h