Run dead variable elimination when using -O and -Os
authorSteven Perron <stevenperron@google.com>
Mon, 23 Oct 2017 19:48:29 +0000 (15:48 -0400)
committerDavid Neto <dneto@google.com>
Tue, 24 Oct 2017 02:09:12 +0000 (22:09 -0400)
We want to run the optimization when using -O and -Os, but it was not
added at part of https://github.com/KhronosGroup/SPIRV-Tools/pull/905.
This change will add that a well as some minor formatting changes
requested in that same pull request.

source/opt/CMakeLists.txt
source/opt/optimizer.cpp
source/util/ilist_node.h

index bf3dcb1..99fe747 100644 (file)
@@ -21,7 +21,7 @@ add_library(SPIRV-Tools-opt
   compact_ids_pass.h
   constants.h
   dead_branch_elim_pass.h
-        dead_variable_elimination.h
+  dead_variable_elimination.h
   decoration_manager.h
   def_use_manager.h
   eliminate_dead_constant_pass.h
@@ -67,7 +67,7 @@ add_library(SPIRV-Tools-opt
   decoration_manager.cpp
   def_use_manager.cpp
   dead_branch_elim_pass.cpp
-        dead_variable_elimination.cpp
+  dead_variable_elimination.cpp
   eliminate_dead_constant_pass.cpp
   flatten_decoration_pass.cpp
   fold.cpp
@@ -97,7 +97,7 @@ add_library(SPIRV-Tools-opt
   types.cpp
   type_manager.cpp
   unify_const_pass.cpp
-        instruction_list.cpp)
+  instruction_list.cpp)
 
 spvtools_default_compile_options(SPIRV-Tools-opt)
 target_include_directories(SPIRV-Tools-opt
index a0ea1eb..2fdfe21 100644 (file)
@@ -77,7 +77,8 @@ Optimizer& Optimizer::RegisterPerformancePasses() {
       .RegisterPass(CreateBlockMergePass())
       .RegisterPass(CreateLocalMultiStoreElimPass())
       .RegisterPass(CreateInsertExtractElimPass())
-      .RegisterPass(CreateCommonUniformElimPass());
+      .RegisterPass(CreateCommonUniformElimPass())
+      .RegisterPass(CreateDeadVariableEliminationPass());
 }
 
 Optimizer& Optimizer::RegisterSizePasses() {
@@ -91,7 +92,8 @@ Optimizer& Optimizer::RegisterSizePasses() {
       .RegisterPass(CreateBlockMergePass())
       .RegisterPass(CreateLocalMultiStoreElimPass())
       .RegisterPass(CreateInsertExtractElimPass())
-      .RegisterPass(CreateCommonUniformElimPass());
+      .RegisterPass(CreateCommonUniformElimPass())
+      .RegisterPass(CreateDeadVariableEliminationPass());
 }
 
 bool Optimizer::Run(const uint32_t* original_binary,
index a002384..342fb1d 100644 (file)
@@ -122,7 +122,9 @@ template<class NodeType>
 inline IntrusiveNodeBase<NodeType>& IntrusiveNodeBase<NodeType>::operator=(
     const IntrusiveNodeBase&) {
   assert(!is_sentinel_);
-  if (IsInAList()) RemoveFromList();
+  if (IsInAList()) {
+    RemoveFromList();
+  }
   return *this;
 }