r300: assert that every writer has a reader

Dead writes can lead to problems with regalloc, so add a safety assert
to catch such cases in the vertex shaders at least in the meantime.

Additionally we could think there are no readers due to some shortcoming
of out dataflow analysis or some other bug which we would also like to
know about.

Reviewed-by: Filip Gawin <filip.gawin@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23927>
This commit is contained in:
Pavel Ondračka 2023-06-23 10:39:16 +02:00 committed by Marge Bot
parent 5716700bbf
commit b392d3ac27

View file

@ -401,7 +401,19 @@ struct rc_list * rc_get_variables(struct radeon_compiler * c)
memset(&reader_data, 0, sizeof(reader_data));
rc_get_readers(c, inst, &reader_data, NULL, NULL, NULL);
if (reader_data.ReaderCount == 0) {
continue;
/* Variable is only returned if there is both writer
* and reader. This means dead writes will not get
* register allocated as a result and can overwrite random
* registers. Assert on dead writes insted so we can improve
* the DCE.
*/
const struct rc_opcode_info *opcode =
rc_get_opcode_info(inst->U.I.Opcode);
assert(c->type == RC_FRAGMENT_PROGRAM ||
!opcode->HasDstReg ||
inst->U.I.DstReg.File == RC_FILE_OUTPUT ||
inst->U.I.DstReg.File == RC_FILE_ADDRESS);
continue;
}
new_var = rc_variable(c, inst->U.I.DstReg.File,
inst->U.I.DstReg.Index,