31#define DEBUG_TYPE "aarch64-branch-targets"
32#define AARCH64_BRANCH_TARGETS_NAME "AArch64 Branch Targets"
40 BTIMask = BTIC | BTIJ,
43class AArch64BranchTargetsImpl {
65char AArch64BranchTargetsLegacy::ID = 0;
70void AArch64BranchTargetsLegacy::getAnalysisUsage(
AnalysisUsage &AU)
const {
76 return new AArch64BranchTargetsLegacy();
79bool AArch64BranchTargetsLegacy::runOnMachineFunction(
MachineFunction &MF) {
80 return AArch64BranchTargetsImpl().run(MF);
86 bool Changed = AArch64BranchTargetsImpl().run(MF);
98 LLVM_DEBUG(
dbgs() <<
"********** AArch64 Branch Targets **********\n"
99 <<
"********** Function: " << MF.
getName() <<
'\n');
109 for (
auto &JTE : JTI->getJumpTables())
112 bool MadeChange =
false;
115 bool CouldCall =
false, CouldJump =
false;
130 (
F.hasAddressTaken() || !
F.hasLocalLinkage())))
135 if (
MBB.isMachineBlockAddressTaken() ||
MBB.isIRBlockAddressTaken() ||
136 JumpTableTargets.count(&
MBB))
140 if (HasWinCFI && (
MBB.isEHFuncletEntry() ||
MBB.isCleanupFuncletEntry()))
145 if (CouldCall || CouldJump) {
146 addBTI(
MBB, CouldCall, CouldJump, HasWinCFI);
154void AArch64BranchTargetsImpl::addBTI(MachineBasicBlock &
MBB,
bool CouldCall,
155 bool CouldJump,
bool HasWinCFI) {
157 << (CouldCall ?
"c" :
"") <<
" to " <<
MBB.
getName()
170 (
MBBI->isMetaInstruction() ||
MBBI->getOpcode() == AArch64::EMITBKEY);
177 if (
MBBI !=
MBB.
end() && ((HintNum & BTIMask) == BTIC) &&
178 (
MBBI->getOpcode() == AArch64::PACIASP ||
179 MBBI->getOpcode() == AArch64::PACIBSP))
#define AARCH64_BRANCH_TARGETS_NAME
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
bool branchTargetEnforcement() const
const AArch64InstrInfo * getInstrInfo() const override
Represent the analysis usage information of a pass.
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
LLVM_ABI DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
MachineInstrBundleIterator< MachineInstr > iterator
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.
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.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
void insert_range(Range &&R)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
static unsigned getBTIHintNum(bool CallTarget, bool JumpTarget)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createAArch64BranchTargetsPass()