Remove TargetMachine::adjustPassManager

Since opt no longer supports to run default (O0/O1/O2/O3/Os/Oz)
pipelines using the legacy PM, there are no in-tree uses of
TargetMachine::adjustPassManager remaining. This patch removes the
no longer used adjustPassManager functions.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D137796
This commit is contained in:
Bjorn Pettersson 2022-11-10 20:11:06 +01:00
parent 962343a979
commit 99c47d9e31
14 changed files with 16 additions and 148 deletions

View File

@ -328,14 +328,16 @@ optimization pipeline before dead-code elimination.
The NVPTX TargetMachine knows how to schedule ``NVVMReflect`` at the beginning The NVPTX TargetMachine knows how to schedule ``NVVMReflect`` at the beginning
of your pass manager; just use the following code when setting up your pass of your pass manager; just use the following code when setting up your pass
manager: manager and the PassBuilder will use ``registerPassBuilderCallbacks`` to let
NVPTXTargetMachine::registerPassBuilderCallbacks add the the pass to the
pass manager:
.. code-block:: c++ .. code-block:: c++
std::unique_ptr<TargetMachine> TM = ...; std::unique_ptr<TargetMachine> TM = ...;
PassManagerBuilder PMBuilder(...); PassBuilder PB(TM);
if (TM) ModulePassManager MPM;
TM->adjustPassManager(PMBuilder); PB.parsePassPipeline(MPM, ...);
Reflection Parameters Reflection Parameters
--------------------- ---------------------

View File

@ -171,8 +171,7 @@ managers created by that ``PassBuilder``. See the documentation for
If a ``PassBuilder`` has a corresponding ``TargetMachine`` for a backend, it If a ``PassBuilder`` has a corresponding ``TargetMachine`` for a backend, it
will call ``TargetMachine::registerPassBuilderCallbacks()`` to allow the will call ``TargetMachine::registerPassBuilderCallbacks()`` to allow the
backend to inject passes into the pipeline. This is equivalent to the legacy backend to inject passes into the pipeline.
PM's ``TargetMachine::adjustPassManager()``.
Clang's ``BackendUtil.cpp`` shows examples of a frontend adding (mostly Clang's ``BackendUtil.cpp`` shows examples of a frontend adding (mostly
sanitizer) passes to various parts of the pipeline. sanitizer) passes to various parts of the pipeline.
@ -518,10 +517,13 @@ remove its usage.
Some IR passes are considered part of the backend codegen pipeline even if Some IR passes are considered part of the backend codegen pipeline even if
they are LLVM IR passes (whereas all MIR passes are codegen passes). This they are LLVM IR passes (whereas all MIR passes are codegen passes). This
includes anything added via ``TargetPassConfig`` hooks, e.g. includes anything added via ``TargetPassConfig`` hooks, e.g.
``TargetPassConfig::addCodeGenPrepare()``. As mentioned before, passes added ``TargetPassConfig::addCodeGenPrepare()``.
in ``TargetMachine::adjustPassManager()`` are part of the optimization
pipeline, and should have a corresponding line in The ``TargetMachine::adjustPassManager()`` function that was used to extend a
``TargetMachine::registerPassBuilderCallbacks()``. legacy PM with passes on a per target basis has been removed. It was mainly
used from opt, but since support for using the default pipelines has been
removed in opt the function isn't needed any longer. In the new PM such
adjustments are done by using ``TargetMachine::registerPassBuilderCallbacks()``.
Currently there are efforts to make the codegen pipeline work with the new Currently there are efforts to make the codegen pipeline work with the new
PM. PM.

View File

@ -24,6 +24,7 @@
// As of this writing, we don't separate IPO and the Post-IPO SOPT. They // As of this writing, we don't separate IPO and the Post-IPO SOPT. They
// are intermingled together, and are driven by a single pass manager (see // are intermingled together, and are driven by a single pass manager (see
// PassManagerBuilder::populateLTOPassManager()). // PassManagerBuilder::populateLTOPassManager()).
// FIXME: populateLTOPassManager no longer exists.
// //
// The "LTOCodeGenerator" is the driver for the IPO and Post-IPO stages. // The "LTOCodeGenerator" is the driver for the IPO and Post-IPO stages.
// The "CodeGenerator" here is bit confusing. Don't confuse the "CodeGenerator" // The "CodeGenerator" here is bit confusing. Don't confuse the "CodeGenerator"

