strip_debug_info_pass.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2016 Google Inc.
  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. #include "source/opt/strip_debug_info_pass.h"
  15. #include "source/opt/ir_context.h"
  16. namespace spvtools {
  17. namespace opt {
  18. Pass::Status StripDebugInfoPass::Process() {
  19. bool modified = !context()->debugs1().empty() ||
  20. !context()->debugs2().empty() ||
  21. !context()->debugs3().empty();
  22. context()->debug_clear();
  23. context()->module()->ForEachInst([&modified](Instruction* inst) {
  24. modified |= !inst->dbg_line_insts().empty();
  25. inst->dbg_line_insts().clear();
  26. });
  27. return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange;
  28. }
  29. } // namespace opt
  30. } // namespace spvtools