Go to the documentation of this file.
32 #define DEBUG_TYPE "bpf-check-and-opt-ir"
38 class BPFCheckAndAdjustIR final :
public ModulePass {
39 bool runOnModule(
Module &
F)
override;
48 bool removePassThroughBuiltin(
Module &
M);
49 bool removeCompareBuiltin(
Module &
M);
58 return new BPFCheckAndAdjustIR();
61 void BPFCheckAndAdjustIR::checkIR(
Module &M) {
94 bool BPFCheckAndAdjustIR::removePassThroughBuiltin(
Module &M) {
105 ToBeDeleted =
nullptr;
108 auto *
Call = dyn_cast<CallInst>(&
I);
111 auto *GV = dyn_cast<GlobalValue>(
Call->getCalledOperand());
114 if (!GV->getName().startswith(
"llvm.bpf.passthrough"))
124 bool BPFCheckAndAdjustIR::removeCompareBuiltin(
Module &M) {
128 bool Changed =
false;
135 ToBeDeleted =
nullptr;
138 auto *
Call = dyn_cast<CallInst>(&
I);
141 auto *GV = dyn_cast<GlobalValue>(
Call->getCalledOperand());
144 if (!GV->getName().startswith(
"llvm.bpf.compare"))
152 auto OpVal = cast<ConstantInt>(Arg0)->getValue().getZExtValue();
155 auto *ICmp =
new ICmpInst(Opcode, Arg1, Arg2);
156 ICmp->insertBefore(Call);
158 Call->replaceAllUsesWith(ICmp);
164 bool BPFCheckAndAdjustIR::adjustIR(
Module &M) {
165 bool Changed = removePassThroughBuiltin(M);
166 Changed = removeCompareBuiltin(M) || Changed;
170 bool BPFCheckAndAdjustIR::runOnModule(
Module &M) {
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
ModulePass * createBPFCheckAndAdjustIR()
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
This instruction compares its operands according to the predicate given to the constructor.
INITIALIZE_PASS(BPFCheckAndAdjustIR, DEBUG_TYPE, "BPF Check And Adjust IR", false, false) ModulePass *llvm
static constexpr StringRef TypeIdAttr
The attribute attached to globals representing a type id.
A Module instance is used to store all the information related to an LLVM module.
static constexpr StringRef AmaAttr
The attribute attached to globals representing a field access.
This class represents a function call, abstracting a target machine's calling convention.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
LLVM Value Representation.