View File

@ -46,7 +46,6 @@ class MCSubtargetInfo;
class MCSymbol; class MCSymbol;
class raw_pwrite_stream; class raw_pwrite_stream;
class PassBuilder; class PassBuilder;
class PassManagerBuilder;
struct PerFunctionMIParsingState; struct PerFunctionMIParsingState;
class SMDiagnostic; class SMDiagnostic;
class SMRange; class SMRange;
@ -347,12 +346,7 @@ public:
/// corresponding to \p F. /// corresponding to \p F.
virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const; virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const;
/// Allow the target to modify the pass manager, e.g. by calling /// Allow the target to modify the pass pipeline.
/// PassManagerBuilder::addExtension.
virtual void adjustPassManager(PassManagerBuilder &) {}
/// Allow the target to modify the pass pipeline with New Pass Manager
/// (similar to adjustPassManager for Legacy Pass manager).
virtual void registerPassBuilderCallbacks(PassBuilder &) {} virtual void registerPassBuilderCallbacks(PassBuilder &) {}
/// Allow the target to register alias analyses with the AAManager for use /// Allow the target to register alias analyses with the AAManager for use

View File

@ -49,10 +49,8 @@
#include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/VCSRevision.h" #include "llvm/Support/VCSRevision.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/IPO/WholeProgramDevirt.h" #include "llvm/Transforms/IPO/WholeProgramDevirt.h"
#include "llvm/Transforms/Utils/FunctionImportUtils.h" #include "llvm/Transforms/Utils/FunctionImportUtils.h"
#include "llvm/Transforms/Utils/SplitModule.h" #include "llvm/Transforms/Utils/SplitModule.h"

View File

@ -36,7 +36,6 @@
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/IR/PassTimingInfo.h" #include "llvm/IR/PassTimingInfo.h"
#include "llvm/IR/Verifier.h" #include "llvm/IR/Verifier.h"
#include "llvm/InitializePasses.h"
#include "llvm/LTO/LTO.h" #include "llvm/LTO/LTO.h"
#include "llvm/LTO/LTOBackend.h" #include "llvm/LTO/LTOBackend.h"
#include "llvm/LTO/legacy/LTOModule.h" #include "llvm/LTO/legacy/LTOModule.h"
@ -60,7 +59,6 @@
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/Internalize.h" #include "llvm/Transforms/IPO/Internalize.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/IPO/WholeProgramDevirt.h" #include "llvm/Transforms/IPO/WholeProgramDevirt.h"
#include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/ObjCARC.h"
#include "llvm/Transforms/Utils/ModuleUtils.h" #include "llvm/Transforms/Utils/ModuleUtils.h"

View File

