tgsi: move register checking code before check_register_usage()
authorBrian Paul <brianp@vmware.com>
Thu, 7 Jan 2010 17:54:56 +0000 (10:54 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 7 Jan 2010 17:55:00 +0000 (10:55 -0700)
check_register_usage() frees the scan_register *reg data so we were
reading from freed memory.  This fixes a valgrind error found with
piglit's glsl-vs-mov-after-deref test.

src/gallium/auxiliary/tgsi/tgsi_sanity.c

index 9b0644465afc76a12fe99bd76357449b8b8473c9..3a8cb498d2a8cfa4157c5f38289d9f7b93a9ee95 100644 (file)
@@ -333,15 +333,15 @@ iter_instruction(
          fill_scan_register1d(ind_reg,
                               inst->Src[i].Indirect.File,
                               inst->Src[i].Indirect.Index);
+         if (!(reg->file == TGSI_FILE_ADDRESS || reg->file == TGSI_FILE_LOOP) ||
+             reg->indices[0] != 0) {
+            report_warning(ctx, "Indirect register neither ADDR[0] nor LOOP[0]");
+         }
          check_register_usage(
             ctx,
             reg,
             "indirect",
             FALSE );
-         if (!(reg->file == TGSI_FILE_ADDRESS || reg->file == TGSI_FILE_LOOP) ||
-             reg->indices[0] != 0) {
-            report_warning(ctx, "Indirect register neither ADDR[0] nor LOOP[0]");
-         }
       }
    }