Mesa (master): aco: Fix convert_to_SDWA when instruction has 3 operands.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 24 14:13:53 UTC 2020


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

Author: Timur Kristóf <timur.kristof at gmail.com>
Date:   Sat Aug 22 20:45:54 2020 +0200

aco: Fix convert_to_SDWA when instruction has 3 operands.

Previously, when the instruction had 3 operands, this would cause
possible corruption because of writing to sdwa->sel[2].
This was noticed thanks to GCC 10's -Wstringop-overflow warning.

Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6436>

---

 src/amd/compiler/aco_ir.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/amd/compiler/aco_ir.cpp b/src/amd/compiler/aco_ir.cpp
index 801fbc68616..b594b2824e9 100644
--- a/src/amd/compiler/aco_ir.cpp
+++ b/src/amd/compiler/aco_ir.cpp
@@ -238,6 +238,10 @@ aco_ptr<Instruction> convert_to_SDWA(chip_class chip, aco_ptr<Instruction>& inst
    }
 
    for (unsigned i = 0; i < instr->operands.size(); i++) {
+      /* SDWA only uses operands 0 and 1. */
+      if (i >= 2)
+         break;
+
       switch (instr->operands[i].bytes()) {
       case 1:
          sdwa->sel[i] = sdwa_ubyte;



More information about the mesa-commit mailing list