Test for and prevent any dead-code elimination, as all code is needed in the AST for static-use analysis.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23163 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-09-20 06:20:21 +00:00
parent c981efd84d
commit f5ebfb5f27
8 changed files with 255 additions and 36 deletions

Binary file not shown.

View File

@ -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)

View File

@ -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)

View File

@ -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)

56
Test/dce.frag Normal file
View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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);