Francisco Casas (@fcasas) commented about libs/vkd3d-shader/hlsl_codegen.c:
* statement in this block. We have to stop and do this in a separate
* loop, because instructions must be deleted in reverse order (due to
* def-use chains.)
*
* If we're inside of a loop CF block, we can instead just turn the
* return into a break, which offers the right semantics—except that it
* won't break out of nested loops.
*
* - A CF block which might contain a return statement. After calling
* lower_return() on the CF block body, we stop, pull out everything after
* the CF instruction, shove it into an if block, and then lower that if
* block.
*
* (We could return a "did we make progress" like transform_ir() and run
* this pass multiple times, but we already know the only block that still
* needs addressing, so there's not much point.)
The previous part of the comment is great at explaining what this does!
This paragraph got me a little confused at first though, because I didn't made the association with the `progress` flag immediately. Perhaps a rephrasing would help:
We could return a "did we make progress" **boolean** like **in** transform_ir() and run this pass multiple times, but we already know the only block that **remains** to be **addressed**, so there's not much point.
Also, I have the feeling that this approach wouldn't be easy either, because we would have to check if we already inserted the `early_return_var` conditionals during the last iteration.