@ -51,7 +51,6 @@
#include "llvm/Transforms/IPO/AlwaysInliner.h" #include "llvm/Transforms/IPO/AlwaysInliner.h"
#include "llvm/Transforms/IPO/GlobalDCE.h" #include "llvm/Transforms/IPO/GlobalDCE.h"
#include "llvm/Transforms/IPO/Internalize.h" #include "llvm/Transforms/IPO/Internalize.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/InferAddressSpaces.h" #include "llvm/Transforms/Scalar/InferAddressSpaces.h"
@ -576,80 +575,6 @@ static bool mustPreserveGV(const GlobalValue &GV) {
return !GV.use_empty(); return !GV.use_empty();
} }
void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
Builder.DivergentTarget = true;
bool EnableOpt = getOptLevel() > CodeGenOpt::None;
bool Internalize = InternalizeSymbols;
bool EarlyInline = EarlyInlineAll && EnableOpt && !EnableFunctionCalls;
bool AMDGPUAA = EnableAMDGPUAliasAnalysis && EnableOpt;
bool LibCallSimplify = EnableLibCallSimplify && EnableOpt;
bool PromoteKernelArguments =
EnablePromoteKernelArguments && getOptLevel() > CodeGenOpt::Less;
if (EnableFunctionCalls) {
delete Builder.Inliner;
Builder.Inliner = createFunctionInliningPass();
}
Builder.addExtension(
PassManagerBuilder::EP_ModuleOptimizerEarly,
[Internalize, EarlyInline, AMDGPUAA, this](const PassManagerBuilder &,
legacy::PassManagerBase &PM) {
if (AMDGPUAA) {
PM.add(createAMDGPUAAWrapperPass());
PM.add(createAMDGPUExternalAAWrapperPass());
}
PM.add(createAMDGPUUnifyMetadataPass());
PM.add(createAMDGPUPrintfRuntimeBinding());
if (Internalize)
PM.add(createInternalizePass(mustPreserveGV));
PM.add(createAMDGPUPropagateAttributesLatePass(this));
if (Internalize)
PM.add(createGlobalDCEPass());
if (EarlyInline)
PM.add(createAMDGPUAlwaysInlinePass(false));
});
Builder.addExtension(
PassManagerBuilder::EP_EarlyAsPossible,
[AMDGPUAA, LibCallSimplify, this](const PassManagerBuilder &,
legacy::PassManagerBase &PM) {
if (AMDGPUAA) {
PM.add(createAMDGPUAAWrapperPass());
PM.add(createAMDGPUExternalAAWrapperPass());
}
PM.add(llvm::createAMDGPUPropagateAttributesEarlyPass(this));
PM.add(llvm::createAMDGPUUseNativeCallsPass());
if (LibCallSimplify)
PM.add(llvm::createAMDGPUSimplifyLibCallsPass(this));
});
Builder.addExtension(
PassManagerBuilder::EP_CGSCCOptimizerLate,
[EnableOpt, PromoteKernelArguments](const PassManagerBuilder &,
legacy::PassManagerBase &PM) {
// Add promote kernel arguments pass to the opt pipeline right before
// infer address spaces which is needed to do actual address space
// rewriting.
if (PromoteKernelArguments)
PM.add(createAMDGPUPromoteKernelArgumentsPass());
// Add infer address spaces pass to the opt pipeline after inlining
// but before SROA to increase SROA opportunities.
PM.add(createInferAddressSpacesPass());
// This should run after inlining to have any chance of doing anything,
// and before other cleanup optimizations.
PM.add(createAMDGPULowerKernelAttributesPass());
// Promote alloca to vector before SROA and loop unroll. If we manage
// to eliminate allocas before unroll we may choose to unroll less.
if (EnableOpt)
PM.add(createAMDGPUPromoteAllocaToVector());
});
}
void AMDGPUTargetMachine::registerDefaultAliasAnalyses(AAManager &AAM) { void AMDGPUTargetMachine::registerDefaultAliasAnalyses(AAManager &AAM) {
AAM.registerFunctionAnalysis<AMDGPUAA>(); AAM.registerFunctionAnalysis<AMDGPUAA>();
} }

View File

@ -50,8 +50,6 @@ public:
return TLOF.get(); return TLOF.get();
} }
void adjustPassManager(PassManagerBuilder &) override;
void registerPassBuilderCallbacks(PassBuilder &PB) override; void registerPassBuilderCallbacks(PassBuilder &PB) override;
void registerDefaultAliasAnalyses(AAManager &) override; void registerDefaultAliasAnalyses(AAManager &) override;

View File

