25#define DEBUG_TYPE "bpf-ir-peephole"
31static bool BPFIRPeepholeImpl(
Function &
F) {
60 if (
auto *II = dyn_cast<IntrinsicInst>(&
I)) {
61 if (II->getIntrinsicID() != Intrinsic::stacksave)
63 if (!II->hasOneUser())
65 auto *Inst = cast<Instruction>(*II->user_begin());
69 Inst->eraseFromParent();
74 if (
auto *LD = dyn_cast<LoadInst>(&
I)) {
75 if (!LD->hasOneUser())
77 auto *II = dyn_cast<IntrinsicInst>(*LD->user_begin());
80 if (II->getIntrinsicID() != Intrinsic::stackrestore)
85 II->eraseFromParent();
103char BPFIRPeephole::ID = 0;
108bool BPFIRPeephole::runOnFunction(
Function &
F) {
return BPFIRPeepholeImpl(
F); }
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
A container for analyses that lazily runs them and caches their results.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createBPFIRPeephole()