Mesa (master): v3d: Avoid assertion failures when removing end-of-shader instructions.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Dec 15 03:29:16 UTC 2018


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

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Dec 11 14:07:52 2018 -0800

v3d: Avoid assertion failures when removing end-of-shader instructions.

After generating VIR, we leave c->cursor pointing at the end of the
shader.  If the shader had dead code at the end (for example from preamble
instructions in a shader with no side effects), we would assertion fail
that we were leaving the cursor pointing at freed memory.  Since anything
following DCE should be setting up a new cursor anyway, just clear the
cursor at the start.

---

 src/broadcom/compiler/vir_opt_dead_code.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/broadcom/compiler/vir_opt_dead_code.c b/src/broadcom/compiler/vir_opt_dead_code.c
index 362fc9e52a..4aedbb6540 100644
--- a/src/broadcom/compiler/vir_opt_dead_code.c
+++ b/src/broadcom/compiler/vir_opt_dead_code.c
@@ -101,6 +101,12 @@ vir_opt_dead_code(struct v3d_compile *c)
         bool progress = false;
         bool *used = calloc(c->num_temps, sizeof(bool));
 
+        /* Defuse the "are you removing the cursor?" assertion in the core.
+         * You'll need to set up a new cursor for any new instructions after
+         * doing DCE (which we would expect, anyway).
+         */
+        c->cursor.link = NULL;
+
         vir_for_each_inst_inorder(inst, c) {
                 for (int i = 0; i < vir_get_nsrc(inst); i++) {
                         if (inst->src[i].file == QFILE_TEMP)




More information about the mesa-commit mailing list