Commit 2feb3db5 by Shahbaz Youssefi Committed by Commit Bot

Remove unused translator option bit

SH_DONT_PRUNE_UNUSED_FUNCTIONS was only used by tests, and never used by ANGLE or chromium. Bug: angleproject:4889 Change-Id: I4926f86125e69b07e9d4d95134b7b70522e0d64f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2607491Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 41dbfe9c
...@@ -30,14 +30,14 @@ constexpr ShCompileOptions kCommonOptions = ...@@ -30,14 +30,14 @@ constexpr ShCompileOptions kCommonOptions =
SH_ENFORCE_PACKING_RESTRICTIONS | SH_CLAMP_INDIRECT_ARRAY_BOUNDS | SH_ENFORCE_PACKING_RESTRICTIONS | SH_CLAMP_INDIRECT_ARRAY_BOUNDS |
SH_LIMIT_EXPRESSION_COMPLEXITY | SH_LIMIT_CALL_STACK_DEPTH | SH_INIT_GL_POSITION | SH_LIMIT_EXPRESSION_COMPLEXITY | SH_LIMIT_CALL_STACK_DEPTH | SH_INIT_GL_POSITION |
SH_INIT_OUTPUT_VARIABLES | SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS | SH_INIT_OUTPUT_VARIABLES | SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS |
SH_DONT_PRUNE_UNUSED_FUNCTIONS | SH_REMOVE_POW_WITH_CONSTANT_EXPONENT | SH_REMOVE_POW_WITH_CONSTANT_EXPONENT | SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL |
SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL | SH_HLSL_GET_DIMENSIONS_IGNORES_BASE_LEVEL | SH_HLSL_GET_DIMENSIONS_IGNORES_BASE_LEVEL | SH_REWRITE_TEXELFETCHOFFSET_TO_TEXELFETCH |
SH_REWRITE_TEXELFETCHOFFSET_TO_TEXELFETCH | SH_EMULATE_ISNAN_FLOAT_FUNCTION | SH_EMULATE_ISNAN_FLOAT_FUNCTION | SH_INITIALIZE_UNINITIALIZED_LOCALS |
SH_INITIALIZE_UNINITIALIZED_LOCALS | SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW | SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW | SH_CLAMP_POINT_SIZE |
SH_CLAMP_POINT_SIZE | SH_DONT_USE_LOOPS_TO_INITIALIZE_VARIABLES | SH_DONT_USE_LOOPS_TO_INITIALIZE_VARIABLES | SH_SKIP_D3D_CONSTANT_REGISTER_ZERO |
SH_SKIP_D3D_CONSTANT_REGISTER_ZERO | SH_EMULATE_GL_DRAW_ID | SH_INIT_SHARED_VARIABLES | SH_EMULATE_GL_DRAW_ID | SH_INIT_SHARED_VARIABLES | SH_FORCE_ATOMIC_VALUE_RESOLUTION |
SH_FORCE_ATOMIC_VALUE_RESOLUTION | SH_EMULATE_GL_BASE_VERTEX_BASE_INSTANCE | SH_EMULATE_GL_BASE_VERTEX_BASE_INSTANCE | SH_TAKE_VIDEO_TEXTURE_AS_EXTERNAL_OES |
SH_TAKE_VIDEO_TEXTURE_AS_EXTERNAL_OES | SH_VALIDATE_AST | SH_ADD_BASE_VERTEX_TO_VERTEX_ID | SH_VALIDATE_AST | SH_ADD_BASE_VERTEX_TO_VERTEX_ID |
SH_REMOVE_DYNAMIC_INDEXING_OF_SWIZZLED_VECTOR | SH_DISABLE_ARB_TEXTURE_RECTANGLE | SH_REMOVE_DYNAMIC_INDEXING_OF_SWIZZLED_VECTOR | SH_DISABLE_ARB_TEXTURE_RECTANGLE |
SH_IGNORE_PRECISION_QUALIFIERS | SH_FORCE_SHADER_PRECISION_HIGHP_TO_MEDIUMP; SH_IGNORE_PRECISION_QUALIFIERS | SH_FORCE_SHADER_PRECISION_HIGHP_TO_MEDIUMP;
......
...@@ -634,10 +634,7 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root, ...@@ -634,10 +634,7 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
return false; return false;
} }
if ((compileOptions & SH_DONT_PRUNE_UNUSED_FUNCTIONS) == 0) pruneUnusedFunctions(root);
{
pruneUnusedFunctions(root);
}
if (IsSpecWithFunctionBodyNewScope(mShaderSpec, mShaderVersion)) if (IsSpecWithFunctionBodyNewScope(mShaderSpec, mShaderVersion))
{ {
if (!ReplaceShadowingVariables(this, root, &mSymbolTable)) if (!ReplaceShadowingVariables(this, root, &mSymbolTable))
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// PruneUnusedFunctions_test.cpp: // PruneUnusedFunctions_test.cpp:
// Test for the pruning of unused function with the SH_PRUNE_UNUSED_FUNCTIONS compile flag // Test for the pruning of unused functions
// //
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
...@@ -23,9 +23,9 @@ class PruneUnusedFunctionsTest : public MatchOutputCodeTest ...@@ -23,9 +23,9 @@ class PruneUnusedFunctionsTest : public MatchOutputCodeTest
PruneUnusedFunctionsTest() : MatchOutputCodeTest(GL_FRAGMENT_SHADER, 0, SH_ESSL_OUTPUT) {} PruneUnusedFunctionsTest() : MatchOutputCodeTest(GL_FRAGMENT_SHADER, 0, SH_ESSL_OUTPUT) {}
protected: protected:
void compile(const std::string &shaderString, bool prune) void compile(const std::string &shaderString)
{ {
int compilationFlags = SH_VARIABLES | (prune ? 0 : SH_DONT_PRUNE_UNUSED_FUNCTIONS); int compilationFlags = SH_VARIABLES;
MatchOutputCodeTest::compile(shaderString, compilationFlags); MatchOutputCodeTest::compile(shaderString, compilationFlags);
} }
}; };
...@@ -42,13 +42,9 @@ TEST_F(PruneUnusedFunctionsTest, UnusedFunctionAndProto) ...@@ -42,13 +42,9 @@ TEST_F(PruneUnusedFunctionsTest, UnusedFunctionAndProto)
"float unused(float a) {\n" "float unused(float a) {\n"
" return a;\n" " return a;\n"
"}\n"; "}\n";
compile(shaderString, true); compile(shaderString);
EXPECT_TRUE(notFoundInCode("unused(")); EXPECT_TRUE(notFoundInCode("unused("));
EXPECT_TRUE(foundInCode("main(", 1)); EXPECT_TRUE(foundInCode("main(", 1));
compile(shaderString, false);
EXPECT_TRUE(foundInCode("unused(", 2));
EXPECT_TRUE(foundInCode("main(", 1));
} }
// Check that unimplemented prototypes are removed iff the options is set // Check that unimplemented prototypes are removed iff the options is set
...@@ -60,13 +56,9 @@ TEST_F(PruneUnusedFunctionsTest, UnimplementedPrototype) ...@@ -60,13 +56,9 @@ TEST_F(PruneUnusedFunctionsTest, UnimplementedPrototype)
"void main() {\n" "void main() {\n"
" gl_FragColor = vec4(1.0);\n" " gl_FragColor = vec4(1.0);\n"
"}\n"; "}\n";
compile(shaderString, true); compile(shaderString);
EXPECT_TRUE(notFoundInCode("unused(")); EXPECT_TRUE(notFoundInCode("unused("));
EXPECT_TRUE(foundInCode("main(", 1)); EXPECT_TRUE(foundInCode("main(", 1));
compile(shaderString, false);
EXPECT_TRUE(foundInCode("unused(", 1));
EXPECT_TRUE(foundInCode("main(", 1));
} }
// Check that used functions are not pruned (duh) // Check that used functions are not pruned (duh)
...@@ -81,11 +73,7 @@ TEST_F(PruneUnusedFunctionsTest, UsedFunction) ...@@ -81,11 +73,7 @@ TEST_F(PruneUnusedFunctionsTest, UsedFunction)
"float used(float a) {\n" "float used(float a) {\n"
" return a;\n" " return a;\n"
"}\n"; "}\n";
compile(shaderString, true); compile(shaderString);
EXPECT_TRUE(foundInCode("used(", 3));
EXPECT_TRUE(foundInCode("main(", 1));
compile(shaderString, false);
EXPECT_TRUE(foundInCode("used(", 3)); EXPECT_TRUE(foundInCode("used(", 3));
EXPECT_TRUE(foundInCode("main(", 1)); EXPECT_TRUE(foundInCode("main(", 1));
} }
......
...@@ -598,33 +598,6 @@ TEST_F(RemoveUnreferencedVariablesTest, UserDefinedTypeReferencedInUnusedFunctio ...@@ -598,33 +598,6 @@ TEST_F(RemoveUnreferencedVariablesTest, UserDefinedTypeReferencedInUnusedFunctio
ASSERT_TRUE(notFoundInCode("myStructType")); ASSERT_TRUE(notFoundInCode("myStructType"));
} }
// Test that a struct type that is only referenced in an unused function is kept in case
// SH_DONT_PRUNE_UNUSED_FUNCTIONS is specified.
TEST_F(RemoveUnreferencedVariablesTest, UserDefinedTypeReferencedInUnusedFunctionThatIsNotPruned)
{
const std::string &shaderString =
R"(
struct myStructType
{
int iMember;
};
myStructType func()
{
return myStructType(0);
}
void main()
{
})";
compile(shaderString, SH_DONT_PRUNE_UNUSED_FUNCTIONS);
ASSERT_TRUE(foundInCode("struct _umyStructType"));
// Ensure that the struct isn't declared as a part of the function header.
ASSERT_TRUE(foundInCode("};"));
}
// Test that a struct type that is only referenced as a function return value is kept. // Test that a struct type that is only referenced as a function return value is kept.
TEST_F(RemoveUnreferencedVariablesTest, UserDefinedTypeReturnedFromFunction) TEST_F(RemoveUnreferencedVariablesTest, UserDefinedTypeReturnedFromFunction)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment