intel/compiler: Delete bidirectional block links in opt_predicated_break

Previously when earlier_block->children.make_empty() was called, the
child blocks would still have links back to earlier_block.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25216>
This commit is contained in:
Ian Romanick 2023-09-13 10:44:31 -07:00 committed by Marge Bot
parent 5842829380
commit bbd7729993
3 changed files with 41 additions and 2 deletions

View file

@ -166,6 +166,28 @@ bblock_t::dump() const
}
}
void
bblock_t::unlink_list(exec_list *list)
{
assert(list == &parents || list == &children);
const bool remove_parent = list == &children;
foreach_list_typed_safe(bblock_link, link, link, list) {
/* Also break the links from the other block back to this block. */
exec_list *sub_list = remove_parent ? &link->block->parents : &link->block->children;
foreach_list_typed_safe(bblock_link, sub_link, link, sub_list) {
if (sub_link->block == this) {
sub_link->link.remove();
ralloc_free(sub_link);
}
}
link->link.remove();
ralloc_free(link);
}
}
cfg_t::cfg_t(const backend_shader *s, exec_list *instructions) :
s(s)
{

View file

@ -107,6 +107,23 @@ struct bblock_t {
backend_instruction *first_non_control_flow_inst();
backend_instruction *last_non_control_flow_inst();
private:
/**
* \sa unlink_parents, unlink_children
*/
void unlink_list(exec_list *);
public:
void unlink_parents()
{
unlink_list(&parents);
}
void unlink_children()
{
unlink_list(&children);
}
#endif
struct exec_node link;

View file

@ -159,13 +159,13 @@ opt_predicated_break(backend_shader *s)
endif_inst->remove(endif_block);
if (!earlier_block->ends_with_control_flow()) {
earlier_block->children.make_empty();
earlier_block->unlink_children();
earlier_block->add_successor(s->cfg->mem_ctx, jump_block,
bblock_link_logical);
}
if (!later_block->starts_with_control_flow()) {
later_block->parents.make_empty();
later_block->unlink_parents();
}
jump_block->add_successor(s->cfg->mem_ctx, later_block,
bblock_link_logical);