On Tue Sep 19 09:00:26 2023 +0000, Zebediah Figura wrote:
I changed it so that after `OpReturn` another dummy SPIR-V block is
began and the generated SPIR-V is valid. That's a problem with the SPIR-V code generation, not with VSIR. Shouldn't we just stop writing instructions in the current block after a jump?
That's another approach. It's a bit more complicated because it requires more coordination with the rest of the code generator, which needs to know when to stop and resume emitting code, but at the same time still has to emit correct SPIR-V (it's not clear to me, say, if just stopping writing bytecode when you're not in a block is the right thing: as far as I know there could be other types of SPIR-V bytecode, such as annotations or I don't know what, that we still want to be generated). So my solution felt easier.
At the same time, my easier solution doesn't look too wrong: at least for the moment the SPIR-V generator is very crude, it receives VSIR instructions and directly emit the corresponding SPIR-V code without optimization. So if it receives dead code it is not inappropriate to emit other dead code: we just have to ensure that the SPIR-V code is valid, which is what this patch does.