StripDebugInfo.cpp 1012 B

1234567891011121314151617181920212223242526272829
  1. //===- StripDebugInfo.cpp -------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "StripDebugInfo.h"
  9. #include "Delta.h"
  10. #include "llvm/IR/DebugInfo.h"
  11. #include "llvm/IR/Metadata.h"
  12. using namespace llvm;
  13. /// Removes all aliases aren't inside any of the
  14. /// desired Chunks.
  15. static void stripDebugInfoImpl(Oracle &O, ReducerWorkItem &WorkItem) {
  16. Module &Program = WorkItem.getModule();
  17. bool HasDebugInfo = any_of(Program.named_metadata(), [](NamedMDNode &NMD) {
  18. return NMD.getName().startswith("llvm.dbg.");
  19. });
  20. if (HasDebugInfo && !O.shouldKeep())
  21. StripDebugInfo(Program);
  22. }
  23. void llvm::stripDebugInfoDeltaPass(TestRunner &Test) {
  24. runDeltaPass(Test, stripDebugInfoImpl, "Stripping Debug Info");
  25. }