intel/compiler: Validate fuzzed instructions
authorMatt Turner <mattst88@gmail.com>
Tue, 12 Nov 2019 00:11:34 +0000 (16:11 -0800)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Jan 2020 00:19:21 +0000 (00:19 +0000)
... before giving them to the instruction compactor.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2635>

src/intel/compiler/brw_eu.h
src/intel/compiler/brw_eu_validate.c
src/intel/compiler/test_eu_compact.cpp

index ce1368a7fd3e235835955b9495175c3ac8523002..ea4ee7748f67769f0ba8e15e680073e00deb86be 100644 (file)
@@ -1243,6 +1243,9 @@ void brw_debug_compact_uncompact(const struct gen_device_info *devinfo,
                                  brw_inst *orig, brw_inst *uncompacted);
 
 /* brw_eu_validate.c */
+bool brw_validate_instruction(const struct gen_device_info *devinfo,
+                              const brw_inst *inst, int offset,
+                              struct disasm_info *disasm);
 bool brw_validate_instructions(const struct gen_device_info *devinfo,
                                const void *assembly, int start_offset, int end_offset,
                                struct disasm_info *disasm);
index e2bb552c720d3a0ab2f8278894addd1e75ba9cff..3b802d3b35539bc0ce039252d846b6dd5fa0188b 100644 (file)
@@ -1937,7 +1937,7 @@ instruction_restrictions(const struct gen_device_info *devinfo,
    return error_msg;
 }
 
-static bool
+bool
 brw_validate_instruction(const struct gen_device_info *devinfo,
                          const brw_inst *inst, int offset,
                          struct disasm_info *disasm)
index ec93d2bd1421a55cb35f3cac88a7ac74c6b201ad..4cb33aefba226c37a8e4a0d5bc9b2a59c666e145 100644 (file)
@@ -160,6 +160,9 @@ test_fuzz_compact_instruction(struct brw_codegen *p, brw_inst src)
 
          clear_pad_bits(p->devinfo, &instr);
 
+         if (!brw_validate_instruction(p->devinfo, &instr, 0, NULL))
+            continue;
+
         if (!test_compact_instruction(p, instr)) {
            printf("  twiddled bits for fuzzing %d, %d\n", bit0, bit1);
            return false;