summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSteven Perron <stevenperron@google.com>2017-10-20 12:17:41 -0400
committerDavid Neto <dneto@google.com>2017-10-23 13:57:05 -0400
commit5834719fc17d4735fce0102738b87b70255cfd5f (patch)
treeee1dad8331b0ecfbeaa3faffb10dc723ee9cdffc /tools
parent24367947367fe9fe2524e7923391a284aa6c3476 (diff)
downloadSPIRV-Tools-5834719fc17d4735fce0102738b87b70255cfd5f.tar.gz
SPIRV-Tools-5834719fc17d4735fce0102738b87b70255cfd5f.tar.bz2
SPIRV-Tools-5834719fc17d4735fce0102738b87b70255cfd5f.zip
Add pass to remove dead variables at the module level.
There does not seem to be any pass that remove global variables. I think we could use one. This pass will look specifically for global variables that are not referenced and are not exported. Any decoration associated with the variable will also be removed. However, this could cause types or constants to become unreferenced. They will not be removed. Another pass will have to be called to remove those.
Diffstat (limited to 'tools')
-rw-r--r--tools/opt/opt.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 2a187f04..dd44d248 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -153,6 +153,8 @@ Options:
call tree functions.
--strength-reduction
Replaces instructions with equivalent and less expensive ones.
+ --eliminate-dead-variables
+ Deletes module scope variables that are not referenced.
-O
Optimize for performance. Apply a sequence of transformations
in an attempt to improve the performance of the generated
@@ -353,6 +355,8 @@ OptStatus ParseFlags(int argc, const char** argv, Optimizer* optimizer,
optimizer->RegisterPass(CreateCommonUniformElimPass());
} else if (0 == strcmp(cur_arg, "--eliminate-dead-const")) {
optimizer->RegisterPass(CreateEliminateDeadConstantPass());
+ } else if (0 == strcmp(cur_arg, "--eliminate-dead-variables")) {
+ optimizer->RegisterPass(CreateDeadVariableEliminationPass());
} else if (0 == strcmp(cur_arg, "--fold-spec-const-op-composite")) {
optimizer->RegisterPass(CreateFoldSpecConstantOpAndCompositePass());
} else if (0 == strcmp(cur_arg, "--strength-reduction")) {