| 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 |
|
| 14 |
#include "ReduceInstructionFlagsMIR.h" |
| 15 |
#include "llvm/CodeGen/MachineFunction.h" |
| 16 |
#include "llvm/CodeGen/MachineModuleInfo.h" |
| 17 |
using namespace llvm; |
| 18 |
|
| 19 |
static void removeFlagsFromModule(Oracle &O, ReducerWorkItem &WorkItem) { |
| 20 |
for (const Function &F : WorkItem.getModule()) { |
| 21 |
if (auto *MF = WorkItem.MMI->getMachineFunction(F)) { |
| 22 |
for (MachineBasicBlock &MBB : *MF) { |
| 23 |
for (MachineInstr &MI : MBB) { |
| 24 |
// TODO: Should this clear flags individually? |
| 25 |
if (MI.getFlags() != 0 && !O.shouldKeep()) |
| 26 |
MI.setFlags(0); |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
void llvm::reduceInstructionFlagsMIRDeltaPass(TestRunner &Test) { |
| 34 |
runDeltaPass(Test, removeFlagsFromModule, "Reducing Instruction Flags"); |
| 35 |
} |