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