nir: return early when lowering a return at the end of a function

Otherwise we create unused conditional return flags and things
get unnecessarily ugly fast when lowering nested functions.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Timothy Arceri 2018-04-08 21:47:32 +10:00
parent d3cafc18fc
commit 6e22ad6edc

View file

@ -180,6 +180,12 @@ lower_returns_in_block(nir_block *block, struct lower_returns_state *state)
nir_instr_remove(&jump->instr);
/* If this is a return in the last block of the function there is nothing
* more to do once its removed.
*/
if (block == nir_impl_last_block(state->builder.impl))
return true;
nir_builder *b = &state->builder;
/* Set the return flag */