From 2d914ebe818b47faa7ec778108be767c55b26c20 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 7 Oct 2019 22:42:35 -0400 Subject: [PATCH] pan/midgard: Fix memory corruption in register spilling Essentially an off-by-one error ... bit of an edge case, but seems to occur in some glamor shaders. Signed-off-by: Alyssa Rosenzweig --- src/panfrost/midgard/mir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c index 5d49f7f79f1..3a3a4f93448 100644 --- a/src/panfrost/midgard/mir.c +++ b/src/panfrost/midgard/mir.c @@ -531,11 +531,11 @@ mir_insert_instruction_after_scheduled( 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_1 = bundles + after + 2; + 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_1->instructions[0]->link); + list_addtail(&new.instructions[0]->link, &after_bundle->instructions[after_bundle->instruction_count - 1]->link); } /* Flip the first-two arguments of a (binary) op. Currently ALU -- 2.30.2