29#define DEBUG_TYPE "aarch64-branch-targets"
30#define AARCH64_BRANCH_TARGETS_NAME "AArch64 Branch Targets"
38 BTIMask = BTIC | BTIJ,
56char AArch64BranchTargets::ID = 0;
61void AArch64BranchTargets::getAnalysisUsage(
AnalysisUsage &AU)
const {
67 return new AArch64BranchTargets();
71 if (!MF.
getInfo<AArch64FunctionInfo>()->branchTargetEnforcement())
74 LLVM_DEBUG(
dbgs() <<
"********** AArch64 Branch Targets **********\n"
75 <<
"********** Function: " << MF.
getName() <<
'\n');
81 SmallPtrSet<MachineBasicBlock *, 8> JumpTableTargets;
83 for (
auto &JTE : JTI->getJumpTables())
86 bool MadeChange =
false;
88 for (MachineBasicBlock &
MBB : MF) {
89 bool CouldCall =
false, CouldJump =
false;
104 (!MF.getSubtarget<AArch64Subtarget>().isTargetELF() ||
105 (
F.hasAddressTaken() || !
F.hasLocalLinkage())))
120 if (CouldCall || CouldJump) {
121 addBTI(
MBB, CouldCall, CouldJump, HasWinCFI);
129void AArch64BranchTargets::addBTI(MachineBasicBlock &
MBB,
bool CouldCall,
130 bool CouldJump,
bool HasWinCFI) {
132 << (CouldCall ?
"c" :
"") <<
" to " <<
MBB.
getName()
135 const AArch64InstrInfo *
TII =
static_cast<const AArch64InstrInfo *
>(
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)
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.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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.
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.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void insert_range(Range &&R)
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()