diff options
author | Steven Perron <stevenperron@google.com> | 2017-10-20 12:17:41 -0400 |
---|---|---|
committer | David Neto <dneto@google.com> | 2017-10-23 13:57:05 -0400 |
commit | 5834719fc17d4735fce0102738b87b70255cfd5f (patch) | |
tree | ee1dad8331b0ecfbeaa3faffb10dc723ee9cdffc /tools | |
parent | 24367947367fe9fe2524e7923391a284aa6c3476 (diff) | |
download | SPIRV-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.cpp | 4 |
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")) { |