Mesa (master): nir/cf: Conditionally do block_add_normal_succs() in unlink_jump();
Kenneth Graunke
kwg at kemper.freedesktop.org
Wed Sep 23 18:03:15 UTC 2015
Module: Mesa
Branch: master
Commit: 0991b2eb3535f9af289149c9e63c38b56cb4b549
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0991b2eb3535f9af289149c9e63c38b56cb4b549
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Tue Sep 22 18:04:14 2015 -0700
nir/cf: Conditionally do block_add_normal_succs() in unlink_jump();
There is a bug where we mess up predecessors/successors due to the
ordering of unlinking/recreating edges/adding fake edges. In order to
fix that, I need everything in one routine.
However, calling block_add_normal_succs() isn't safe from
cleanup_cf_node() - it would crash trying to insert phi undefs.
So unfortunately I need to add a parameter.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>
---
src/glsl/nir/nir_control_flow.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/glsl/nir/nir_control_flow.c b/src/glsl/nir/nir_control_flow.c
index e2a151d..2b23f38 100644
--- a/src/glsl/nir/nir_control_flow.c
+++ b/src/glsl/nir/nir_control_flow.c
@@ -548,8 +548,8 @@ remove_phi_src(nir_block *block, nir_block *pred)
* infinite loops. Note that the jump to be eliminated may be free-floating.
*/
-static
-void unlink_jump(nir_block *block, nir_jump_type type)
+static void
+unlink_jump(nir_block *block, nir_jump_type type, bool add_normal_successors)
{
if (block->successors[0])
remove_phi_src(block->successors[0], block);
@@ -574,14 +574,14 @@ void unlink_jump(nir_block *block, nir_jump_type type)
}
unlink_block_successors(block);
+ if (add_normal_successors)
+ block_add_normal_succs(block);
}
void
nir_handle_remove_jump(nir_block *block, nir_jump_type type)
{
- unlink_jump(block, type);
-
- block_add_normal_succs(block);
+ unlink_jump(block, type, true);
nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
nir_metadata_preserve(impl, nir_metadata_none);
@@ -689,7 +689,7 @@ cleanup_cf_node(nir_cf_node *node, nir_function_impl *impl)
nir_foreach_instr_safe(block, instr) {
if (instr->type == nir_instr_type_jump) {
nir_jump_type jump_type = nir_instr_as_jump(instr)->type;
- unlink_jump(block, jump_type);
+ unlink_jump(block, jump_type, false);
} else {
nir_foreach_ssa_def(instr, replace_ssa_def_uses, impl);
nir_instr_remove(instr);
More information about the mesa-commit
mailing list