ReduceInstructionFlagsMIR.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //===- ReduceInstructionFlagsMIR.cpp - Specialized Delta Pass -------------===//
  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 function which calls the Generic Delta pass in order
  10. // to reduce uninteresting MachineInstr flags from the MachineFunction.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "ReduceInstructionFlagsMIR.h"
  14. #include "llvm/CodeGen/MachineFunction.h"
  15. #include "llvm/CodeGen/MachineModuleInfo.h"
  16. using namespace llvm;
  17. static void removeFlagsFromModule(Oracle &O, ReducerWorkItem &WorkItem) {
  18. for (const Function &F : WorkItem.getModule()) {
  19. if (auto *MF = WorkItem.MMI->getMachineFunction(F)) {
  20. for (MachineBasicBlock &MBB : *MF) {
  21. for (MachineInstr &MI : MBB) {
  22. // TODO: Should this clear flags individually?
  23. if (MI.getFlags() != 0 && !O.shouldKeep())
  24. MI.setFlags(0);
  25. }
  26. }
  27. }
  28. }
  29. }
  30. void llvm::reduceInstructionFlagsMIRDeltaPass(TestRunner &Test) {
  31. runDeltaPass(Test, removeFlagsFromModule, "Reducing Instruction Flags");
  32. }