diff --git a/Install/Windows/glslangValidator.exe b/Install/Windows/glslangValidator.exe index 5d8b6c8aaf75aec95089544737daee7a0df90c99..35f1078b1c8914659dca919c700fbf723d35f123 100644 Binary files a/Install/Windows/glslangValidator.exe and b/Install/Windows/glslangValidator.exe differ diff --git a/Test/baseResults/dce.frag.out b/Test/baseResults/dce.frag.out new file mode 100644 index 0000000000000000000000000000000000000000..d854acaab66db89eec32f0be2cb3040aad6276a0 --- /dev/null +++ b/Test/baseResults/dce.frag.out @@ -0,0 +1,116 @@ +0:? Sequence +0:5 Sequence +0:5 move second child to first child (int) +0:5 'c' (int) +0:5 0 (const int) +0:7 Function Definition: bar( (void) +0:7 Function Parameters: +0:9 Sequence +0:9 Test condition and select (void) +0:9 Condition +0:9 false (const bool) +0:9 true case +0:10 Pre-Increment (int) +0:10 'c' (int) +0:9 false case +0:12 Pre-Increment (int) +0:12 'c' (int) +0:14 Test condition and select (int) +0:14 Condition +0:14 false (const bool) +0:14 true case +0:14 Pre-Increment (int) +0:14 'c' (int) +0:14 false case +0:14 Pre-Increment (int) +0:14 'c' (int) +0:16 switch +0:16 condition +0:16 'c' (int) +0:16 body +0:16 Sequence +0:17 case: with expression +0:17 1 (const int) +0:? Sequence +0:18 Pre-Increment (int) +0:18 'c' (int) +0:19 Branch: Break +0:20 Pre-Increment (int) +0:20 'c' (int) +0:21 case: with expression +0:21 2 (const int) +0:? Sequence +0:22 Branch: Break +0:23 Pre-Increment (int) +0:23 'c' (int) +0:24 default: +0:? Sequence +0:25 Branch: Break +0:28 Sequence +0:28 Sequence +0:28 move second child to first child (int) +0:28 'i' (int) +0:28 0 (const int) +0:28 Loop with condition tested first +0:28 Loop Condition +0:28 Compare Less Than (bool) +0:28 'i' (int) +0:28 0 (const int) +0:28 Loop Body +0:29 Pre-Increment (int) +0:29 'c' (int) +0:28 Loop Terminal Expression +0:28 Pre-Increment (int) +0:28 'i' (int) +0:31 Sequence +0:31 Sequence +0:31 move second child to first child (int) +0:31 'i' (int) +0:31 0 (const int) +0:31 Loop with condition tested first +0:31 Loop Condition +0:31 Compare Less Than (bool) +0:31 'i' (int) +0:31 10 (const int) +0:31 Loop Body +0:32 Sequence +0:32 Test condition and select (void) +0:32 Condition +0:32 Compare Less Than (bool) +0:32 'c' (int) +0:32 3 (const int) +0:32 true case +0:33 Sequence +0:33 Branch: Break +0:34 Pre-Increment (int) +0:34 'c' (int) +0:32 false case +0:36 Sequence +0:36 Branch: Continue +0:37 Pre-Increment (int) +0:37 'c' (int) +0:31 Loop Terminal Expression +0:31 Pre-Increment (int) +0:31 'i' (int) +0:41 Branch: Return +0:43 Pre-Increment (int) +0:43 'c' (int) +0:46 Function Definition: foo( (int) +0:46 Function Parameters: +0:48 Sequence +0:48 Test condition and select (void) +0:48 Condition +0:48 Compare Greater Than (bool) +0:48 'c' (int) +0:48 4 (const int) +0:48 true case +0:49 Sequence +0:49 Branch: Return with expression +0:49 4 (const int) +0:50 Pre-Increment (int) +0:50 'c' (int) +0:53 Branch: Return with expression +0:53 5 (const int) +0:55 Pre-Increment (int) +0:55 'c' (int) + diff --git a/Test/baseResults/precision.frag.out b/Test/baseResults/precision.frag.out index e36f97ab664d0a7d199f30fc01e09ded2af99733..76ef998b0b308c7fb3e096a6da9a3dca2f786dac 100644 --- a/Test/baseResults/precision.frag.out +++ b/Test/baseResults/precision.frag.out @@ -55,11 +55,15 @@ ERROR: node is still EOpNull! 0:58 Loop Condition 0:58 true (const bool) 0:58 Loop Body -0:? Sequence -0:? Sequence -0:54 add second child into first child (mediump int) -0:54 'sum' (lowp int) -0:54 'level4_medium' (mediump int) +0:51 Sequence +0:51 Test condition and select (void) +0:51 Condition +0:51 true (const bool) +0:51 true case +0:? Sequence +0:54 add second child into first child (mediump int) +0:54 'sum' (lowp int) +0:54 'level4_medium' (mediump int) 0:57 add second child into first child (highp int) 0:57 'sum' (lowp int) 0:57 'level3_high' (highp int) diff --git a/Test/baseResults/uint.frag.out b/Test/baseResults/uint.frag.out index 2f0434941c2a69a6f1a53ae524171724f5d67c15..b871722437ee422b7b7ad325cf88db3805ade466 100644 --- a/Test/baseResults/uint.frag.out +++ b/Test/baseResults/uint.frag.out @@ -25,18 +25,48 @@ ERROR: node is still EOpNull! 0:19 't' (flat in mediump 2-component vector of uint) 0:19 1 (const int) 0:19 3 (const uint) -0:28 multiply second child into first child (mediump int) -0:28 'count' (mediump int) -0:28 2 (const int) -0:30 multiply second child into first child (mediump int) -0:30 'count' (mediump int) -0:30 3 (const int) -0:42 multiply second child into first child (mediump int) -0:42 'count' (mediump int) -0:42 7 (const int) -0:44 multiply second child into first child (mediump int) -0:44 'count' (mediump int) -0:44 11 (const int) +0:27 Test condition and select (void) +0:27 Condition +0:27 true (const bool) +0:27 true case +0:28 multiply second child into first child (mediump int) +0:28 'count' (mediump int) +0:28 2 (const int) +0:29 Test condition and select (void) +0:29 Condition +0:29 true (const bool) +0:29 true case +0:30 multiply second child into first child (mediump int) +0:30 'count' (mediump int) +0:30 3 (const int) +0:31 Test condition and select (void) +0:31 Condition +0:31 false (const bool) +0:31 true case +0:32 multiply second child into first child (mediump int) +0:32 'count' (mediump int) +0:32 5 (const int) +0:41 Test condition and select (void) +0:41 Condition +0:41 true (const bool) +0:41 true case +0:42 multiply second child into first child (mediump int) +0:42 'count' (mediump int) +0:42 7 (const int) +0:43 Test condition and select (void) +0:43 Condition +0:43 true (const bool) +0:43 true case +0:44 multiply second child into first child (mediump int) +0:44 'count' (mediump int) +0:44 11 (const int) +0:45 Test condition and select (void) +0:45 Condition +0:45 false (const bool) +0:45 true case +0:46 multiply second child into first child (mediump int) +0:46 'count' (mediump int) +0:46 13 (const int) 0:49 Sequence 0:49 move second child to first child (mediump int) 0:49 'shiftedii' (mediump int) @@ -127,15 +157,34 @@ ERROR: node is still EOpNull! 0:67 'ai' (mediump int) 0:67 Convert int to uint (mediump uint) 0:67 'count' (mediump int) -0:76 multiply second child into first child (mediump int) -0:76 'count' (mediump int) -0:76 17 (const int) -0:82 multiply second child into first child (mediump int) -0:82 'count' (mediump int) -0:82 23 (const int) -0:85 multiply second child into first child (mediump int) -0:85 'count' (mediump int) -0:85 27 (const int) +0:75 Test condition and select (void) +0:75 Condition +0:75 true (const bool) +0:75 true case +0:76 multiply second child into first child (mediump int) +0:76 'count' (mediump int) +0:76 17 (const int) +0:78 Test condition and select (void) +0:78 Condition +0:78 false (const bool) +0:78 true case +0:79 multiply second child into first child (mediump int) +0:79 'count' (mediump int) +0:79 19 (const int) +0:81 Test condition and select (void) +0:81 Condition +0:81 true (const bool) +0:81 true case +0:82 multiply second child into first child (mediump int) +0:82 'count' (mediump int) +0:82 23 (const int) +0:84 Test condition and select (void) +0:84 Condition +0:84 true (const bool) +0:84 true case +0:85 multiply second child into first child (mediump int) +0:85 'count' (mediump int) +0:85 27 (const int) 0:87 Sequence 0:87 move second child to first child (mediump uint) 0:87 'mask1' (mediump uint) diff --git a/Test/dce.frag b/Test/dce.frag new file mode 100644 index 0000000000000000000000000000000000000000..119a98ddfe875a20f855652cde35962d8cba5993 --- /dev/null +++ b/Test/dce.frag @@ -0,0 +1,56 @@ +#version 400 + +const bool flag = false; + +int c = 0; + +void bar() +{ + if (flag) + ++c; // should still show up in AST + else + ++c; + + flag ? ++c : ++c; // both should still show up in AST + + switch (c) { + case 1: + ++c; + break; + ++c; // should still show up in AST + case 2: + break; + ++c; // should still show up in AST + default: + break; + } + + for (int i = 0; i < 0; ++i) + ++c; // should still show up in AST + + for (int i = 0; i < 10; ++i) { + if (c < 3) { + break; + ++c; // should still show up in AST + } else { + continue; + ++c; // should still show up in AST + } + } + + return; + + ++c; // should still show up in AST +} + +int foo() // not called, but should still show up in AST +{ + if (c > 4) { + return 4; + ++c; // should still show up in AST + } + + return 5; + + ++c; // should still show up in AST +} diff --git a/Test/testlist b/Test/testlist index 223e751c2fca7ed7c618d8762f147f23502f41f7..ef82695117e76df9b5ad49d68baf75ab1432d10c 100644 --- a/Test/testlist +++ b/Test/testlist @@ -49,6 +49,7 @@ numeral.frag 400.tese 420.tese 430.comp +dce.frag ../../LunarGLASS/test/aggOps.frag ../../LunarGLASS/test/always-discard.frag ../../LunarGLASS/test/always-discard2.frag diff --git a/Todo.txt b/Todo.txt index 75f2c3eac0c80ac3d7dc9c518f8500c8e34a50de..4d4360b1b8adc2cb09978bf72dc8505033594730 100644 --- a/Todo.txt +++ b/Todo.txt @@ -3,7 +3,7 @@ Current functionality level: ESSL 3.0 Link Validation + provide input config file for setting limits - also consider spitting out measures of complexity - - ensure no static references thrown away + + ensure no static references thrown away Cross-stage linking - type consistency check of uniform and ins <-> outs, both variables and blocks, stage-specific arrayness matching - location/binding/index check diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp index a4847422654468c2d688630ed206a1cfd382eda5..62c93a4b5c7a5eef371b91dfaa400d800f96501f 100644 --- a/glslang/MachineIndependent/Intermediate.cpp +++ b/glslang/MachineIndependent/Intermediate.cpp @@ -688,16 +688,9 @@ TIntermAggregate* TIntermediate::makeAggregate(TIntermNode* node, TSourceLoc loc TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nodePair, TSourceLoc loc) { // - // For compile time constant selections, prune the code and - // test now. + // Don't prune the false path for compile-time constants; it's needed + // for static access analysis. // - - if (cond->getAsTyped() && cond->getAsTyped()->getAsConstantUnion()) { - if (cond->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->getBConst()) - return nodePair.node1; - else - return nodePair.node2; - } TIntermSelection* node = new TIntermSelection(cond, nodePair.node1, nodePair.node2); node->setLoc(loc);