[llvm] 2a61ced - [BPF] Remove unused legacy passes after TargetMachine::adjustPassManager removal
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 24 22:44:10 PDT 2023
Author: Fangrui Song
Date: 2023-06-24T22:44:06-07:00
New Revision: 2a61ceddb30aaed291317795e3183371e8cf3d7a
URL: https://github.com/llvm/llvm-project/commit/2a61ceddb30aaed291317795e3183371e8cf3d7a
DIFF: https://github.com/llvm/llvm-project/commit/2a61ceddb30aaed291317795e3183371e8cf3d7a.diff
LOG: [BPF] Remove unused legacy passes after TargetMachine::adjustPassManager removal
D137796 made these passes unused.
`opt --bpf-ir-peephole` is specified in one test. Add a `registerPipelineParsingCallback`
so that we can use change the test to use `opt --passes=bpf-ir-peephole` instead.
Added:
Modified:
llvm/lib/Target/BPF/BPF.h
llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
llvm/lib/Target/BPF/BPFAdjustOpt.cpp
llvm/lib/Target/BPF/BPFIRPeephole.cpp
llvm/lib/Target/BPF/BPFPreserveDIType.cpp
llvm/lib/Target/BPF/BPFTargetMachine.cpp
llvm/test/CodeGen/BPF/vla.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/BPF/BPF.h b/llvm/lib/Target/BPF/BPF.h
index b48c122f48b4d..9b7bab785ee97 100644
--- a/llvm/lib/Target/BPF/BPF.h
+++ b/llvm/lib/Target/BPF/BPF.h
@@ -18,12 +18,8 @@ namespace llvm {
class BPFTargetMachine;
class PassRegistry;
-ModulePass *createBPFAdjustOpt();
ModulePass *createBPFCheckAndAdjustIR();
-FunctionPass *createBPFAbstractMemberAccess(BPFTargetMachine *TM);
-FunctionPass *createBPFPreserveDIType();
-FunctionPass *createBPFIRPeephole();
FunctionPass *createBPFISelDag(BPFTargetMachine &TM);
FunctionPass *createBPFMISimplifyPatchablePass();
FunctionPass *createBPFMIPeepholePass();
@@ -31,17 +27,13 @@ FunctionPass *createBPFMIPeepholeTruncElimPass();
FunctionPass *createBPFMIPreEmitPeepholePass();
FunctionPass *createBPFMIPreEmitCheckingPass();
-void initializeBPFAbstractMemberAccessLegacyPassPass(PassRegistry &);
-void initializeBPFAdjustOptPass(PassRegistry&);
void initializeBPFCheckAndAdjustIRPass(PassRegistry&);
void initializeBPFDAGToDAGISelPass(PassRegistry &);
-void initializeBPFIRPeepholePass(PassRegistry &);
void initializeBPFMIPeepholePass(PassRegistry&);
void initializeBPFMIPeepholeTruncElimPass(PassRegistry &);
void initializeBPFMIPreEmitCheckingPass(PassRegistry&);
void initializeBPFMIPreEmitPeepholePass(PassRegistry &);
void initializeBPFMISimplifyPatchablePass(PassRegistry &);
-void initializeBPFPreserveDITypePass(PassRegistry &);
class BPFAbstractMemberAccessPass
: public PassInfoMixin<BPFAbstractMemberAccessPass> {
diff --git a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
index a130a9c3e08ed..9c99765b60c08 100644
--- a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
+++ b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
@@ -188,35 +188,8 @@ class BPFAbstractMemberAccess final {
};
std::map<std::string, GlobalVariable *> BPFAbstractMemberAccess::GEPGlobals;
-
-class BPFAbstractMemberAccessLegacyPass final : public FunctionPass {
- BPFTargetMachine *TM;
-
- bool runOnFunction(Function &F) override {
- return BPFAbstractMemberAccess(TM).run(F);
- }
-
-public:
- static char ID;
-
- // Add optional BPFTargetMachine parameter so that BPF backend can add the
- // phase with target machine to find out the endianness. The default
- // constructor (without parameters) is used by the pass manager for managing
- // purposes.
- BPFAbstractMemberAccessLegacyPass(BPFTargetMachine *TM = nullptr)
- : FunctionPass(ID), TM(TM) {}
-};
-
} // End anonymous namespace
-char BPFAbstractMemberAccessLegacyPass::ID = 0;
-INITIALIZE_PASS(BPFAbstractMemberAccessLegacyPass, DEBUG_TYPE,
- "BPF Abstract Member Access", false, false)
-
-FunctionPass *llvm::createBPFAbstractMemberAccess(BPFTargetMachine *TM) {
- return new BPFAbstractMemberAccessLegacyPass(TM);
-}
-
bool BPFAbstractMemberAccess::run(Function &F) {
LLVM_DEBUG(dbgs() << "********** Abstract Member Accesses **********\n");
diff --git a/llvm/lib/Target/BPF/BPFAdjustOpt.cpp b/llvm/lib/Target/BPF/BPFAdjustOpt.cpp
index e109235434e9d..4ab0cbcc92477 100644
--- a/llvm/lib/Target/BPF/BPFAdjustOpt.cpp
+++ b/llvm/lib/Target/BPF/BPFAdjustOpt.cpp
@@ -40,15 +40,6 @@ static cl::opt<bool> DisableBPFavoidSpeculation(
cl::init(false));
namespace {
-
-class BPFAdjustOpt final : public ModulePass {
-public:
- static char ID;
-
- BPFAdjustOpt() : ModulePass(ID) {}
- bool runOnModule(Module &M) override;
-};
-
class BPFAdjustOptImpl {
struct PassThroughInfo {
Instruction *Input;
@@ -78,14 +69,6 @@ class BPFAdjustOptImpl {
} // End anonymous namespace
-char BPFAdjustOpt::ID = 0;
-INITIALIZE_PASS(BPFAdjustOpt, "bpf-adjust-opt", "BPF Adjust Optimization",
- false, false)
-
-ModulePass *llvm::createBPFAdjustOpt() { return new BPFAdjustOpt(); }
-
-bool BPFAdjustOpt::runOnModule(Module &M) { return BPFAdjustOptImpl(&M).run(); }
-
bool BPFAdjustOptImpl::run() {
bool Changed = adjustICmpToBuiltin();
diff --git a/llvm/lib/Target/BPF/BPFIRPeephole.cpp b/llvm/lib/Target/BPF/BPFIRPeephole.cpp
index 283b3687f7ccc..a257f582f2a10 100644
--- a/llvm/lib/Target/BPF/BPFIRPeephole.cpp
+++ b/llvm/lib/Target/BPF/BPFIRPeephole.cpp
@@ -90,23 +90,8 @@ static bool BPFIRPeepholeImpl(Function &F) {
return Changed;
}
-
-class BPFIRPeephole final : public FunctionPass {
- bool runOnFunction(Function &F) override;
-
-public:
- static char ID;
- BPFIRPeephole() : FunctionPass(ID) {}
-};
} // End anonymous namespace
-char BPFIRPeephole::ID = 0;
-INITIALIZE_PASS(BPFIRPeephole, DEBUG_TYPE, "BPF IR Peephole", false, false)
-
-FunctionPass *llvm::createBPFIRPeephole() { return new BPFIRPeephole(); }
-
-bool BPFIRPeephole::runOnFunction(Function &F) { return BPFIRPeepholeImpl(F); }
-
PreservedAnalyses BPFIRPeepholePass::run(Function &F,
FunctionAnalysisManager &AM) {
return BPFIRPeepholeImpl(F) ? PreservedAnalyses::none()
diff --git a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
index 58d18e66a6aa2..ec770eecb2e50 100644
--- a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
+++ b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
@@ -125,28 +125,8 @@ static bool BPFPreserveDITypeImpl(Function &F) {
return true;
}
-
-class BPFPreserveDIType final : public FunctionPass {
- bool runOnFunction(Function &F) override;
-
-public:
- static char ID;
- BPFPreserveDIType() : FunctionPass(ID) {}
-};
} // End anonymous namespace
-char BPFPreserveDIType::ID = 0;
-INITIALIZE_PASS(BPFPreserveDIType, DEBUG_TYPE, "BPF Preserve Debuginfo Type",
- false, false)
-
-FunctionPass *llvm::createBPFPreserveDIType() {
- return new BPFPreserveDIType();
-}
-
-bool BPFPreserveDIType::runOnFunction(Function &F) {
- return BPFPreserveDITypeImpl(F);
-}
-
PreservedAnalyses BPFPreserveDITypePass::run(Function &F,
FunctionAnalysisManager &AM) {
return BPFPreserveDITypeImpl(F) ? PreservedAnalyses::none()
diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
index 1bbdc583c4e50..c47e8274b2e2f 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
@@ -40,10 +40,6 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFTarget() {
RegisterTargetMachine<BPFTargetMachine> Z(getTheBPFTarget());
PassRegistry &PR = *PassRegistry::getPassRegistry();
- initializeBPFAbstractMemberAccessLegacyPassPass(PR);
- initializeBPFPreserveDITypePass(PR);
- initializeBPFIRPeepholePass(PR);
- initializeBPFAdjustOptPass(PR);
initializeBPFCheckAndAdjustIRPass(PR);
initializeBPFMIPeepholePass(PR);
initializeBPFMIPeepholeTruncElimPass(PR);
@@ -103,6 +99,15 @@ TargetPassConfig *BPFTargetMachine::createPassConfig(PassManagerBase &PM) {
}
void BPFTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
+ PB.registerPipelineParsingCallback(
+ [](StringRef PassName, FunctionPassManager &FPM,
+ ArrayRef<PassBuilder::PipelineElement>) {
+ if (PassName == "bpf-ir-peephole") {
+ FPM.addPass(BPFIRPeepholePass());
+ return true;
+ }
+ return false;
+ });
PB.registerPipelineStartEPCallback(
[=](ModulePassManager &MPM, OptimizationLevel) {
FunctionPassManager FPM;
diff --git a/llvm/test/CodeGen/BPF/vla.ll b/llvm/test/CodeGen/BPF/vla.ll
index 68124bf5e20f7..9a2276970bb52 100644
--- a/llvm/test/CodeGen/BPF/vla.ll
+++ b/llvm/test/CodeGen/BPF/vla.ll
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt --bpf-ir-peephole -mtriple=bpf-pc-linux -S %s | FileCheck %s
+; RUN: opt -passes=bpf-ir-peephole -mtriple=bpf-pc-linux -S %s | FileCheck %s
; Source:
; #define AA 40
; struct t {
More information about the llvm-commits
mailing list