18 #define DEBUG_TYPE "double barriers"
20 STATISTIC(NumDMBsRemoved,
"Number of DMBs removed");
30 const char *getPassName()
const override {
31 return "optimise barriers pass";
48 bool ARMOptimizeBarriersPass::runOnMachineFunction(
MachineFunction &MF) {
50 std::vector<MachineInstr *> ToRemove;
57 for (
auto &MBB : MF) {
60 bool IsRemovableNextDMB =
false;
61 for (
auto &
MI : MBB) {
62 if (
MI.getOpcode() == ARM::DMB) {
63 if (IsRemovableNextDMB) {
66 if (
MI.getOperand(0).getImm() == DMBType) {
67 ToRemove.push_back(&
MI);
71 DMBType =
MI.getOperand(0).getImm();
75 IsRemovableNextDMB =
true;
76 DMBType =
MI.getOperand(0).getImm();
81 IsRemovableNextDMB =
false;
86 for (
auto MI : ToRemove) {
87 MI->eraseFromParent();
91 return NumDMBsRemoved > 0;
98 return new ARMOptimizeBarriersPass();
STATISTIC(NumFunctions,"Total number of functions")
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
FunctionPass * createARMOptimizeBarriersPass()
createARMOptimizeBarriersPass - Returns an instance of the remove double barriers pass...
static bool CanMovePastDMB(const MachineInstr *MI)
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
bool isReturn(QueryType Type=AnyInBundle) const
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
FunctionPass class - This class is used to implement most global optimizations.
Representation of each machine instruction.
bool isCall(QueryType Type=AnyInBundle) const