vc4: Add more useful debug for the undefined-source case
authorEric Anholt <eric@anholt.net>
Wed, 16 Jul 2014 16:09:05 +0000 (09:09 -0700)
committerEric Anholt <eric@anholt.net>
Sat, 9 Aug 2014 01:59:47 +0000 (18:59 -0700)
We could get undefined sources in real programs from the wild, so we'll
need to turn off this debug eventually.  But for now, using undefined
sources is typically me just mistyping something.

src/gallium/drivers/vc4/vc4_qpu_emit.c

index da47539af0f2f6694bbc4a9969050fe13f89d756..6b047023e5676a5a05e86b7c47c42d790b317fcf 100644 (file)
@@ -266,11 +266,18 @@ vc4_generate_code(struct qcompile *c)
                                 src[i] = qpu_rn(0);
                                 break;
                         case QFILE_TEMP:
-                                assert(reg_allocated[index] != -1);
-                                src[i] = allocate_to_qpu_reg[reg_allocated[index]];
-                                reg_uses_remaining[index]--;
-                                if (reg_uses_remaining[index] == 0)
-                                        reg_in_use[reg_allocated[index]] = false;
+                                if (reg_allocated[index] == -1) {
+                                        fprintf(stderr, "undefined reg use: ");
+                                        qir_dump_inst(qinst);
+                                        fprintf(stderr, "\n");
+
+                                        src[i] = qpu_rn(0);
+                                } else {
+                                        src[i] = allocate_to_qpu_reg[reg_allocated[index]];
+                                        reg_uses_remaining[index]--;
+                                        if (reg_uses_remaining[index] == 0)
+                                                reg_in_use[reg_allocated[index]] = false;
+                                }
                                 break;
                         case QFILE_UNIF:
                                 src[i] = qpu_unif();