18 #define DEBUG_TYPE "double barriers"
20 STATISTIC(NumDMBsRemoved,
"Number of DMBs removed");
35 StringRef getPassName()
const override {
return "optimise barriers pass"; }
51 bool ARMOptimizeBarriersPass::runOnMachineFunction(
MachineFunction &MF) {
56 std::vector<MachineInstr *> ToRemove;
63 for (
auto &
MBB : MF) {
66 bool IsRemovableNextDMB =
false;
67 for (
auto &
MI :
MBB) {
68 if (
MI.getOpcode() == ARM::DMB) {
69 if (IsRemovableNextDMB) {
72 if (
MI.getOperand(0).getImm() == DMBType) {
73 ToRemove.push_back(&
MI);
77 DMBType =
MI.getOperand(0).getImm();
81 IsRemovableNextDMB =
true;
82 DMBType =
MI.getOperand(0).getImm();
87 IsRemovableNextDMB =
false;
92 for (
auto MI : ToRemove) {
93 MI->eraseFromParent();
97 return NumDMBsRemoved > 0;
104 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...
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
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.
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
bool isCall(QueryType Type=AnyInBundle) const
StringRef - Represent a constant reference to a string, i.e.
Properties which a MachineFunction may have at a given point in time.