Mesa (master): nir: Give end_block its own index

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 22 21:41:55 UTC 2018


Module: Mesa
Branch: master
Commit: 410de0e3f1690f905c268549cef1e1e60d63e8d9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=410de0e3f1690f905c268549cef1e1e60d63e8d9

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Tue Aug 14 15:06:38 2018 -0700

nir: Give end_block its own index

Since there's no particular reason for the index to be 0, choose an
index that is not used by other block.  This is convenient when we
store "per-block" data in an array AND look for the successors
data (e.g. any kind of backwards data-flow analysis).

v2: Add a note about end_block's index. (Jason)

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

 src/compiler/nir/nir.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index e12aa5d80f..7ae4684519 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1641,7 +1641,10 @@ nir_index_blocks(nir_function_impl *impl)
       block->index = index++;
    }
 
-   impl->num_blocks = index;
+   /* The end_block isn't really part of the program, which is why its index
+    * is >= num_blocks.
+    */
+   impl->num_blocks = impl->end_block->index = index;
 }
 
 static bool




More information about the mesa-commit mailing list