ReduceModuleData.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. //===- ReduceModuleData.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. //
  9. // This file implements a reduce pass to reduce various module data.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "ReduceModuleData.h"
  13. using namespace llvm;
  14. static void clearModuleData(Oracle &O, ReducerWorkItem &WorkItem) {
  15. Module &Program = WorkItem.getModule();
  16. if (!Program.getModuleIdentifier().empty() && !O.shouldKeep())
  17. Program.setModuleIdentifier("");
  18. if (!Program.getSourceFileName().empty() && !O.shouldKeep())
  19. Program.setSourceFileName("");
  20. // TODO: clear line by line rather than all at once
  21. if (!Program.getModuleInlineAsm().empty() && !O.shouldKeep())
  22. Program.setModuleInlineAsm("");
  23. }
  24. void llvm::reduceModuleDataDeltaPass(TestRunner &Test) {
  25. runDeltaPass(Test, clearModuleData, "Reducing Module Data");
  26. }