aboutsummaryrefslogtreecommitdiff
path: root/include
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 /include
parent24367947367fe9fe2524e7923391a284aa6c3476 (diff)
downloadspirv-tools-5834719fc17d4735fce0102738b87b70255cfd5f.tar.gz
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 'include')
-rw-r--r--include/spirv-tools/optimizer.hpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/spirv-tools/optimizer.hpp b/include/spirv-tools/optimizer.hpp
index 32800e62..8d9f94d5 100644
--- a/include/spirv-tools/optimizer.hpp
+++ b/include/spirv-tools/optimizer.hpp
@@ -101,7 +101,7 @@ class Optimizer {
// Returns a vector of strings with all the pass names added to this
// optimizer's pass manager. These strings are valid until the associated
// pass manager is destroyed.
- std::vector<const char *> GetPassNames() const;
+ std::vector<const char*> GetPassNames() const;
private:
struct Impl; // Opaque struct for holding internal data.
@@ -118,9 +118,9 @@ Optimizer::PassToken CreateNullPass();
Optimizer::PassToken CreateStripDebugInfoPass();
// Creates an eliminate-dead-functions pass.
-// An eliminate-dead-functions pass will remove all functions that are not in the
-// call trees rooted at entry points and exported functions. These functions
-// are not needed because they will never be called.
+// An eliminate-dead-functions pass will remove all functions that are not in
+// the call trees rooted at entry points and exported functions. These
+// functions are not needed because they will never be called.
Optimizer::PassToken CreateEliminateDeadFunctionsPass();
// Creates a set-spec-constant-default-value pass from a mapping from spec-ids
@@ -401,6 +401,11 @@ Optimizer::PassToken CreateRemoveDuplicatesPass();
// - Removal of unreachable basic blocks.
Optimizer::PassToken CreateCFGCleanupPass();
+// Create dead variable elimination pass.
+// This pass will delete module scope variables, along with their decorations,
+// that are not referenced.
+Optimizer::PassToken CreateDeadVariableEliminationPass();
+
} // namespace spvtools
#endif // SPIRV_TOOLS_OPTIMIZER_HPP_