[Mesa-dev] [PATCH 1/4] Revert "glsl: Skip processing the first function's body in do_dead_functions()."

Eric Anholt eric at anholt.net
Tue Aug 2 11:01:17 PDT 2011


On Mon, 1 Aug 2011 22:16:40 -0700, Paul Berry <stereotype441 at gmail.com> wrote:
> On 1 August 2011 17:35, Ian Romanick <idr at freedesktop.org> wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On 08/01/2011 04:07 PM, Paul Berry wrote:
> >> opt_dead_functions contained a shortcut to skip processing the first
> >> function's body, based on the assumption that IR functions are
> >> topologically sorted, with callees always coming before their callers
> >> (therefore the first function cannot contain any calls).
> >
> > After linking, that is absolutely true.
> >
> > When linking, we start with an empty shader.  Then we find main, and
> > pull it in.  For each function pulled in (initially just main), we
> > recursively pull in all the called functions.
> >
> > In the absence of cycles (i.e., recursion), that should guarantee the
> > desired sort order.  Right?
> 
> Hmm, what you say makes sense, but there must be something more subtle
> going on, because what led me to make this patch was that I first
> tried writing the rest of the patch series, and then when I tested it
> I ran into problems because at link time, the functions weren't sorted
> in callee-to-caller order.
> 
> I will investigate things further in the morning and let you know what I find.

Since we only have one ir_function per function name, we might still be
able to construct your failure by calling everything f(some args).

I like the is_leaf() idea for implementing this optimization much
better, though.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110802/92222c44/attachment.pgp>


More information about the mesa-dev mailing list