29#define DEBUG_TYPE "aarch64-branch-targets"
30#define AARCH64_BRANCH_TARGETS_NAME "AArch64 Branch Targets"
38 BTIMask = BTIC | BTIJ,
58char AArch64BranchTargets::ID = 0;
63void AArch64BranchTargets::getAnalysisUsage(
AnalysisUsage &AU)
const {
69 return new AArch64BranchTargets();
73 if (!MF.
getInfo<AArch64FunctionInfo>()->branchTargetEnforcement())
76 LLVM_DEBUG(
dbgs() <<
"********** AArch64 Branch Targets **********\n"
77 <<
"********** Function: " << MF.
getName() <<
'\n');
85 SmallPtrSet<MachineBasicBlock *, 8> JumpTableTargets;
87 for (
auto &JTE : JTI->getJumpTables())
88 JumpTableTargets.insert_range(JTE.MBBs);
90 bool MadeChange =
false;
92 for (MachineBasicBlock &
MBB : MF) {
93 bool CouldCall =
false, CouldJump =
false;
108 (
F.hasAddressTaken() || !
F.hasLocalLinkage())))
114 JumpTableTargets.count(&
MBB))
123 if (CouldCall || CouldJump) {
124 addBTI(
MBB, CouldCall, CouldJump, HasWinCFI);
132void AArch64BranchTargets::addBTI(MachineBasicBlock &
MBB,
bool CouldCall,
133 bool CouldJump,
bool HasWinCFI) {
135 << (CouldCall ?
"c" :
"") <<
" to " <<
MBB.
getName()
138 unsigned HintNum = 32;
143 assert(HintNum != 32 &&
"No target kinds!");
154 (
MBBI->isMetaInstruction() ||
MBBI->getOpcode() == AArch64::EMITBKEY);
160 if (
MBBI !=
MBB.
end() && ((HintNum & BTIMask) == BTIC) &&
161 (
MBBI->getOpcode() == AArch64::PACIASP ||
162 MBBI->getOpcode() == AArch64::PACIBSP))
#define AARCH64_BRANCH_TARGETS_NAME
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
const AArch64InstrInfo * getInstrInfo() const override
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.
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
LLVM_ABI DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
bool isMachineBlockAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
MachineInstrBundleIterator< MachineInstr > iterator
LLVM_ABI StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
bool isCleanupFuncletEntry() const
Returns true if this is the entry block of a cleanup funclet.
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.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
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.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createAArch64BranchTargetsPass()