glsl: validate IR after linking (debug builds only)
glsl: validate IR after linking (debug builds only)

At least one of the invariants verified by IR validation concerns the
relative ordering of toplevel constructs in the IR: references to
global variables must come after the declarations of those global
variables.

Since linking affects the ordering of toplevel constructs in the IR,
it's possible that a bug in the linker will cause invalid IR to be
generated, even if all the pre-linked shaders are valid.  (In fact,
such a bug was fixed by the previous commit.)

Bugs like this are easily masked by further optimization passes,
particularly inlining.  So to make them easier to track down, this
patch addes an IR validation step right after linking, and before
final optimization occurs.  The validation only occurs on debug
builds.

Reviewed-by: Kenneth Graunke <bd2562f754ec92342f93f61c25d731e290a2ffa8@whitecape.org>

KTXSoftware/glsl2agal,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,zeux/glsl-optimizer,adobe/glsl2agal,metora/MesaGLSLCompiler,mapbox/glsl-optimizer,bkaradzic/glsl-optimizer,mcanthony/glsl-optimizer,dellis1972/glsl-optimizer,jbarczak/glsl-optimizer,tokyovigilante/glsl-optimizer,dellis1972/glsl-optimizer,bkaradzic/glsl-optimizer,benaadams/glsl-optimizer,metora/MesaGLSLCompiler,benaadams/glsl-optimizer,zz85/glsl-optimizer,adobe/glsl2agal,metora/MesaGLSLCompiler,benaadams/glsl-optimizer,tokyovigilante/glsl-optimizer,adobe/glsl2agal,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,bkaradzic/glsl-optimizer,dellis1972/glsl-optimizer,tokyovigilante/glsl-optimizer,djreep81/glsl-optimizer,djreep81/glsl-optimizer,adobe/glsl2agal,mapbox/glsl-optimizer,wolf96/glsl-optimizer,mapbox/glsl-optimizer,dellis1972/glsl-optimizer,jbarczak/glsl-optimizer,wolf96/glsl-optimizer,jbarczak/glsl-optimizer,KTXSoftware/glsl2agal,KTXSoftware/glsl2agal,wolf96/glsl-optimizer,bkaradzic/glsl-optimizer,mapbox/glsl-optimizer,adobe/glsl2agal,zz85/glsl-optimizer,benaadams/glsl-optimizer,djreep81/glsl-optimizer,zeux/glsl-optimizer,mapbox/glsl-optimizer,dellis1972/glsl-optimizer,mcanthony/glsl-optimizer,benaadams/glsl-optimizer,djreep81/glsl-optimizer,mcanthony/glsl-optimizer,mcanthony/glsl-optimizer,mcanthony/glsl-optimizer,KTXSoftware/glsl2agal,zeux/glsl-optimizer,benaadams/glsl-optimizer,KTXSoftware/glsl2agal,djreep81/glsl-optimizer,zeux/glsl-optimizer,zeux/glsl-optimizer,zz85/glsl-optimizer,zz85/glsl-optimizer,bkaradzic/glsl-optimizer,jbarczak/glsl-optimizer,zz85/glsl-optimizer,jbarczak/glsl-optimizer,zz85/glsl-optimizer