<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 9, 2018 at 9:34 PM, Timothy Arceri <span dir="ltr"><<a href="mailto:tarceri@itsqueeze.com" target="_blank">tarceri@itsqueeze.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Otherwise we create unused conditional return flags and things<br>
get unnecessarily ugly fast when lowering nested functions.<br>
---<br>
src/compiler/nir/nir_lower_<wbr>returns.c | 8 ++++++++<br>
1 file changed, 8 insertions(+)<br>
<br>
diff --git a/src/compiler/nir/nir_lower_<wbr>returns.c b/src/compiler/nir/nir_lower_<wbr>returns.c<br>
index 423192adb8a..e1ba5f2ad64 100644<br>
--- a/src/compiler/nir/nir_lower_<wbr>returns.c<br>
+++ b/src/compiler/nir/nir_lower_<wbr>returns.c<br>
@@ -27,6 +27,7 @@<br>
<br>
struct lower_returns_state {<br>
nir_builder builder;<br>
+ nir_function_impl *impl;<br>
struct exec_list *cf_list;<br>
nir_loop *loop;<br>
nir_variable *return_flag;<br>
@@ -180,6 +181,12 @@ lower_returns_in_block(nir_<wbr>block *block, struct lower_returns_state *state)<br>
<br>
nir_instr_remove(&jump->instr)<wbr>;<br>
<br>
+ /* If this is a return in the last block of the function there is nothing<br>
+ * more to do once its removed.<br>
+ */<br>
+ if (block == nir_impl_last_block(state-><wbr>impl))<br></blockquote><div><br></div><div>You can pull the impl out of the builder.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ return true;<br>
+<br>
nir_builder *b = &state->builder;<br>
<br>
/* Set the return flag */<br>
@@ -252,6 +259,7 @@ nir_lower_returns_impl(nir_<wbr>function_impl *impl)<br>
{<br>
struct lower_returns_state state;<br>
<br>
+ state.impl = impl;<br>
state.cf_list = &impl->body;<br>
state.loop = NULL;<br>
state.return_flag = NULL;<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.17.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>