summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2011-08-03 15:37:01 -0700
committerPaul Berry <stereotype441@gmail.com>2011-08-08 12:44:02 -0700
commitc148ef6ddb3dbf256c26d82ed2f45f1fde55a231 (patch)
tree09766d23e8abbe5c5469b35ff97ed1885c1d5856 /src/glsl
parent01a851c296347d8e9d2166b3c83eab97404c0670 (diff)
downloadexternal_mesa3d-c148ef6ddb3dbf256c26d82ed2f45f1fde55a231.zip
external_mesa3d-c148ef6ddb3dbf256c26d82ed2f45f1fde55a231.tar.gz
external_mesa3d-c148ef6ddb3dbf256c26d82ed2f45f1fde55a231.tar.bz2
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 <kenneth@whitecape.org>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/linker.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 19eb9b5..b54ef41 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -922,6 +922,14 @@ link_intrastage_shaders(void *mem_ctx,
free(linking_shaders);
+#ifdef DEBUG
+ /* At this point linked should contain all of the linked IR, so
+ * validate it to make sure nothing went wrong.
+ */
+ if (linked)
+ validate_ir_tree(linked->ir);
+#endif
+
/* Make a pass over all variable declarations to ensure that arrays with
* unspecified sizes have a size specified. The size is inferred from the
* max_array_access field.