28#define DEBUG_TYPE "bpf-mi-checking"
86 &getBPFMCRegisterClass(BPF::GPRRegClassID);
87 std::vector<unsigned> GPR32LiveDefs;
88 std::vector<unsigned> GPR64DeadDefs;
93 if (!MO.isReg() || MO.isUse())
96 RegIsGPR64 = GPR64RegClass->
contains(MO.getReg());
104 GPR32LiveDefs.push_back(MO.getReg());
111 GPR64DeadDefs.push_back(MO.getReg());
115 if (GPR32LiveDefs.empty())
120 if (GPR64DeadDefs.empty())
124 for (
auto I : GPR32LiveDefs)
145 if (
MI.getOpcode() != BPF::XADDW &&
MI.getOpcode() != BPF::XADDD)
149 if (hasLiveDefs(
MI,
TRI)) {
153 F,
"Invalid usage of the XADD return value",
DL});
159bool BPFMIPreEmitCheckingLegacy::runOnMachineFunction(
MachineFunction &MF) {
174 "BPF PreEmit Checking",
false,
false)
176char BPFMIPreEmitCheckingLegacy::ID = 0;
178 return new BPFMIPreEmitCheckingLegacy();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void processAtomicInsts(MachineFunction &MF)
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Diagnostic information for unsupported feature in backend.
FunctionPass class - This class is used to implement most global optimizations.
MCRegisterClass - Base class of TargetRegisterClass.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
FunctionPass * createBPFMIPreEmitCheckingLegacyPass()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.