<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 5, 2015 at 3:40 PM, Connor Abbott <span dir="ltr"><<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This should go before the previous patch, or else that patch won't<br>
work as intended, and also it confused me a little by using a behavior<br>
(the returning NULL) before introducing it.<br></blockquote><div><br></div><div>The previous patch is a bug.  It uses a cast of a chunk of the block to an instruction.  It just so happens that the ->type of what it gets is never a phi.  This patch turns that bug into a segfault hence putting it after the fix.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
On Thu, Feb 5, 2015 at 5:29 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
> ---<br>
>  src/glsl/nir/nir.h | 28 ++++++++++++++++++++++------<br>
>  1 file changed, 22 insertions(+), 6 deletions(-)<br>
><br>
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h<br>
> index 4cb2e92..32c991a 100644<br>
> --- a/src/glsl/nir/nir.h<br>
> +++ b/src/glsl/nir/nir.h<br>
> @@ -416,15 +416,23 @@ typedef struct {<br>
>  } nir_instr;<br>
><br>
>  static inline nir_instr *<br>
> -nir_instr_next(const nir_instr *instr)<br>
> +nir_instr_next(nir_instr *instr)<br>
>  {<br>
> -   return exec_node_data(nir_instr, (instr)->node.next, node);<br>
> +   struct exec_node *next = exec_node_get_next(&instr->node);<br>
> +   if (exec_node_is_tail_sentinel(next))<br>
> +      return NULL;<br>
> +   else<br>
> +      return exec_node_data(nir_instr, next, node);<br>
>  }<br>
><br>
>  static inline nir_instr *<br>
> -nir_instr_prev(const nir_instr *instr)<br>
> +nir_instr_prev(nir_instr *instr)<br>
>  {<br>
> -   return exec_node_data(nir_instr, (instr)->node.prev, node);<br>
> +   struct exec_node *prev = exec_node_get_prev(&instr->node);<br>
> +   if (exec_node_is_head_sentinel(prev))<br>
> +      return NULL;<br>
> +   else<br>
> +      return exec_node_data(nir_instr, prev, node);<br>
>  }<br>
><br>
>  typedef struct {<br>
> @@ -1264,13 +1272,21 @@ typedef struct {<br>
>  static inline nir_cf_node *<br>
>  nir_cf_node_next(nir_cf_node *node)<br>
>  {<br>
> -   return exec_node_data(nir_cf_node, exec_node_get_next(&node->node), node);<br>
> +   struct exec_node *next = exec_node_get_next(&node->node);<br>
> +   if (exec_node_is_tail_sentinel(next))<br>
> +      return NULL;<br>
> +   else<br>
> +      return exec_node_data(nir_cf_node, next, node);<br>
>  }<br>
><br>
>  static inline nir_cf_node *<br>
>  nir_cf_node_prev(nir_cf_node *node)<br>
>  {<br>
> -   return exec_node_data(nir_cf_node, exec_node_get_prev(&node->node), node);<br>
> +   struct exec_node *prev = exec_node_get_prev(&node->node);<br>
> +   if (exec_node_is_head_sentinel(prev))<br>
> +      return NULL;<br>
> +   else<br>
> +      return exec_node_data(nir_cf_node, prev, node);<br>
>  }<br>
><br>
>  static inline bool<br>
> --<br>
> 2.2.2<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>