28#define DEBUG_TYPE "arm-branch-targets"
29#define ARM_BRANCH_TARGETS_NAME "ARM Branch Targets"
45char ARMBranchTargets::ID = 0;
50void ARMBranchTargets::getAnalysisUsage(
AnalysisUsage &AU)
const {
56 return new ARMBranchTargets();
60 if (!MF.
getInfo<ARMFunctionInfo>()->branchTargetEnforcement())
64 <<
"********** Function: " << MF.
getName() <<
'\n');
65 const ARMInstrInfo &
TII =
66 *
static_cast<const ARMInstrInfo *
>(MF.
getSubtarget().getInstrInfo());
68 bool MadeChange =
false;
69 for (MachineBasicBlock &
MBB : MF) {
70 bool IsFirstBB = &
MBB == &MF.
front();
82 addBTI(
TII,
MBB, IsFirstBB);
96void ARMBranchTargets::addBTI(
const ARMInstrInfo &
TII, MachineBasicBlock &
MBB,
99 unsigned OpCode = ARM::t2BTI;
100 unsigned MIFlags = 0;
104 return MI.isMetaInstruction();
112 <<
"' to replace with PACBTI\n");
115 auto NextMBBI = std::next(
MBBI);
122 << (OpCode == ARM::t2BTI ?
"BTI" :
"PACBTI")
123 <<
"' instr into BB '" <<
MBB.
getName() <<
"'\n");
#define ARM_BRANCH_TARGETS_NAME
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
bool isEHPad() const
Returns true if the block is a landing pad.
bool isIRBlockAddressTaken() const
Test whether this block is the target of an IR BlockAddress.
LLVM_ABI DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
LLVM_ABI void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
instr_iterator instr_end()
bool isMachineBlockAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
LLVM_ABI StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
FunctionPass * createARMBranchTargetsPass()
auto find_if_not(R &&Range, UnaryPredicate P)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.