[Mesa-dev] [PATCH 07/11] nir/cf: Fix dominance metadata in the dead control flow pass.

Jason Ekstrand jason at jlekstrand.net
Wed Sep 23 10:43:45 PDT 2015


5, 6, and 7 are

Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>

On Tue, Sep 22, 2015 at 9:37 PM, Connor Abbott <cwabbott0 at gmail.com> wrote:
> On Tue, Sep 22, 2015 at 11:01 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
>> The NIR control flow modification API churns the block structure,
>> splitting blocks, stitching them back together, and so on.  Preserving
>> information about block dominance is hard (and probably not worthwhile).
>>
>> This patch makes nir_cf_extract() throw away all metadata, like we do
>> when adding/removing jumps.
>>
>> We then make the dead control flow pass compute dominance information
>> right before it uses it.  This is necessary because earlier work by the
>> pass may have invalidated it.
>>
>> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
>
> Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>
>
>> ---
>>  src/glsl/nir/nir_control_flow.c | 3 +++
>>  src/glsl/nir/nir_opt_dead_cf.c  | 7 ++++---
>>  2 files changed, 7 insertions(+), 3 deletions(-)
>>
>> New patch!
>>
>> diff --git a/src/glsl/nir/nir_control_flow.c b/src/glsl/nir/nir_control_flow.c
>> index e027766..8ec1252 100644
>> --- a/src/glsl/nir/nir_control_flow.c
>> +++ b/src/glsl/nir/nir_control_flow.c
>> @@ -742,6 +742,9 @@ nir_cf_extract(nir_cf_list *extracted, nir_cursor begin, nir_cursor end)
>>     extracted->impl = nir_cf_node_get_function(&block_begin->cf_node);
>>     exec_list_make_empty(&extracted->list);
>>
>> +   /* Dominance and other block-related information is toast. */
>> +   nir_metadata_preserve(extracted->impl, nir_metadata_none);
>> +
>>     nir_cf_node *cf_node = &block_begin->cf_node;
>>     nir_cf_node *cf_node_end = &block_end->cf_node;
>>     while (true) {
>> diff --git a/src/glsl/nir/nir_opt_dead_cf.c b/src/glsl/nir/nir_opt_dead_cf.c
>> index 317bbc5..0d4819b 100644
>> --- a/src/glsl/nir/nir_opt_dead_cf.c
>> +++ b/src/glsl/nir/nir_opt_dead_cf.c
>> @@ -203,6 +203,10 @@ loop_is_dead(nir_loop *loop)
>>                                       NULL))
>>        return false;
>>
>> +   nir_function_impl *impl = nir_cf_node_get_function(&loop->cf_node);
>> +   nir_metadata_require(impl, nir_metadata_live_variables |
>> +                              nir_metadata_dominance);
>> +
>>     for (nir_block *cur = after->imm_dom; cur != before; cur = cur->imm_dom) {
>>        nir_foreach_instr(cur, instr) {
>>           if (!nir_foreach_ssa_def(instr, def_not_live_out, after))
>> @@ -332,9 +336,6 @@ dead_cf_list(struct exec_list *list, bool *list_ends_in_jump)
>>  static bool
>>  opt_dead_cf_impl(nir_function_impl *impl)
>>  {
>> -   nir_metadata_require(impl, nir_metadata_live_variables |
>> -                              nir_metadata_dominance);
>> -
>>     bool dummy;
>>     bool progress = dead_cf_list(&impl->body, &dummy);
>>
>> --
>> 2.5.3
>>


More information about the mesa-dev mailing list