Mesa (master): pan/midgard: Debug mir_insert_instruction_after_scheduled

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Oct 20 12:32:20 UTC 2019


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Wed Oct 16 12:18:51 2019 -0400

pan/midgard: Debug mir_insert_instruction_after_scheduled

Add some comments explaining what's going on in a more natural flow in
order to solve the actual bug.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Fixes: 2d914ebe818 ("pan/midgard: Fix memory corruption in register spilling")

---

 src/panfrost/midgard/mir.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c
index 3a3a4f93448..f1eca73f789 100644
--- a/src/panfrost/midgard/mir.c
+++ b/src/panfrost/midgard/mir.c
@@ -525,17 +525,21 @@ mir_insert_instruction_after_scheduled(
         midgard_instruction *tag,
         midgard_instruction ins)
 {
-        unsigned after = mir_bundle_idx_for_ins(tag, block);
+        /* We need to grow the bundles array to add our new bundle */
         size_t count = util_dynarray_num_elements(&block->bundles, midgard_bundle);
         UNUSED void *unused = util_dynarray_grow(&block->bundles, midgard_bundle, 1);
 
+        /* Find the bundle that we want to insert after */
+        unsigned after = mir_bundle_idx_for_ins(tag, block);
+
+        /* All the bundles after that one, we move ahead by one */
         midgard_bundle *bundles = (midgard_bundle *) block->bundles.data;
         memmove(bundles + after + 2, bundles + after + 1, (count - after - 1) * sizeof(midgard_bundle));
         midgard_bundle *after_bundle = bundles + after;
 
         midgard_bundle new = mir_bundle_for_op(ctx, ins);
         memcpy(bundles + after + 1, &new, sizeof(new));
-        list_addtail(&new.instructions[0]->link, &after_bundle->instructions[after_bundle->instruction_count - 1]->link);
+        list_add(&new.instructions[0]->link, &after_bundle->instructions[after_bundle->instruction_count - 1]->link);
 }
 
 /* Flip the first-two arguments of a (binary) op. Currently ALU




More information about the mesa-commit mailing list