Debian Codegraph @

third_party/spirv-tools/source/reduce/remove_function_reduction_opportunity.cpp

raw
1 // Copyright (c) 2019 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "source/reduce/remove_function_reduction_opportunity.h"
16
17 #include "source/opt/eliminate_dead_functions_util.h"
18
19 namespace spvtools {
20 namespace reduce {
21
22 bool RemoveFunctionReductionOpportunity::PreconditionHolds() {
23 // Removing one function cannot influence whether another function can be
24 // removed.
25 return true;
26 }
27
28 void RemoveFunctionReductionOpportunity::Apply() {
29 for (opt::Module::iterator function_it = context_->module()->begin();
30 function_it != context_->module()->end(); ++function_it) {
31 if (&*function_it == function_) {
32 opt::eliminatedeadfunctionsutil::EliminateFunction(context_,
33 &function_it);
34 return;
35 }
36 }
37 assert(0 && "Function to be removed was not found.");
38 }
39
40 } // namespace reduce
41 } // namespace spvtools