Clean up dead-code elimination in optimizer.
Dead-function-removal and dead-global-removal was implemented directly
inside of Compiler::optimize(). This code has been broken out into
separate helper functions for clarity.
Additionally, dead-function elimination was guarded by a ProgramSetting,
but dead-variable elimination was only guarded by fOptimize. A new flag
for dead-variable elimination was added for consistency.
Change-Id: I783501362762dad08262ffb92602d02ec079ed9b
Bug: skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/382917
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/SkSLProgramSettings.h b/src/sksl/SkSLProgramSettings.h
index 8d21c2c..1fe6754 100644
--- a/src/sksl/SkSLProgramSettings.h
+++ b/src/sksl/SkSLProgramSettings.h
@@ -53,9 +53,11 @@
int fDefaultUniformBinding = 0;
// Enables the SkSL optimizer.
bool fOptimize = true;
- // (Requires fOptimize = true) Remove any uncalled functions other than main(). Note that a
+ // (Requires fOptimize = true) Removes any uncalled functions other than main(). Note that a
// function which starts out being used may end up being uncalled after optimization.
bool fRemoveDeadFunctions = true;
+ // (Requires fOptimize = true) Removes global variables which are never used.
+ bool fRemoveDeadVariables = true;
// (Requires fOptimize = true) When greater than zero, enables the inliner. The threshold value
// sets an upper limit on the acceptable amount of code growth from inlining.
int fInlineThreshold = SkSL::kDefaultInlineThreshold;