[Mesa-dev] [PATCH 3/4] glsl: In ir_validate, check that ir_loop::counter always refers to a new var.

Paul Berry stereotype441 at gmail.com
Wed Nov 27 16:24:56 PST 2013


On 27 November 2013 14:43, Ian Romanick <idr at freedesktop.org> wrote:

> On 11/27/2013 12:44 PM, Paul Berry wrote:
> > The compiler back-ends (i965's fs_visitor and brw_visitor,
> > ir_to_mesa_visitor, and glsl_to_tgsi_visitor) have been assuming this
> > for some time.  Thanks to the preceding patch, the compiler front-end
> > no longer breaks this assumption.
> >
> > This patch adds code to validate the assumption so that if we have
> > future bugs, we'll be able to catch them earlier.
> > ---
> >  src/glsl/ir_validate.cpp | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> >
> > diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
> > index 13e41a0..26d6388 100644
> > --- a/src/glsl/ir_validate.cpp
> > +++ b/src/glsl/ir_validate.cpp
> > @@ -63,6 +63,7 @@ public:
> >
> >     virtual ir_visitor_status visit_enter(ir_if *ir);
> >
> > +   virtual ir_visitor_status visit_enter(ir_loop *ir);
> >     virtual ir_visitor_status visit_leave(ir_loop *ir);
> >     virtual ir_visitor_status visit_enter(ir_function *ir);
> >     virtual ir_visitor_status visit_leave(ir_function *ir);
> > @@ -149,6 +150,18 @@ ir_validate::visit_enter(ir_if *ir)
> >
> >
> >  ir_visitor_status
> > +ir_validate::visit_enter(ir_loop *ir)
> > +{
> > +   if (ir->counter != NULL && hash_table_find(ht, ir->counter) != NULL)
> {
> > +      printf("ir_loop @ %p specifies already-declared variable `%s' @
> %p\n",
> > +             (void *) ir, ir->counter->name, (void *) ir->counter);
> > +      abort();
> > +   }
>
> We should enforce the invariants that you mention in the next patch.
> That should happen either in this patch or a follow-on... but probably
> here.  Yeah?
>

You mean the stuff about from, to, and increment being non-null when
counter is non-null and vice versa?  That's already enforced in
ir_validate::visit_leave(ir_loop *).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131127/f9ac1dc5/attachment.html>


More information about the mesa-dev mailing list