#include "X86.h"
#include "X86InstrInfo.h"
#include "X86Subtarget.h"
#include "X86TargetMachine.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/IR/Module.h"
usingnamespacellvm;
#define DEBUG_TYPE …
cl::opt<bool> IndirectBranchTracking(
"x86-indirect-branch-tracking", cl::init(false), cl::Hidden,
cl::desc("Enable X86 indirect branch tracking pass."));
STATISTIC(NumEndBranchAdded, "Number of ENDBR instructions added");
namespace {
class X86IndirectBranchTrackingPass : public MachineFunctionPass { … };
}
char X86IndirectBranchTrackingPass::ID = …;
FunctionPass *llvm::createX86IndirectBranchTrackingPass() { … }
bool X86IndirectBranchTrackingPass::addENDBR(
MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { … }
static bool IsCallReturnTwice(llvm::MachineOperand &MOp) { … }
static bool needsPrologueENDBR(MachineFunction &MF, const Module *M) { … }
bool X86IndirectBranchTrackingPass::runOnMachineFunction(MachineFunction &MF) { … }