@ -24,7 +24,6 @@
#include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/SimplifyCFG.h" #include "llvm/Transforms/Scalar/SimplifyCFG.h"
#include "llvm/Transforms/Utils/SimplifyCFGOptions.h" #include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
@ -102,28 +101,6 @@ TargetPassConfig *BPFTargetMachine::createPassConfig(PassManagerBase &PM) {
return new BPFPassConfig(*this, PM); return new BPFPassConfig(*this, PM);
} }
void BPFTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
Builder.addExtension(
PassManagerBuilder::EP_EarlyAsPossible,
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
PM.add(createBPFAbstractMemberAccess(this));
PM.add(createBPFPreserveDIType());
PM.add(createBPFIRPeephole());
});
Builder.addExtension(
PassManagerBuilder::EP_Peephole,
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
PM.add(createCFGSimplificationPass(
SimplifyCFGOptions().hoistCommonInsts(true)));
});
Builder.addExtension(
PassManagerBuilder::EP_ModuleOptimizerEarly,
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
PM.add(createBPFAdjustOpt());
});
}
void BPFTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { void BPFTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
PB.registerPipelineStartEPCallback( PB.registerPipelineStartEPCallback(
[=](ModulePassManager &MPM, OptimizationLevel) { [=](ModulePassManager &MPM, OptimizationLevel) {

View File

@ -40,7 +40,6 @@ public:
return TLOF.get(); return TLOF.get();
} }
void adjustPassManager(PassManagerBuilder &) override;
void registerPassBuilderCallbacks(PassBuilder &PB) override; void registerPassBuilderCallbacks(PassBuilder &PB) override;
}; };
} }

View File

@ -27,7 +27,6 @@
#include "llvm/MC/TargetRegistry.h" #include "llvm/MC/TargetRegistry.h"
#include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar.h"
using namespace llvm; using namespace llvm;
@ -273,19 +272,6 @@ HexagonTargetMachine::getSubtargetImpl(const Function &F) const {
return I.get(); return I.get();
} }
void HexagonTargetMachine::adjustPassManager(PassManagerBuilder &PMB) {
PMB.addExtension(
PassManagerBuilder::EP_LateLoopOptimizations,
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
PM.add(createHexagonLoopIdiomPass());
});
PMB.addExtension(
PassManagerBuilder::EP_LoopOptimizerEnd,
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
PM.add(createHexagonVectorLoopCarriedReuseLegacyPass());
});
}
void HexagonTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { void HexagonTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
PB.registerLateLoopOptimizationsEPCallback( PB.registerLateLoopOptimizationsEPCallback(
[=](LoopPassManager &LPM, OptimizationLevel Level) { [=](LoopPassManager &LPM, OptimizationLevel Level) {

View File

@ -36,7 +36,6 @@ public:
static unsigned getModuleMatchQuality(const Module &M); static unsigned getModuleMatchQuality(const Module &M);
void adjustPassManager(PassManagerBuilder &PMB) override;
void registerPassBuilderCallbacks(PassBuilder &PB) override; void registerPassBuilderCallbacks(PassBuilder &PB) override;
TargetPassConfig *createPassConfig(PassManagerBase &PM) override; TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
TargetTransformInfo getTargetTransformInfo(const Function &F) const override; TargetTransformInfo getTargetTransformInfo(const Function &F) const override;

View File

@ -31,7 +31,6 @@
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Vectorize.h" #include "llvm/Transforms/Vectorize.h"
@ -201,15 +200,6 @@ TargetPassConfig *NVPTXTargetMachine::createPassConfig(PassManagerBase &PM) {
return new NVPTXPassConfig(*this, PM); return new NVPTXPassConfig(*this, PM);
} }
void NVPTXTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
Builder.addExtension(
PassManagerBuilder::EP_EarlyAsPossible,
[&](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
PM.add(createNVVMReflectPass(Subtarget.getSmVersion()));
PM.add(createNVVMIntrRangePass(Subtarget.getSmVersion()));
});
}
void NVPTXTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { void NVPTXTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
PB.registerPipelineParsingCallback( PB.registerPipelineParsingCallback(
[](StringRef PassName, FunctionPassManager &PM, [](StringRef PassName, FunctionPassManager &PM,

View File

@ -62,7 +62,6 @@ public:
return TLOF.get(); return TLOF.get();
} }
void adjustPassManager(PassManagerBuilder &) override;
void registerPassBuilderCallbacks(PassBuilder &PB) override; void registerPassBuilderCallbacks(PassBuilder &PB) override;
TargetTransformInfo getTargetTransformInfo(const Function &F) const override; TargetTransformInfo getTargetTransformInfo(const Function &F) const override;