diff --git a/llvm/docs/NVPTXUsage.rst b/llvm/docs/NVPTXUsage.rst --- a/llvm/docs/NVPTXUsage.rst +++ b/llvm/docs/NVPTXUsage.rst @@ -326,17 +326,6 @@ Therefore, it is recommended that ``NVVMReflect`` is executed early in the optimization pipeline before dead-code elimination. -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 -manager: - -.. code-block:: c++ - - std::unique_ptr TM = ...; - PassManagerBuilder PMBuilder(...); - if (TM) - TM->adjustPassManager(PMBuilder); - Reflection Parameters --------------------- diff --git a/llvm/docs/NewPassManager.rst b/llvm/docs/NewPassManager.rst --- a/llvm/docs/NewPassManager.rst +++ b/llvm/docs/NewPassManager.rst @@ -171,8 +171,7 @@ If a ``PassBuilder`` has a corresponding ``TargetMachine`` for a backend, it will call ``TargetMachine::registerPassBuilderCallbacks()`` to allow the -backend to inject passes into the pipeline. This is equivalent to the legacy -PM's ``TargetMachine::adjustPassManager()``. +backend to inject passes into the pipeline. Clang's ``BackendUtil.cpp`` shows examples of a frontend adding (mostly sanitizer) passes to various parts of the pipeline. diff --git a/llvm/docs/WritingAnLLVMPass.rst b/llvm/docs/WritingAnLLVMPass.rst --- a/llvm/docs/WritingAnLLVMPass.rst +++ b/llvm/docs/WritingAnLLVMPass.rst @@ -185,18 +185,6 @@ an analysis pass, for example dominator tree pass, then ``true`` is supplied as the fourth argument. -If we want to register the pass as a step of an existing pipeline, some extension -points are provided, e.g. ``PassManagerBuilder::EP_EarlyAsPossible`` to apply our -pass before any optimization, or ``PassManagerBuilder::EP_FullLinkTimeOptimizationLast`` -to apply it after Link Time Optimizations. - -.. code-block:: c++ - - static llvm::RegisterStandardPasses Y( - llvm::PassManagerBuilder::EP_EarlyAsPossible, - [](const llvm::PassManagerBuilder &Builder, - llvm::legacy::PassManagerBase &PM) { PM.add(new Hello()); }); - As a whole, the ``.cpp`` file looks like: .. code-block:: c++ @@ -228,11 +216,6 @@ false /* Only looks at CFG */, false /* Analysis Pass */); - static RegisterStandardPasses Y( - PassManagerBuilder::EP_EarlyAsPossible, - [](const PassManagerBuilder &Builder, - legacy::PassManagerBase &PM) { PM.add(new Hello()); }); - Now that it's all together, compile the file with a simple "``gmake``" command from the top level of your build directory and you should get a new file "``lib/LLVMHello.so``". Note that everything in this file is diff --git a/llvm/examples/Bye/Bye.cpp b/llvm/examples/Bye/Bye.cpp --- a/llvm/examples/Bye/Bye.cpp +++ b/llvm/examples/Bye/Bye.cpp @@ -44,17 +44,6 @@ false /* Only looks at CFG */, false /* Analysis Pass */); -/* Legacy PM Registration */ -static llvm::RegisterStandardPasses RegisterBye( - llvm::PassManagerBuilder::EP_VectorizerStart, - [](const llvm::PassManagerBuilder &Builder, - llvm::legacy::PassManagerBase &PM) { PM.add(new LegacyBye()); }); - -static llvm::RegisterStandardPasses RegisterByeLTO( - llvm::PassManagerBuilder::EP_ModuleOptimizerEarly, - [](const llvm::PassManagerBuilder &Builder, - llvm::legacy::PassManagerBase &PM) { PM.add(new LegacyBye()); }); - /* New PM Registration */ llvm::PassPluginLibraryInfo getByePluginInfo() { return {LLVM_PLUGIN_API_VERSION, "Bye", LLVM_VERSION_STRING, diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -347,12 +347,7 @@ /// corresponding to \p F. virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const; - /// Allow the target to modify the pass manager, e.g. by calling - /// 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). + /// Allow the target to modify the pass pipeline. virtual void registerPassBuilderCallbacks(PassBuilder &) {} /// Allow the target to register alias analyses with the AAManager for use diff --git a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h --- a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -63,68 +63,6 @@ ExtensionFn; typedef int GlobalExtensionID; - enum ExtensionPointTy { - /// EP_EarlyAsPossible - This extension point allows adding passes before - /// any other transformations, allowing them to see the code as it is coming - /// out of the frontend. - EP_EarlyAsPossible, - - /// EP_ModuleOptimizerEarly - This extension point allows adding passes - /// just before the main module-level optimization passes. - EP_ModuleOptimizerEarly, - - /// EP_LoopOptimizerEnd - This extension point allows adding loop passes to - /// the end of the loop optimizer. - EP_LoopOptimizerEnd, - - /// EP_ScalarOptimizerLate - This extension point allows adding optimization - /// passes after most of the main optimizations, but before the last - /// cleanup-ish optimizations. - EP_ScalarOptimizerLate, - - /// EP_OptimizerLast -- This extension point allows adding passes that - /// run after everything else. - EP_OptimizerLast, - - /// EP_VectorizerStart - This extension point allows adding optimization - /// passes before the vectorizer and other highly target specific - /// optimization passes are executed. - EP_VectorizerStart, - - /// EP_EnabledOnOptLevel0 - This extension point allows adding passes that - /// should not be disabled by O0 optimization level. The passes will be - /// inserted after the inlining pass. - EP_EnabledOnOptLevel0, - - /// EP_Peephole - This extension point allows adding passes that perform - /// peephole optimizations similar to the instruction combiner. These passes - /// will be inserted after each instance of the instruction combiner pass. - EP_Peephole, - - /// EP_LateLoopOptimizations - This extension point allows adding late loop - /// canonicalization and simplification passes. This is the last point in - /// the loop optimization pipeline before loop deletion. Each pass added - /// here must be an instance of LoopPass. - /// This is the place to add passes that can remove loops, such as target- - /// specific loop idiom recognition. - EP_LateLoopOptimizations, - - /// EP_CGSCCOptimizerLate - This extension point allows adding CallGraphSCC - /// passes at the end of the main CallGraphSCC passes and before any - /// function simplification passes run by CGPassManager. - EP_CGSCCOptimizerLate, - - /// EP_FullLinkTimeOptimizationEarly - This extensions point allow adding - /// passes that - /// run at Link Time, before Full Link Time Optimization. - EP_FullLinkTimeOptimizationEarly, - - /// EP_FullLinkTimeOptimizationLast - This extensions point allow adding - /// passes that - /// run at Link Time, after Full Link Time Optimization. - EP_FullLinkTimeOptimizationLast, - }; - /// The Optimization Level - Specify the basic optimization level. /// 0 = -O0, 1 = -O1, 2 = -O2, 3 = -O3 unsigned OptLevel; @@ -168,32 +106,11 @@ unsigned LicmMssaOptCap; unsigned LicmMssaNoAccForPromotionCap; -private: - /// ExtensionList - This is list of all of the extensions that are registered. - std::vector> Extensions; - public: PassManagerBuilder(); ~PassManagerBuilder(); - /// Adds an extension that will be used by all PassManagerBuilder instances. - /// This is intended to be used by plugins, to register a set of - /// optimisations to run automatically. - /// - /// \returns A global extension identifier that can be used to remove the - /// extension. - static GlobalExtensionID addGlobalExtension(ExtensionPointTy Ty, - ExtensionFn Fn); - /// Removes an extension that was previously added using addGlobalExtension. - /// This is also intended to be used by plugins, to remove any extension that - /// was previously registered before being unloaded. - /// - /// \param ExtensionID Identifier of the extension to be removed. - static void removeGlobalExtension(GlobalExtensionID ExtensionID); - void addExtension(ExtensionPointTy Ty, ExtensionFn Fn); private: - void addExtensionsToPM(ExtensionPointTy ETy, - legacy::PassManagerBase &PM) const; void addInitialAliasAnalysisPasses(legacy::PassManagerBase &PM) const; void addFunctionSimplificationPasses(legacy::PassManagerBase &MPM); void addVectorPasses(legacy::PassManagerBase &PM, bool IsFullLTO); @@ -208,27 +125,6 @@ void populateModulePassManager(legacy::PassManagerBase &MPM); }; -/// Registers a function for adding a standard set of passes. This should be -/// used by optimizer plugins to allow all front ends to transparently use -/// them. Create a static instance of this class in your plugin, providing a -/// private function that the PassManagerBuilder can use to add your passes. -class RegisterStandardPasses { - PassManagerBuilder::GlobalExtensionID ExtensionID; - -public: - RegisterStandardPasses(PassManagerBuilder::ExtensionPointTy Ty, - PassManagerBuilder::ExtensionFn Fn) { - ExtensionID = PassManagerBuilder::addGlobalExtension(Ty, std::move(Fn)); - } - - ~RegisterStandardPasses() { - // If the collection holding the global extensions is destroyed after the - // plugin is unloaded, the extension has to be removed here. Indeed, the - // destructor of the ExtensionFn may reference code in the plugin. - PassManagerBuilder::removeGlobalExtension(ExtensionID); - } -}; - inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) { return reinterpret_cast(P); } diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h @@ -50,8 +50,6 @@ return TLOF.get(); } - void adjustPassManager(PassManagerBuilder &) override; - void registerPassBuilderCallbacks(PassBuilder &PB) override; void registerDefaultAliasAnalyses(AAManager &) override; diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -576,80 +576,6 @@ 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) { AAM.registerFunctionAnalysis(); } diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.h b/llvm/lib/Target/BPF/BPFTargetMachine.h --- a/llvm/lib/Target/BPF/BPFTargetMachine.h +++ b/llvm/lib/Target/BPF/BPFTargetMachine.h @@ -40,7 +40,6 @@ return TLOF.get(); } - void adjustPassManager(PassManagerBuilder &) override; void registerPassBuilderCallbacks(PassBuilder &PB) override; }; } diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp --- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp +++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp @@ -102,28 +102,6 @@ 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) { PB.registerPipelineStartEPCallback( [=](ModulePassManager &MPM, OptimizationLevel) { diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h --- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h +++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h @@ -36,7 +36,6 @@ static unsigned getModuleMatchQuality(const Module &M); - void adjustPassManager(PassManagerBuilder &PMB) override; void registerPassBuilderCallbacks(PassBuilder &PB) override; TargetPassConfig *createPassConfig(PassManagerBase &PM) override; TargetTransformInfo getTargetTransformInfo(const Function &F) const override; diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp --- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp @@ -273,19 +273,6 @@ 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) { PB.registerLateLoopOptimizationsEPCallback( [=](LoopPassManager &LPM, OptimizationLevel Level) { diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h @@ -62,7 +62,6 @@ return TLOF.get(); } - void adjustPassManager(PassManagerBuilder &) override; void registerPassBuilderCallbacks(PassBuilder &PB) override; TargetTransformInfo getTargetTransformInfo(const Function &F) const override; diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -201,15 +201,6 @@ 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) { PB.registerPipelineParsingCallback( [](StringRef PassName, FunctionPassManager &PM, diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -193,64 +193,6 @@ delete Inliner; } -/// Set of global extensions, automatically added as part of the standard set. -static ManagedStatic< - SmallVector, - 8>> - GlobalExtensions; -static PassManagerBuilder::GlobalExtensionID GlobalExtensionsCounter; - -/// Check if GlobalExtensions is constructed and not empty. -/// Since GlobalExtensions is a managed static, calling 'empty()' will trigger -/// the construction of the object. -static bool GlobalExtensionsNotEmpty() { - return GlobalExtensions.isConstructed() && !GlobalExtensions->empty(); -} - -PassManagerBuilder::GlobalExtensionID -PassManagerBuilder::addGlobalExtension(PassManagerBuilder::ExtensionPointTy Ty, - PassManagerBuilder::ExtensionFn Fn) { - auto ExtensionID = GlobalExtensionsCounter++; - GlobalExtensions->push_back(std::make_tuple(Ty, std::move(Fn), ExtensionID)); - return ExtensionID; -} - -void PassManagerBuilder::removeGlobalExtension( - PassManagerBuilder::GlobalExtensionID ExtensionID) { - // RegisterStandardPasses may try to call this function after GlobalExtensions - // has already been destroyed; doing so should not generate an error. - if (!GlobalExtensions.isConstructed()) - return; - - auto GlobalExtension = - llvm::find_if(*GlobalExtensions, [ExtensionID](const auto &elem) { - return std::get<2>(elem) == ExtensionID; - }); - assert(GlobalExtension != GlobalExtensions->end() && - "The extension ID to be removed should always be valid."); - - GlobalExtensions->erase(GlobalExtension); -} - -void PassManagerBuilder::addExtension(ExtensionPointTy Ty, ExtensionFn Fn) { - Extensions.push_back(std::make_pair(Ty, std::move(Fn))); -} - -void PassManagerBuilder::addExtensionsToPM(ExtensionPointTy ETy, - legacy::PassManagerBase &PM) const { - if (GlobalExtensionsNotEmpty()) { - for (auto &Ext : *GlobalExtensions) { - if (std::get<0>(Ext) == ETy) - std::get<1>(Ext)(*this, PM); - } - } - for (const auto &[PT, Fn] : Extensions) - if (PT == ETy) - Fn(*this, PM); -} - void PassManagerBuilder::addInitialAliasAnalysisPasses( legacy::PassManagerBase &PM) const { switch (UseCFLAA) { @@ -277,8 +219,6 @@ void PassManagerBuilder::populateFunctionPassManager( legacy::FunctionPassManager &FPM) { - addExtensionsToPM(EP_EarlyAsPossible, FPM); - // Add LibraryInfo if we have some. if (LibraryInfo) FPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo)); @@ -341,7 +281,6 @@ MPM.add(createInstructionCombiningPass()); if (SizeLevel == 0 && !DisableLibCallsShrinkWrap) MPM.add(createLibCallsShrinkWrapPass()); - addExtensionsToPM(EP_Peephole, MPM); // TODO: Investigate the cost/benefit of tail call elimination on debugging. if (OptLevel > 1) @@ -391,7 +330,6 @@ } MPM.add(createLoopIdiomPass()); // Recognize idioms like memset. MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars - addExtensionsToPM(EP_LateLoopOptimizations, MPM); MPM.add(createLoopDeletionPass()); // Delete dead loops if (EnableLoopInterchange) @@ -400,7 +338,6 @@ // Unroll small loops and perform peeling. MPM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops, ForgetAllSCEVInLoopUnroll)); - addExtensionsToPM(EP_LoopOptimizerEnd, MPM); // This ends the loop pass pipelines. // Break up allocas that may now be splittable after loop unrolling. @@ -424,7 +361,6 @@ // Run instcombine after redundancy elimination to exploit opportunities // opened up by them. MPM.add(createInstructionCombiningPass()); - addExtensionsToPM(EP_Peephole, MPM); if (OptLevel > 1) { if (EnableDFAJumpThreading && SizeLevel == 0) MPM.add(createDFAJumpThreadingPass()); @@ -442,8 +378,6 @@ /*AllowSpeculation=*/true)); } - addExtensionsToPM(EP_ScalarOptimizerLate, MPM); - if (RerollLoops) MPM.add(createLoopRerollPass()); @@ -452,7 +386,6 @@ SimplifyCFGOptions().hoistCommonInsts(true).sinkCommonInsts(true))); // Clean up after everything. MPM.add(createInstructionCombiningPass()); - addExtensionsToPM(EP_Peephole, MPM); } /// FIXME: Should LTO cause any differences to this set of passes? @@ -536,7 +469,6 @@ PM.add(createVectorCombinePass()); if (!IsFullLTO) { - addExtensionsToPM(EP_Peephole, PM); PM.add(createInstructionCombiningPass()); if (EnableUnrollAndJam && !DisableUnrollLoops) { @@ -595,10 +527,6 @@ // builds. The function merging pass is if (MergeFunctions) MPM.add(createMergeFunctionsPass()); - else if (GlobalExtensionsNotEmpty() || !Extensions.empty()) - MPM.add(createBarrierNoopPass()); - - addExtensionsToPM(EP_EnabledOnOptLevel0, MPM); MPM.add(createAnnotationRemarksLegacyPass()); return; @@ -617,8 +545,6 @@ if (AttributorRun & AttributorRunOption::MODULE) MPM.add(createAttributorLegacyPass()); - addExtensionsToPM(EP_ModuleOptimizerEarly, MPM); - if (OptLevel > 2) MPM.add(createCallSiteSplittingPass()); @@ -636,7 +562,6 @@ MPM.add(createDeadArgEliminationPass()); // Dead argument elimination MPM.add(createInstructionCombiningPass()); // Clean up after IPCP & DAE - addExtensionsToPM(EP_Peephole, MPM); MPM.add( createCFGSimplificationPass(SimplifyCFGOptions().convertSwitchRangeToICmp( true))); // Clean up after IPCP & DAE @@ -665,7 +590,6 @@ MPM.add(createPostOrderFunctionAttrsLegacyPass()); - addExtensionsToPM(EP_CGSCCOptimizerLate, MPM); addFunctionSimplificationPasses(MPM); // FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC @@ -740,8 +664,6 @@ MPM.add(createEarlyCSEPass(false)); } - addExtensionsToPM(EP_VectorizerStart, MPM); - // Re-rotate loops in all our loop nests. These may have fallout out of // rotated form due to GVN or other transformations, and the vectorizer relies // on the rotated form. Disable header duplication at -Oz. @@ -794,8 +716,6 @@ MPM.add(createCFGSimplificationPass( SimplifyCFGOptions().convertSwitchRangeToICmp(true))); - addExtensionsToPM(EP_OptimizerLast, MPM); - MPM.add(createAnnotationRemarksLegacyPass()); } diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -349,9 +349,6 @@ Builder.SLPVectorize = OptLevel > 1 && SizeLevel < 2; - if (TM) - TM->adjustPassManager(Builder); - Builder.populateFunctionPassManager(FPM); Builder.populateModulePassManager(MPM); }