[clang] [llvm] [polly] [PassManager] Make passes inherit from RequiredPassInfoMixin/OptionalPassInfoMixin (PR #192120)

Arthur Eubanks via cfe-commits cfe-commits at lists.llvm.org
Mon May 4 13:46:29 PDT 2026


https://github.com/aeubanks updated https://github.com/llvm/llvm-project/pull/192120

>From a9dabee7b05ecccea5aa69e481c882149073cee1 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Tue, 14 Apr 2026 18:30:33 +0000
Subject: [PATCH 1/4] [PassManager] Make passes inherit from
 MandatoryPassInfoMixin/OptionalPassInfoMixin

It's very easy to forget to add `isRequired() { return true; }` for passes that must be run on all IR, rather than e.g. being skipped on optnone functions.

This PR adds MandatoryPassInfoMixin/OptionalPassInfoMixin which have `isRequired()`, and the long term vision is there to be no default `isRequired()` on PassInfoMixin.

However, for out-of-tree migration purposes, we leave a `isRequired() { return false; }` for now in PassInfoMixin.
---
 llvm/docs/WritingAnLLVMNewPMPass.rst          | 19 ++--
 llvm/examples/Bye/Bye.cpp                     |  2 +-
 llvm/examples/IRTransforms/SimplifyCFG.cpp    |  2 +-
 .../llvm/Analysis/AliasAnalysisEvaluator.h    |  2 +-
 llvm/include/llvm/Analysis/AliasSetTracker.h  |  4 +-
 llvm/include/llvm/Analysis/AssumptionCache.h  |  5 +-
 .../llvm/Analysis/BlockFrequencyInfo.h        |  4 +-
 .../llvm/Analysis/BranchProbabilityInfo.h     |  4 +-
 llvm/include/llvm/Analysis/CFGPrinter.h       | 12 +--
 llvm/include/llvm/Analysis/CFGSCCPrinter.h    |  3 +-
 llvm/include/llvm/Analysis/CGSCCPassManager.h | 17 ++--
 llvm/include/llvm/Analysis/CallGraph.h        |  9 +-
 llvm/include/llvm/Analysis/CallPrinter.h      |  7 +-
 llvm/include/llvm/Analysis/CostModel.h        |  5 +-
 llvm/include/llvm/Analysis/CtxProfAnalysis.h  |  5 +-
 llvm/include/llvm/Analysis/CycleAnalysis.h    |  8 +-
 llvm/include/llvm/Analysis/DDG.h              |  4 +-
 llvm/include/llvm/Analysis/DDGPrinter.h       |  3 +-
 .../llvm/Analysis/DOTGraphTraitsPass.h        |  8 +-
 .../llvm/Analysis/DXILMetadataAnalysis.h      |  4 +-
 llvm/include/llvm/Analysis/DXILResource.h     |  5 +-
 llvm/include/llvm/Analysis/Delinearization.h  |  3 +-
 llvm/include/llvm/Analysis/DemandedBits.h     |  5 +-
 .../llvm/Analysis/DependenceAnalysis.h        |  4 +-
 .../include/llvm/Analysis/DominanceFrontier.h |  4 +-
 .../Analysis/FunctionPropertiesAnalysis.h     |  6 +-
 llvm/include/llvm/Analysis/GlobalsModRef.h    |  2 +-
 llvm/include/llvm/Analysis/HashRecognize.h    |  2 +-
 llvm/include/llvm/Analysis/IR2Vec.h           |  7 +-
 .../llvm/Analysis/IRSimilarityIdentifier.h    |  3 +-
 llvm/include/llvm/Analysis/InlineAdvisor.h    |  3 +-
 llvm/include/llvm/Analysis/InlineCost.h       |  3 +-
 llvm/include/llvm/Analysis/InstCount.h        |  2 +-
 llvm/include/llvm/Analysis/KernelInfo.h       |  4 +-
 llvm/include/llvm/Analysis/LazyCallGraph.h    |  8 +-
 llvm/include/llvm/Analysis/LazyValueInfo.h    |  4 +-
 llvm/include/llvm/Analysis/Lint.h             |  2 +-
 .../include/llvm/Analysis/LoopCacheAnalysis.h |  5 +-
 llvm/include/llvm/Analysis/LoopInfo.h         |  6 +-
 llvm/include/llvm/Analysis/LoopNestAnalysis.h |  4 +-
 llvm/include/llvm/Analysis/MemDerefPrinter.h  |  3 +-
 llvm/include/llvm/Analysis/MemorySSA.h        | 12 +--
 .../llvm/Analysis/ModuleDebugInfoPrinter.h    |  3 +-
 llvm/include/llvm/Analysis/MustExecute.h      |  7 +-
 llvm/include/llvm/Analysis/PhiValues.h        |  4 +-
 llvm/include/llvm/Analysis/PostDominators.h   |  4 +-
 .../llvm/Analysis/ProfileSummaryInfo.h        |  3 +-
 llvm/include/llvm/Analysis/RegionInfo.h       |  8 +-
 llvm/include/llvm/Analysis/ScalarEvolution.h  |  7 +-
 .../llvm/Analysis/ScalarEvolutionDivision.h   |  3 +-
 llvm/include/llvm/Analysis/StackLifetime.h    |  4 +-
 .../llvm/Analysis/StackSafetyAnalysis.h       |  7 +-
 llvm/include/llvm/Analysis/StructuralHash.h   |  4 +-
 .../llvm/Analysis/UniformityAnalysis.h        |  4 +-
 llvm/include/llvm/Bitcode/BitcodeWriterPass.h |  5 +-
 .../llvm/CodeGen/AssignmentTrackingAnalysis.h |  2 +-
 llvm/include/llvm/CodeGen/AtomicExpand.h      |  2 +-
 llvm/include/llvm/CodeGen/BranchFoldingPass.h |  2 +-
 llvm/include/llvm/CodeGen/BranchRelaxation.h  |  4 +-
 llvm/include/llvm/CodeGen/CodeGenPrepare.h    |  2 +-
 .../llvm/CodeGen/ComplexDeinterleavingPass.h  |  2 +-
 .../llvm/CodeGen/DeadMachineInstructionElim.h |  2 +-
 llvm/include/llvm/CodeGen/DetectDeadLanes.h   |  3 +-
 llvm/include/llvm/CodeGen/DwarfEHPrepare.h    |  2 +-
 llvm/include/llvm/CodeGen/EarlyIfConversion.h |  3 +-
 llvm/include/llvm/CodeGen/ExpandIRInsts.h     |  4 +-
 .../llvm/CodeGen/ExpandPostRAPseudos.h        |  4 +-
 llvm/include/llvm/CodeGen/ExpandReductions.h  |  2 +-
 llvm/include/llvm/CodeGen/FEntryInserter.h    |  3 +-
 llvm/include/llvm/CodeGen/FinalizeISel.h      |  3 +-
 .../llvm/CodeGen/FixupStatepointCallerSaved.h |  2 +-
 .../include/llvm/CodeGen/GCEmptyBasicBlocks.h |  3 +-
 llvm/include/llvm/CodeGen/GCMetadata.h        |  2 +-
 .../CodeGen/GlobalISel/GISelValueTracking.h   |  2 +-
 llvm/include/llvm/CodeGen/GlobalMerge.h       |  2 +-
 .../llvm/CodeGen/GlobalMergeFunctions.h       |  2 +-
 llvm/include/llvm/CodeGen/HardwareLoops.h     |  2 +-
 llvm/include/llvm/CodeGen/IndirectBrExpand.h  |  3 +-
 llvm/include/llvm/CodeGen/InitUndef.h         |  3 +-
 llvm/include/llvm/CodeGen/InlineAsmPrepare.h  |  3 +-
 llvm/include/llvm/CodeGen/InterleavedAccess.h |  3 +-
 .../llvm/CodeGen/InterleavedLoadCombine.h     |  2 +-
 llvm/include/llvm/CodeGen/JMCInstrumenter.h   |  2 +-
 .../llvm/CodeGen/LiveDebugValuesPass.h        |  2 +-
 .../include/llvm/CodeGen/LiveDebugVariables.h |  2 +-
 llvm/include/llvm/CodeGen/LiveIntervals.h     |  3 +-
 llvm/include/llvm/CodeGen/LiveStacks.h        |  3 +-
 llvm/include/llvm/CodeGen/LiveVariables.h     |  3 +-
 .../llvm/CodeGen/LocalStackSlotAllocation.h   |  3 +-
 llvm/include/llvm/CodeGen/LowerEmuTLS.h       |  2 +-
 llvm/include/llvm/CodeGen/MIRPrinter.h        |  6 +-
 .../llvm/CodeGen/MachineBlockFrequencyInfo.h  |  4 +-
 .../llvm/CodeGen/MachineBlockPlacement.h      |  6 +-
 .../CodeGen/MachineBranchProbabilityInfo.h    |  2 +-
 llvm/include/llvm/CodeGen/MachineCSE.h        |  2 +-
 .../llvm/CodeGen/MachineCopyPropagation.h     |  2 +-
 .../llvm/CodeGen/MachineCycleAnalysis.h       |  3 +-
 llvm/include/llvm/CodeGen/MachineDominators.h |  3 +-
 .../llvm/CodeGen/MachineFunctionAnalysis.h    |  3 +-
 .../include/llvm/CodeGen/MachineInstrBundle.h |  5 +-
 llvm/include/llvm/CodeGen/MachineLICM.h       |  2 +-
 .../llvm/CodeGen/MachineLateInstrsCleanup.h   |  2 +-
 llvm/include/llvm/CodeGen/MachineLoopInfo.h   |  4 +-
 .../include/llvm/CodeGen/MachinePassManager.h |  4 +-
 .../llvm/CodeGen/MachinePostDominators.h      |  3 +-
 llvm/include/llvm/CodeGen/MachineScheduler.h  |  5 +-
 llvm/include/llvm/CodeGen/MachineSink.h       |  2 +-
 .../llvm/CodeGen/MachineTraceMetrics.h        |  3 +-
 .../llvm/CodeGen/MachineUniformityAnalysis.h  |  3 +-
 llvm/include/llvm/CodeGen/MachineVerifier.h   |  3 +-
 llvm/include/llvm/CodeGen/OptimizePHIs.h      |  2 +-
 llvm/include/llvm/CodeGen/PEI.h               |  4 +-
 llvm/include/llvm/CodeGen/PHIElimination.h    |  3 +-
 llvm/include/llvm/CodeGen/PatchableFunction.h |  4 +-
 llvm/include/llvm/CodeGen/PeepholeOptimizer.h |  3 +-
 .../llvm/CodeGen/PostRAHazardRecognizer.h     |  3 +-
 llvm/include/llvm/CodeGen/PostRAMachineSink.h |  2 +-
 .../llvm/CodeGen/PostRASchedulerList.h        |  2 +-
 .../llvm/CodeGen/PreISelIntrinsicLowering.h   |  2 +-
 .../llvm/CodeGen/ProcessImplicitDefs.h        |  3 +-
 .../llvm/CodeGen/ReachingDefAnalysis.h        |  5 +-
 llvm/include/llvm/CodeGen/RegAllocFast.h      |  4 +-
 .../include/llvm/CodeGen/RegAllocGreedyPass.h |  3 +-
 .../llvm/CodeGen/RegUsageInfoPropagate.h      |  2 +-
 .../llvm/CodeGen/RegisterCoalescerPass.h      |  3 +-
 llvm/include/llvm/CodeGen/RegisterUsageInfo.h |  3 +-
 .../llvm/CodeGen/RemoveLoadsIntoFakeUses.h    |  2 +-
 .../llvm/CodeGen/RemoveRedundantDebugValues.h |  2 +-
 .../llvm/CodeGen/RenameIndependentSubregs.h   |  2 +-
 llvm/include/llvm/CodeGen/ReplaceWithVeclib.h |  2 +-
 llvm/include/llvm/CodeGen/SafeStack.h         |  2 +-
 .../llvm/CodeGen/SanitizerBinaryMetadata.h    |  3 +-
 llvm/include/llvm/CodeGen/SelectOptimize.h    |  2 +-
 llvm/include/llvm/CodeGen/SelectionDAGISel.h  |  4 +-
 .../llvm/CodeGen/ShadowStackGCLowering.h      |  2 +-
 llvm/include/llvm/CodeGen/ShrinkWrap.h        |  2 +-
 llvm/include/llvm/CodeGen/SjLjEHPrepare.h     |  2 +-
 llvm/include/llvm/CodeGen/SlotIndexes.h       |  4 +-
 llvm/include/llvm/CodeGen/StackColoring.h     |  2 +-
 .../CodeGen/StackFrameLayoutAnalysisPass.h    |  3 +-
 llvm/include/llvm/CodeGen/StackProtector.h    |  2 +-
 llvm/include/llvm/CodeGen/StackSlotColoring.h |  3 +-
 llvm/include/llvm/CodeGen/TailDuplication.h   |  2 +-
 .../llvm/CodeGen/TwoAddressInstructionPass.h  |  2 +-
 llvm/include/llvm/CodeGen/TypePromotion.h     |  2 +-
 .../llvm/CodeGen/UnreachableBlockElim.h       |  4 +-
 llvm/include/llvm/CodeGen/VirtRegMap.h        |  8 +-
 llvm/include/llvm/CodeGen/WasmEHPrepare.h     |  2 +-
 llvm/include/llvm/CodeGen/WinEHPrepare.h      |  2 +-
 .../llvm/CodeGen/XRayInstrumentation.h        |  4 +-
 llvm/include/llvm/IR/DebugInfo.h              |  3 +-
 llvm/include/llvm/IR/Dominators.h             |  8 +-
 llvm/include/llvm/IR/PassInstrumentation.h    |  7 +-
 llvm/include/llvm/IR/PassManager.h            | 38 +++++---
 llvm/include/llvm/IR/PassManagerInternal.h    | 17 ++--
 llvm/include/llvm/IR/SafepointIRVerifier.h    |  5 +-
 llvm/include/llvm/IR/Verifier.h               |  3 +-
 .../include/llvm/IRPrinter/IRPrintingPasses.h |  6 +-
 llvm/include/llvm/Passes/CodeGenPassBuilder.h |  6 +-
 llvm/include/llvm/Passes/PassBuilder.h        | 13 +--
 .../AggressiveInstCombine.h                   |  2 +-
 llvm/include/llvm/Transforms/CFGuard.h        |  2 +-
 .../Coroutines/CoroAnnotationElide.h          |  5 +-
 .../llvm/Transforms/Coroutines/CoroCleanup.h  |  3 +-
 .../Coroutines/CoroConditionalWrapper.h       |  4 +-
 .../llvm/Transforms/Coroutines/CoroEarly.h    |  3 +-
 .../llvm/Transforms/Coroutines/CoroElide.h    |  3 +-
 .../llvm/Transforms/Coroutines/CoroSplit.h    |  4 +-
 .../llvm/Transforms/HipStdPar/HipStdPar.h     | 13 +--
 .../llvm/Transforms/IPO/AlwaysInliner.h       |  3 +-
 .../llvm/Transforms/IPO/Annotation2Metadata.h |  3 +-
 .../llvm/Transforms/IPO/ArgumentPromotion.h   |  3 +-
 llvm/include/llvm/Transforms/IPO/Attributor.h |  8 +-
 .../llvm/Transforms/IPO/BlockExtractor.h      |  2 +-
 .../Transforms/IPO/CalledValuePropagation.h   |  2 +-
 .../llvm/Transforms/IPO/ConstantMerge.h       |  2 +-
 .../include/llvm/Transforms/IPO/CrossDSOCFI.h |  2 +-
 .../Transforms/IPO/DeadArgumentElimination.h  |  2 +-
 .../llvm/Transforms/IPO/ElimAvailExtern.h     |  2 +-
 .../llvm/Transforms/IPO/EmbedBitcodePass.h    |  4 +-
 .../llvm/Transforms/IPO/ExpandVariadics.h     |  2 +-
 llvm/include/llvm/Transforms/IPO/ExtractGV.h  |  2 +-
 .../llvm/Transforms/IPO/FatLTOCleanup.h       |  3 +-
 .../llvm/Transforms/IPO/ForceFunctionAttrs.h  |  3 +-
 .../llvm/Transforms/IPO/FunctionAttrs.h       |  7 +-
 .../llvm/Transforms/IPO/FunctionImport.h      |  2 +-
 llvm/include/llvm/Transforms/IPO/GlobalDCE.h  |  2 +-
 llvm/include/llvm/Transforms/IPO/GlobalOpt.h  |  2 +-
 .../include/llvm/Transforms/IPO/GlobalSplit.h |  2 +-
 .../llvm/Transforms/IPO/HotColdSplitting.h    |  3 +-
 llvm/include/llvm/Transforms/IPO/IROutliner.h |  2 +-
 .../llvm/Transforms/IPO/InferFunctionAttrs.h  |  3 +-
 llvm/include/llvm/Transforms/IPO/Inliner.h    |  4 +-
 .../include/llvm/Transforms/IPO/Internalize.h |  2 +-
 .../llvm/Transforms/IPO/LoopExtractor.h       |  2 +-
 .../llvm/Transforms/IPO/LowerTypeTests.h      |  7 +-
 .../IPO/MemProfContextDisambiguation.h        |  4 +-
 .../llvm/Transforms/IPO/MergeFunctions.h      |  2 +-
 .../llvm/Transforms/IPO/ModuleInliner.h       |  2 +-
 llvm/include/llvm/Transforms/IPO/OpenMPOpt.h  |  4 +-
 .../llvm/Transforms/IPO/PartialInlining.h     |  2 +-
 llvm/include/llvm/Transforms/IPO/SCCP.h       |  2 +-
 .../llvm/Transforms/IPO/SampleProfile.h       |  3 +-
 .../llvm/Transforms/IPO/SampleProfileProbe.h  |  6 +-
 .../llvm/Transforms/IPO/StripDeadPrototypes.h |  4 +-
 .../llvm/Transforms/IPO/StripSymbols.h        | 11 +--
 .../Transforms/IPO/ThinLTOBitcodeWriter.h     |  4 +-
 .../llvm/Transforms/IPO/WholeProgramDevirt.h  |  3 +-
 .../llvm/Transforms/InstCombine/InstCombine.h |  2 +-
 .../Instrumentation/AddressSanitizer.h        |  4 +-
 .../Transforms/Instrumentation/AllocToken.h   |  3 +-
 .../Instrumentation/BoundsChecking.h          |  3 +-
 .../Transforms/Instrumentation/CGProfile.h    |  2 +-
 .../Instrumentation/ControlHeightReduction.h  |  4 +-
 .../Instrumentation/DataFlowSanitizer.h       |  4 +-
 .../Transforms/Instrumentation/GCOVProfiler.h |  2 +-
 .../Instrumentation/HWAddressSanitizer.h      |  5 +-
 .../Instrumentation/InstrProfiling.h          |  2 +-
 .../llvm/Transforms/Instrumentation/KCFI.h    |  3 +-
 .../Instrumentation/LowerAllowCheckPass.h     |  4 +-
 .../Instrumentation/MemProfInstrumentation.h  |  7 +-
 .../Transforms/Instrumentation/MemProfUse.h   |  2 +-
 .../Instrumentation/MemorySanitizer.h         |  4 +-
 .../NumericalStabilitySanitizer.h             |  3 +-
 .../Instrumentation/PGOCtxProfFlattening.h    |  2 +-
 .../Instrumentation/PGOCtxProfLowering.h      |  6 +-
 .../Instrumentation/PGOForceFunctionAttrs.h   |  2 +-
 .../Instrumentation/PGOInstrumentation.h      | 13 +--
 .../Instrumentation/RealtimeSanitizer.h       |  4 +-
 .../Instrumentation/SanitizerBinaryMetadata.h |  3 +-
 .../Instrumentation/SanitizerCoverage.h       |  4 +-
 .../Instrumentation/ThreadSanitizer.h         |  7 +-
 .../Instrumentation/TypeSanitizer.h           |  3 +-
 llvm/include/llvm/Transforms/ObjCARC.h        |  8 +-
 llvm/include/llvm/Transforms/Scalar/ADCE.h    |  2 +-
 .../Scalar/AlignmentFromAssumptions.h         |  2 +-
 .../Transforms/Scalar/AnnotationRemarks.h     |  4 +-
 llvm/include/llvm/Transforms/Scalar/BDCE.h    |  2 +-
 .../Transforms/Scalar/CallSiteSplitting.h     |  2 +-
 .../llvm/Transforms/Scalar/ConstantHoisting.h |  3 +-
 .../Transforms/Scalar/ConstraintElimination.h |  2 +-
 .../Scalar/CorrelatedValuePropagation.h       |  2 +-
 llvm/include/llvm/Transforms/Scalar/DCE.h     |  4 +-
 .../llvm/Transforms/Scalar/DFAJumpThreading.h |  2 +-
 .../Transforms/Scalar/DeadStoreElimination.h  |  2 +-
 .../llvm/Transforms/Scalar/DivRemPairs.h      |  3 +-
 .../Scalar/DropUnnecessaryAssumes.h           |  2 +-
 .../include/llvm/Transforms/Scalar/EarlyCSE.h |  2 +-
 .../llvm/Transforms/Scalar/ExpandMemCmp.h     |  2 +-
 .../llvm/Transforms/Scalar/FlattenCFG.h       |  2 +-
 .../llvm/Transforms/Scalar/Float2Int.h        |  2 +-
 llvm/include/llvm/Transforms/Scalar/GVN.h     |  6 +-
 .../llvm/Transforms/Scalar/GuardWidening.h    |  2 +-
 .../llvm/Transforms/Scalar/IVUsersPrinter.h   |  3 +-
 .../llvm/Transforms/Scalar/IndVarSimplify.h   |  2 +-
 .../Scalar/InductiveRangeCheckElimination.h   |  2 +-
 .../Transforms/Scalar/InferAddressSpaces.h    |  2 +-
 .../llvm/Transforms/Scalar/InferAlignment.h   |  2 +-
 .../llvm/Transforms/Scalar/InstSimplifyPass.h |  2 +-
 .../Transforms/Scalar/JumpTableToSwitch.h     |  3 +-
 .../llvm/Transforms/Scalar/JumpThreading.h    |  2 +-
 llvm/include/llvm/Transforms/Scalar/LICM.h    |  4 +-
 .../Scalar/LoopAccessAnalysisPrinter.h        |  3 +-
 .../llvm/Transforms/Scalar/LoopBoundSplit.h   |  2 +-
 .../llvm/Transforms/Scalar/LoopDataPrefetch.h |  3 +-
 .../llvm/Transforms/Scalar/LoopDeletion.h     |  2 +-
 .../llvm/Transforms/Scalar/LoopDistribute.h   |  2 +-
 .../llvm/Transforms/Scalar/LoopFlatten.h      |  2 +-
 .../include/llvm/Transforms/Scalar/LoopFuse.h |  2 +-
 .../Transforms/Scalar/LoopIdiomRecognize.h    |  3 +-
 .../llvm/Transforms/Scalar/LoopInstSimplify.h |  3 +-
 .../llvm/Transforms/Scalar/LoopInterchange.h  |  2 +-
 .../Transforms/Scalar/LoopLoadElimination.h   |  3 +-
 .../llvm/Transforms/Scalar/LoopPassManager.h  | 12 +--
 .../llvm/Transforms/Scalar/LoopPredication.h  |  2 +-
 .../llvm/Transforms/Scalar/LoopRotation.h     |  2 +-
 .../llvm/Transforms/Scalar/LoopSimplifyCFG.h  |  2 +-
 .../include/llvm/Transforms/Scalar/LoopSink.h |  2 +-
 .../Transforms/Scalar/LoopStrengthReduce.h    |  3 +-
 .../llvm/Transforms/Scalar/LoopTermFold.h     |  2 +-
 .../Transforms/Scalar/LoopUnrollAndJamPass.h  |  3 +-
 .../llvm/Transforms/Scalar/LoopUnrollPass.h   |  4 +-
 .../Transforms/Scalar/LoopVersioningLICM.h    |  3 +-
 .../llvm/Transforms/Scalar/LowerAtomicPass.h  |  4 +-
 .../Scalar/LowerConstantIntrinsics.h          |  5 +-
 .../Transforms/Scalar/LowerExpectIntrinsic.h  |  4 +-
 .../Transforms/Scalar/LowerGuardIntrinsic.h   |  4 +-
 .../Transforms/Scalar/LowerMatrixIntrinsics.h |  3 +-
 .../Scalar/LowerWidenableCondition.h          |  4 +-
 .../Transforms/Scalar/MakeGuardsExplicit.h    |  3 +-
 .../llvm/Transforms/Scalar/MemCpyOptimizer.h  |  2 +-
 .../llvm/Transforms/Scalar/MergeICmps.h       |  3 +-
 .../Transforms/Scalar/MergedLoadStoreMotion.h |  2 +-
 .../llvm/Transforms/Scalar/NaryReassociate.h  |  2 +-
 llvm/include/llvm/Transforms/Scalar/NewGVN.h  |  2 +-
 .../Scalar/PartiallyInlineLibCalls.h          |  2 +-
 .../llvm/Transforms/Scalar/PlaceSafepoints.h  |  2 +-
 .../llvm/Transforms/Scalar/Reassociate.h      |  2 +-
 llvm/include/llvm/Transforms/Scalar/Reg2Mem.h |  2 +-
 .../Scalar/RewriteStatepointsForGC.h          |  3 +-
 llvm/include/llvm/Transforms/Scalar/SCCP.h    |  2 +-
 llvm/include/llvm/Transforms/Scalar/SROA.h    |  2 +-
 .../Scalar/ScalarizeMaskedMemIntrin.h         |  2 +-
 .../llvm/Transforms/Scalar/Scalarizer.h       |  2 +-
 .../Scalar/SeparateConstOffsetFromGEP.h       |  2 +-
 .../Transforms/Scalar/SimpleLoopUnswitch.h    |  3 +-
 .../llvm/Transforms/Scalar/SimplifyCFG.h      |  3 +-
 llvm/include/llvm/Transforms/Scalar/Sink.h    |  2 +-
 .../Transforms/Scalar/SpeculativeExecution.h  |  2 +-
 .../Scalar/StraightLineStrengthReduce.h       |  2 +-
 .../llvm/Transforms/Scalar/StructurizeCFG.h   |  2 +-
 .../Scalar/TailRecursionElimination.h         |  2 +-
 .../Transforms/Scalar/WarnMissedTransforms.h  |  2 +-
 .../llvm/Transforms/Utils/AddDiscriminators.h |  4 +-
 .../Transforms/Utils/AssumeBundleBuilder.h    |  4 +-
 .../Transforms/Utils/BreakCriticalEdges.h     |  3 +-
 .../Transforms/Utils/CanonicalizeAliases.h    |  3 +-
 .../Utils/CanonicalizeFreezeInLoops.h         |  2 +-
 .../llvm/Transforms/Utils/CountVisits.h       |  2 +-
 .../llvm/Transforms/Utils/DXILUpgrade.h       |  2 +-
 llvm/include/llvm/Transforms/Utils/Debugify.h |  5 +-
 .../Transforms/Utils/DeclareRuntimeLibcalls.h |  2 +-
 .../Transforms/Utils/EntryExitInstrumenter.h  |  4 +-
 .../llvm/Transforms/Utils/ExtraPassManager.h  |  8 +-
 .../llvm/Transforms/Utils/FixIrreducible.h    |  2 +-
 .../llvm/Transforms/Utils/HelloWorld.h        |  2 +-
 .../llvm/Transforms/Utils/IRNormalizer.h      |  2 +-
 .../llvm/Transforms/Utils/InjectTLIMappings.h |  2 +-
 .../llvm/Transforms/Utils/InstructionNamer.h  |  2 +-
 llvm/include/llvm/Transforms/Utils/LCSSA.h    |  2 +-
 .../Transforms/Utils/LibCallsShrinkWrap.h     |  3 +-
 .../llvm/Transforms/Utils/LoopSimplify.h      |  2 +-
 .../llvm/Transforms/Utils/LoopVersioning.h    |  2 +-
 .../llvm/Transforms/Utils/LowerGlobalDtors.h  |  3 +-
 .../llvm/Transforms/Utils/LowerIFunc.h        |  2 +-
 .../llvm/Transforms/Utils/LowerInvoke.h       |  3 +-
 .../llvm/Transforms/Utils/LowerSwitch.h       |  2 +-
 llvm/include/llvm/Transforms/Utils/Mem2Reg.h  |  2 +-
 .../llvm/Transforms/Utils/MetaRenamer.h       |  2 +-
 .../llvm/Transforms/Utils/MoveAutoInit.h      |  2 +-
 .../llvm/Transforms/Utils/NameAnonGlobals.h   |  4 +-
 .../llvm/Transforms/Utils/PredicateInfo.h     |  7 +-
 .../llvm/Transforms/Utils/ProfileVerify.h     |  4 +-
 .../Utils/RelLookupTableConverter.h           |  2 +-
 .../llvm/Transforms/Utils/StripGCRelocates.h  |  2 +-
 .../Utils/StripNonLineTableDebugInfo.h        |  2 +-
 .../llvm/Transforms/Utils/SymbolRewriter.h    |  2 +-
 .../Transforms/Utils/UnifyFunctionExitNodes.h |  2 +-
 .../llvm/Transforms/Utils/UnifyLoopExits.h    |  2 +-
 .../Vectorize/LoadStoreVectorizer.h           |  3 +-
 .../Transforms/Vectorize/LoopIdiomVectorize.h |  3 +-
 .../llvm/Transforms/Vectorize/LoopVectorize.h |  2 +-
 .../llvm/Transforms/Vectorize/SLPVectorizer.h |  2 +-
 .../SandboxVectorizer/SandboxVectorizer.h     |  3 +-
 .../llvm/Transforms/Vectorize/VectorCombine.h |  2 +-
 llvm/lib/Passes/PassBuilder.cpp               |  9 +-
 llvm/lib/Target/AArch64/AArch64.h             | 37 ++++----
 llvm/lib/Target/AMDGPU/AMDGPU.h               | 90 ++++++++++---------
 .../Target/AMDGPU/AMDGPUCtorDtorLowering.h    |  2 +-
 .../AMDGPU/AMDGPUExportKernelRuntimeHandles.h |  2 +-
 .../Target/AMDGPU/AMDGPULowerVGPREncoding.h   |  2 +-
 .../Target/AMDGPU/AMDGPUPerfHintAnalysis.h    |  2 +-
 .../AMDGPU/AMDGPUPreloadKernArgProlog.h       |  2 +-
 .../Target/AMDGPU/AMDGPUPrepareAGPRAlloc.h    |  2 +-
 .../AMDGPURemoveIncompatibleFunctions.h       |  2 +-
 llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h |  3 +-
 llvm/lib/Target/AMDGPU/AMDGPUSplitModule.h    |  3 +-
 .../AMDGPU/AMDGPUUnifyDivergentExitNodes.h    |  2 +-
 .../lib/Target/AMDGPU/AMDGPUWaitSGPRHazards.h |  2 +-
 llvm/lib/Target/AMDGPU/GCNDPPCombine.h        |  2 +-
 llvm/lib/Target/AMDGPU/GCNNSAReassign.h       |  2 +-
 .../lib/Target/AMDGPU/GCNPreRALongBranchReg.h |  2 +-
 .../lib/Target/AMDGPU/GCNPreRAOptimizations.h |  2 +-
 .../Target/AMDGPU/GCNRewritePartialRegUses.h  |  2 +-
 llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h      |  2 +-
 llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h      |  2 +-
 llvm/lib/Target/AMDGPU/SIFoldOperands.h       |  2 +-
 llvm/lib/Target/AMDGPU/SIFormMemoryClauses.h  |  3 +-
 llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.h |  2 +-
 llvm/lib/Target/AMDGPU/SILowerControlFlow.h   |  3 +-
 llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h    |  3 +-
 llvm/lib/Target/AMDGPU/SILowerWWMCopies.h     |  3 +-
 .../lib/Target/AMDGPU/SIOptimizeExecMasking.h |  2 +-
 .../AMDGPU/SIOptimizeExecMaskingPreRA.h       |  2 +-
 .../Target/AMDGPU/SIOptimizeVGPRLiveRange.h   |  2 +-
 llvm/lib/Target/AMDGPU/SIPeepholeSDWA.h       |  2 +-
 llvm/lib/Target/AMDGPU/SIPostRABundler.h      |  2 +-
 llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h |  2 +-
 llvm/lib/Target/AMDGPU/SIShrinkInstructions.h |  2 +-
 llvm/lib/Target/AMDGPU/SIWholeQuadMode.h      |  2 +-
 llvm/lib/Target/ARM/ARM.h                     |  4 +-
 llvm/lib/Target/BPF/BPF.h                     | 23 ++---
 llvm/lib/Target/DirectX/DXILCBufferAccess.h   |  2 +-
 .../Target/DirectX/DXILDataScalarization.h    |  3 +-
 llvm/lib/Target/DirectX/DXILFinalizeLinkage.h |  3 +-
 llvm/lib/Target/DirectX/DXILFlattenArrays.h   |  2 +-
 .../DirectX/DXILForwardHandleAccesses.h       |  2 +-
 .../Target/DirectX/DXILIntrinsicExpansion.h   |  3 +-
 llvm/lib/Target/DirectX/DXILLegalizePass.h    |  2 +-
 llvm/lib/Target/DirectX/DXILMemIntrinsics.h   |  2 +-
 llvm/lib/Target/DirectX/DXILOpLowering.h      |  2 +-
 .../DirectX/DXILPostOptimizationValidation.h  |  2 +-
 llvm/lib/Target/DirectX/DXILPrettyPrinter.h   |  3 +-
 llvm/lib/Target/DirectX/DXILResourceAccess.h  |  2 +-
 .../DirectX/DXILResourceImplicitBinding.h     |  2 +-
 llvm/lib/Target/DirectX/DXILRootSignature.h   |  2 +-
 llvm/lib/Target/DirectX/DXILShaderFlags.h     |  2 +-
 .../Target/DirectX/DXILTranslateMetadata.h    |  3 +-
 .../Hexagon/HexagonLoopIdiomRecognition.h     |  2 +-
 .../Hexagon/HexagonVectorLoopCarriedReuse.h   |  2 +-
 llvm/lib/Target/NVPTX/NVPTX.h                 | 19 ++--
 llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h |  2 +-
 llvm/lib/Target/RISCV/RISCV.h                 |  3 +-
 llvm/lib/Target/SPIRV/SPIRVCBufferAccess.h    |  2 +-
 llvm/lib/Target/SPIRV/SPIRVCtorDtorLowering.h |  2 +-
 llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.h   |  3 +-
 .../SPIRV/SPIRVLegalizeZeroSizeArrays.h       |  2 +-
 .../Target/SPIRV/SPIRVPushConstantAccess.h    |  3 +-
 .../Target/SPIRV/SPIRVStructurizerWrapper.h   |  2 +-
 llvm/lib/Target/X86/X86.h                     | 89 +++++++++---------
 llvm/lib/Target/X86/X86AsmPrinter.h           |  9 +-
 llvm/lib/Transforms/Utils/ProfileVerify.cpp   |  2 +-
 .../Analysis/CGSCCPassManagerTest.cpp         |  9 +-
 .../Analysis/LastRunTrackingAnalysisTest.cpp  |  2 +-
 llvm/unittests/CodeGen/PassManagerTest.cpp    |  8 +-
 .../unittests/IR/PassBuilderCallbacksTest.cpp |  2 +-
 llvm/unittests/IR/PassManagerTest.cpp         | 24 ++---
 llvm/unittests/IR/TimePassesTest.cpp          |  4 +-
 .../Plugins/DoublerPlugin/DoublerPlugin.cpp   |  2 +-
 .../Passes/Plugins/TestPlugin/TestPlugin.cpp  |  2 +-
 .../Transforms/Scalar/LoopPassManagerTest.cpp |  2 +-
 .../Transforms/Utils/MemTransferLowering.cpp  |  2 +-
 polly/include/polly/Pass/PollyFunctionPass.h  |  3 +-
 polly/include/polly/Pass/PollyModulePass.h    |  2 +-
 polly/include/polly/ScopDetection.h           |  6 +-
 polly/include/polly/ScopInfo.h                |  3 +-
 polly/include/polly/ScopInliner.h             |  2 +-
 .../include/polly/Support/DumpFunctionPass.h  |  2 +-
 polly/include/polly/Support/DumpModulePass.h  |  2 +-
 439 files changed, 838 insertions(+), 911 deletions(-)

diff --git a/llvm/docs/WritingAnLLVMNewPMPass.rst b/llvm/docs/WritingAnLLVMNewPMPass.rst
index ea30d637347f1..b3f5c2ecf98cc 100644
--- a/llvm/docs/WritingAnLLVMNewPMPass.rst
+++ b/llvm/docs/WritingAnLLVMNewPMPass.rst
@@ -25,7 +25,8 @@ Unlike passes under the legacy pass manager where the pass interface is
 defined via inheritance, passes under the new pass manager rely on
 concept-based polymorphism, meaning there is no explicit interface (see
 comments in ``PassManager.h`` for more details). All LLVM passes inherit from
-the CRTP mix-in ``PassInfoMixin<PassT>``. The pass should have a ``run()``
+the CRTP mix-in ``OptionalPassInfoMixin<PassT>`` or
+``MandatoryPassInfoMixin<PassT>``. The pass should have a ``run()``
 method which returns a ``PreservedAnalyses`` and takes in some unit of IR
 along with an analysis manager. For example, a function pass would have a
 ``PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);`` method.
@@ -82,7 +83,7 @@ contain the following boilerplate:
 
   namespace llvm {
 
-  class HelloWorldPass : public PassInfoMixin<HelloWorldPass> {
+  class HelloWorldPass : public OptionalPassInfoMixin<HelloWorldPass> {
   public:
     PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
   };
@@ -92,8 +93,12 @@ contain the following boilerplate:
   #endif // LLVM_TRANSFORMS_HELLONEW_HELLOWORLD_H
 
 This creates the class for the pass with a declaration of the ``run()``
-method which actually runs the pass. Inheriting from ``PassInfoMixin<PassT>``
-sets up some more boilerplate so that we don't have to write it ourselves.
+method which actually runs the pass. Inheriting from
+``OptionalPassInfoMixin<PassT>`` or ``MandatoryPassInfoMixin<PassT>`` sets up
+some more boilerplate so that we don't have to write it ourselves.
+``MandatoryPassInfoMixin`` should be used for passes that cannot be skipped
+(e.g. ``AlwaysInlinerPass``), while ``OptionalPassInfoMixin`` should be used
+for passes that can be skipped (e.g. optimization passes).
 
 Our class is in the ``llvm`` namespace so that we don't pollute the global
 namespace.
@@ -210,15 +215,13 @@ FAQs
 Required passes
 ---------------
 
-A pass that defines a static ``isRequired()`` method that returns true is a required pass. For example:
+A pass that inherits from ``MandatoryPassInfoMixin<PassT>`` is a required pass. For example:
 
 .. code-block:: c++
 
-  class HelloWorldPass : public PassInfoMixin<HelloWorldPass> {
+  class HelloWorldPass : public MandatoryPassInfoMixin<HelloWorldPass> {
   public:
     PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-    static bool isRequired() { return true; }
   };
 
 A required pass is a pass that may not be skipped. An example of a required
diff --git a/llvm/examples/Bye/Bye.cpp b/llvm/examples/Bye/Bye.cpp
index b476ab72a65f2..fbe3b75920679 100644
--- a/llvm/examples/Bye/Bye.cpp
+++ b/llvm/examples/Bye/Bye.cpp
@@ -30,7 +30,7 @@ struct LegacyBye : public FunctionPass {
   bool runOnFunction(Function &F) override { return runBye(F); }
 };
 
-struct Bye : PassInfoMixin<Bye> {
+struct Bye : OptionalPassInfoMixin<Bye> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &) {
     if (!runBye(F))
       return PreservedAnalyses::all();
diff --git a/llvm/examples/IRTransforms/SimplifyCFG.cpp b/llvm/examples/IRTransforms/SimplifyCFG.cpp
index bcdb1c64a9870..eb82ae9ad00d8 100644
--- a/llvm/examples/IRTransforms/SimplifyCFG.cpp
+++ b/llvm/examples/IRTransforms/SimplifyCFG.cpp
@@ -368,7 +368,7 @@ static bool doSimplify_v3(Function &F, DominatorTree &DT) {
 }
 
 namespace {
-struct SimplifyCFGPass : public PassInfoMixin<SimplifyCFGPass> {
+struct SimplifyCFGPass : public OptionalPassInfoMixin<SimplifyCFGPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM) {
     switch (Version) {
     case V1:
diff --git a/llvm/include/llvm/Analysis/AliasAnalysisEvaluator.h b/llvm/include/llvm/Analysis/AliasAnalysisEvaluator.h
index d8b02bd42e7d8..07e8d03c6c7b2 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysisEvaluator.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysisEvaluator.h
@@ -31,7 +31,7 @@ namespace llvm {
 class AAResults;
 class Function;
 
-class AAEvaluator : public PassInfoMixin<AAEvaluator> {
+class AAEvaluator : public OptionalPassInfoMixin<AAEvaluator> {
   int64_t FunctionCount = 0;
   int64_t NoAliasCount = 0, MayAliasCount = 0, PartialAliasCount = 0;
   int64_t MustAliasCount = 0;
diff --git a/llvm/include/llvm/Analysis/AliasSetTracker.h b/llvm/include/llvm/Analysis/AliasSetTracker.h
index 7d461b230478b..1e3b5006c2088 100644
--- a/llvm/include/llvm/Analysis/AliasSetTracker.h
+++ b/llvm/include/llvm/Analysis/AliasSetTracker.h
@@ -270,13 +270,13 @@ inline raw_ostream& operator<<(raw_ostream &OS, const AliasSetTracker &AST) {
   return OS;
 }
 
-class AliasSetsPrinterPass : public PassInfoMixin<AliasSetsPrinterPass> {
+class AliasSetsPrinterPass
+    : public MandatoryPassInfoMixin<AliasSetsPrinterPass> {
   raw_ostream &OS;
 
 public:
   LLVM_ABI explicit AliasSetsPrinterPass(raw_ostream &OS);
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Analysis/AssumptionCache.h b/llvm/include/llvm/Analysis/AssumptionCache.h
index 5656729d20366..404ed715522eb 100644
--- a/llvm/include/llvm/Analysis/AssumptionCache.h
+++ b/llvm/include/llvm/Analysis/AssumptionCache.h
@@ -189,15 +189,14 @@ class AssumptionAnalysis : public AnalysisInfoMixin<AssumptionAnalysis> {
 };
 
 /// Printer pass for the \c AssumptionAnalysis results.
-class AssumptionPrinterPass : public PassInfoMixin<AssumptionPrinterPass> {
+class AssumptionPrinterPass
+    : public MandatoryPassInfoMixin<AssumptionPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit AssumptionPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// An immutable pass that tracks lazily created \c AssumptionCache
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h
index 860ceb4e6cce6..a8a54bd0f9c5c 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h
@@ -132,15 +132,13 @@ class BlockFrequencyAnalysis
 
 /// Printer pass for the \c BlockFrequencyInfo results.
 class BlockFrequencyPrinterPass
-    : public PassInfoMixin<BlockFrequencyPrinterPass> {
+    : public MandatoryPassInfoMixin<BlockFrequencyPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit BlockFrequencyPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Legacy analysis pass which computes \c BlockFrequencyInfo.
diff --git a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
index 7a8b8a3aa658a..81bcecbc4e46f 100644
--- a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
+++ b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
@@ -213,15 +213,13 @@ class BranchProbabilityAnalysis
 
 /// Printer pass for the \c BranchProbabilityAnalysis results.
 class BranchProbabilityPrinterPass
-    : public PassInfoMixin<BranchProbabilityPrinterPass> {
+    : public MandatoryPassInfoMixin<BranchProbabilityPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit BranchProbabilityPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Legacy analysis pass which computes \c BranchProbabilityInfo.
diff --git a/llvm/include/llvm/Analysis/CFGPrinter.h b/llvm/include/llvm/Analysis/CFGPrinter.h
index c48d2e5887919..f31754e7764ab 100644
--- a/llvm/include/llvm/Analysis/CFGPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGPrinter.h
@@ -38,28 +38,24 @@ namespace llvm {
 class ModuleSlotTracker;
 
 template <class GraphType> struct GraphTraits;
-class CFGViewerPass : public PassInfoMixin<CFGViewerPass> {
+class CFGViewerPass : public MandatoryPassInfoMixin<CFGViewerPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
-class CFGOnlyViewerPass : public PassInfoMixin<CFGOnlyViewerPass> {
+class CFGOnlyViewerPass : public MandatoryPassInfoMixin<CFGOnlyViewerPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
-class CFGPrinterPass : public PassInfoMixin<CFGPrinterPass> {
+class CFGPrinterPass : public MandatoryPassInfoMixin<CFGPrinterPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
-class CFGOnlyPrinterPass : public PassInfoMixin<CFGOnlyPrinterPass> {
+class CFGOnlyPrinterPass : public MandatoryPassInfoMixin<CFGOnlyPrinterPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 class DOTFuncInfo {
diff --git a/llvm/include/llvm/Analysis/CFGSCCPrinter.h b/llvm/include/llvm/Analysis/CFGSCCPrinter.h
index 0ea0b46c46269..09232af70c372 100644
--- a/llvm/include/llvm/Analysis/CFGSCCPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGSCCPrinter.h
@@ -13,13 +13,12 @@
 
 namespace llvm {
 
-class CFGSCCPrinterPass : public PassInfoMixin<CFGSCCPrinterPass> {
+class CFGSCCPrinterPass : public MandatoryPassInfoMixin<CFGSCCPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit CFGSCCPrinterPass(raw_ostream &OS) : OS(OS) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/include/llvm/Analysis/CGSCCPassManager.h b/llvm/include/llvm/Analysis/CGSCCPassManager.h
index 87cfd9e6064e9..8965e992047f5 100644
--- a/llvm/include/llvm/Analysis/CGSCCPassManager.h
+++ b/llvm/include/llvm/Analysis/CGSCCPassManager.h
@@ -148,9 +148,9 @@ using CGSCCPassManager =
 template <typename AnalysisT>
 struct RequireAnalysisPass<AnalysisT, LazyCallGraph::SCC, CGSCCAnalysisManager,
                            LazyCallGraph &, CGSCCUpdateResult &>
-    : PassInfoMixin<RequireAnalysisPass<AnalysisT, LazyCallGraph::SCC,
-                                        CGSCCAnalysisManager, LazyCallGraph &,
-                                        CGSCCUpdateResult &>> {
+    : MandatoryPassInfoMixin<RequireAnalysisPass<
+          AnalysisT, LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &,
+          CGSCCUpdateResult &>> {
   PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
                         LazyCallGraph &CG, CGSCCUpdateResult &) {
     (void)AM.template getResult<AnalysisT>(C, CG);
@@ -313,7 +313,7 @@ struct CGSCCUpdateResult {
 /// pass over the module to enable a \c FunctionAnalysisManager to be used
 /// within this run safely.
 class ModuleToPostOrderCGSCCPassAdaptor
-    : public PassInfoMixin<ModuleToPostOrderCGSCCPassAdaptor> {
+    : public MandatoryPassInfoMixin<ModuleToPostOrderCGSCCPassAdaptor> {
 public:
   using PassConceptT =
       detail::PassConcept<LazyCallGraph::SCC, CGSCCAnalysisManager,
@@ -346,8 +346,6 @@ class ModuleToPostOrderCGSCCPassAdaptor
     OS << ')';
   }
 
-  static bool isRequired() { return true; }
-
 private:
   std::unique_ptr<PassConceptT> Pass;
 };
@@ -445,7 +443,7 @@ LLVM_ABI LazyCallGraph::SCC &updateCGAndAnalysisManagerForCGSCCPass(
 /// pass over the SCC to enable a \c FunctionAnalysisManager to be used
 /// within this run safely.
 class CGSCCToFunctionPassAdaptor
-    : public PassInfoMixin<CGSCCToFunctionPassAdaptor> {
+    : public MandatoryPassInfoMixin<CGSCCToFunctionPassAdaptor> {
 public:
   using PassConceptT = detail::PassConcept<Function, FunctionAnalysisManager>;
 
@@ -491,8 +489,6 @@ class CGSCCToFunctionPassAdaptor
     OS << ')';
   }
 
-  static bool isRequired() { return true; }
-
 private:
   std::unique_ptr<PassConceptT> Pass;
   bool EagerlyInvalidate;
@@ -544,7 +540,8 @@ class ShouldNotRunFunctionPassesAnalysis
 /// This repetition has the potential to be very large however, as each one
 /// might refine a single call site. As a consequence, in practice we use an
 /// upper bound on the number of repetitions to limit things.
-class DevirtSCCRepeatedPass : public PassInfoMixin<DevirtSCCRepeatedPass> {
+class DevirtSCCRepeatedPass
+    : public OptionalPassInfoMixin<DevirtSCCRepeatedPass> {
 public:
   using PassConceptT =
       detail::PassConcept<LazyCallGraph::SCC, CGSCCAnalysisManager,
diff --git a/llvm/include/llvm/Analysis/CallGraph.h b/llvm/include/llvm/Analysis/CallGraph.h
index 1dd37d47eea71..627765368b3b2 100644
--- a/llvm/include/llvm/Analysis/CallGraph.h
+++ b/llvm/include/llvm/Analysis/CallGraph.h
@@ -299,28 +299,25 @@ class CallGraphAnalysis : public AnalysisInfoMixin<CallGraphAnalysis> {
 };
 
 /// Printer pass for the \c CallGraphAnalysis results.
-class CallGraphPrinterPass : public PassInfoMixin<CallGraphPrinterPass> {
+class CallGraphPrinterPass
+    : public MandatoryPassInfoMixin<CallGraphPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit CallGraphPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Printer pass for the summarized \c CallGraphAnalysis results.
 class CallGraphSCCsPrinterPass
-    : public PassInfoMixin<CallGraphSCCsPrinterPass> {
+    : public MandatoryPassInfoMixin<CallGraphSCCsPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit CallGraphSCCsPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// The \c ModulePass which wraps up a \c CallGraph and the logic to
diff --git a/llvm/include/llvm/Analysis/CallPrinter.h b/llvm/include/llvm/Analysis/CallPrinter.h
index 8f28d8af4671f..d374995e886e0 100644
--- a/llvm/include/llvm/Analysis/CallPrinter.h
+++ b/llvm/include/llvm/Analysis/CallPrinter.h
@@ -22,17 +22,16 @@ namespace llvm {
 class ModulePass;
 
 /// Pass for printing the call graph to a dot file
-class CallGraphDOTPrinterPass : public PassInfoMixin<CallGraphDOTPrinterPass> {
+class CallGraphDOTPrinterPass
+    : public MandatoryPassInfoMixin<CallGraphDOTPrinterPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// Pass for viewing the call graph
-class CallGraphViewerPass : public PassInfoMixin<CallGraphViewerPass> {
+class CallGraphViewerPass : public MandatoryPassInfoMixin<CallGraphViewerPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 LLVM_ABI ModulePass *createCallGraphViewerPass();
diff --git a/llvm/include/llvm/Analysis/CostModel.h b/llvm/include/llvm/Analysis/CostModel.h
index 9b127c27ba7ef..9a095bedb8d60 100644
--- a/llvm/include/llvm/Analysis/CostModel.h
+++ b/llvm/include/llvm/Analysis/CostModel.h
@@ -13,15 +13,14 @@
 
 namespace llvm {
 /// Printer pass for cost modeling results.
-class CostModelPrinterPass : public PassInfoMixin<CostModelPrinterPass> {
+class CostModelPrinterPass
+    : public MandatoryPassInfoMixin<CostModelPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit CostModelPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Analysis/CtxProfAnalysis.h b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
index 5c9823b0f6cc1..d116cab6448cd 100644
--- a/llvm/include/llvm/Analysis/CtxProfAnalysis.h
+++ b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
@@ -147,13 +147,12 @@ class CtxProfAnalysis : public AnalysisInfoMixin<CtxProfAnalysis> {
 };
 
 class CtxProfAnalysisPrinterPass
-    : public PassInfoMixin<CtxProfAnalysisPrinterPass> {
+    : public MandatoryPassInfoMixin<CtxProfAnalysisPrinterPass> {
 public:
   enum class PrintMode { Everything, YAML };
   LLVM_ABI explicit CtxProfAnalysisPrinterPass(raw_ostream &OS);
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-  static bool isRequired() { return true; }
 
 private:
   raw_ostream &OS;
@@ -197,7 +196,7 @@ class ProfileAnnotator {
 // the pass pipeline, associate it with any Global Value, and then use it for
 // PGO and ThinLTO.
 // At that point, this should be moved elsewhere.
-class AssignGUIDPass : public PassInfoMixin<AssignGUIDPass> {
+class AssignGUIDPass : public OptionalPassInfoMixin<AssignGUIDPass> {
 public:
   explicit AssignGUIDPass() = default;
 
diff --git a/llvm/include/llvm/Analysis/CycleAnalysis.h b/llvm/include/llvm/Analysis/CycleAnalysis.h
index 1f2dd6d98dee0..2efc409c6360d 100644
--- a/llvm/include/llvm/Analysis/CycleAnalysis.h
+++ b/llvm/include/llvm/Analysis/CycleAnalysis.h
@@ -62,18 +62,18 @@ class CycleAnalysis : public AnalysisInfoMixin<CycleAnalysis> {
   // TODO: verify analysis?
 };
 
-class CycleInfoPrinterPass : public PassInfoMixin<CycleInfoPrinterPass> {
+class CycleInfoPrinterPass
+    : public MandatoryPassInfoMixin<CycleInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit CycleInfoPrinterPass(raw_ostream &OS);
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
-struct CycleInfoVerifierPass : public PassInfoMixin<CycleInfoVerifierPass> {
+struct CycleInfoVerifierPass
+    : public MandatoryPassInfoMixin<CycleInfoVerifierPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Analysis/DDG.h b/llvm/include/llvm/Analysis/DDG.h
index 120bb46330a79..656e48e6dd9c7 100644
--- a/llvm/include/llvm/Analysis/DDG.h
+++ b/llvm/include/llvm/Analysis/DDG.h
@@ -421,13 +421,13 @@ class DDGAnalysis : public AnalysisInfoMixin<DDGAnalysis> {
 };
 
 /// Textual printer pass for the DDG of a loop.
-class DDGAnalysisPrinterPass : public PassInfoMixin<DDGAnalysisPrinterPass> {
+class DDGAnalysisPrinterPass
+    : public MandatoryPassInfoMixin<DDGAnalysisPrinterPass> {
 public:
   explicit DDGAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                                  LoopStandardAnalysisResults &AR,
                                  LPMUpdater &U);
-  static bool isRequired() { return true; }
 
 private:
   raw_ostream &OS;
diff --git a/llvm/include/llvm/Analysis/DDGPrinter.h b/llvm/include/llvm/Analysis/DDGPrinter.h
index 2ed73ee2b59e7..23b2a6aaaa5c7 100644
--- a/llvm/include/llvm/Analysis/DDGPrinter.h
+++ b/llvm/include/llvm/Analysis/DDGPrinter.h
@@ -25,11 +25,10 @@ class Loop;
 //===--------------------------------------------------------------------===//
 // Implementation of DDG DOT Printer for a loop.
 //===--------------------------------------------------------------------===//
-class DDGDotPrinterPass : public PassInfoMixin<DDGDotPrinterPass> {
+class DDGDotPrinterPass : public MandatoryPassInfoMixin<DDGDotPrinterPass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
-  static bool isRequired() { return true; }
 };
 
 //===--------------------------------------------------------------------===//
diff --git a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
index 19a202f78c6ce..198c93ee07a45 100644
--- a/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
+++ b/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
@@ -44,8 +44,8 @@ template <typename AnalysisT, bool IsSimple,
           typename AnalysisGraphTraitsT =
               DefaultAnalysisGraphTraits<typename AnalysisT::Result &, GraphT>>
 struct DOTGraphTraitsViewer
-    : PassInfoMixin<DOTGraphTraitsViewer<AnalysisT, IsSimple, GraphT,
-                                         AnalysisGraphTraitsT>> {
+    : OptionalPassInfoMixin<DOTGraphTraitsViewer<AnalysisT, IsSimple, GraphT,
+                                                 AnalysisGraphTraitsT>> {
   DOTGraphTraitsViewer(StringRef GraphName) : Name(GraphName) {}
 
   /// Return true if this function should be processed.
@@ -124,8 +124,8 @@ template <typename AnalysisT, bool IsSimple,
           typename AnalysisGraphTraitsT =
               DefaultAnalysisGraphTraits<typename AnalysisT::Result &, GraphT>>
 struct DOTGraphTraitsPrinter
-    : PassInfoMixin<DOTGraphTraitsPrinter<AnalysisT, IsSimple, GraphT,
-                                          AnalysisGraphTraitsT>> {
+    : OptionalPassInfoMixin<DOTGraphTraitsPrinter<AnalysisT, IsSimple, GraphT,
+                                                  AnalysisGraphTraitsT>> {
   DOTGraphTraitsPrinter(StringRef GraphName) : Name(GraphName) {}
 
   /// Return true if this function should be processed.
diff --git a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
index a1b030c157eae..01f1316e6cde5 100644
--- a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
+++ b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
@@ -59,15 +59,13 @@ class DXILMetadataAnalysis : public AnalysisInfoMixin<DXILMetadataAnalysis> {
 
 /// Printer pass for the \c DXILMetadataAnalysis results.
 class DXILMetadataAnalysisPrinterPass
-    : public PassInfoMixin<DXILMetadataAnalysisPrinterPass> {
+    : public MandatoryPassInfoMixin<DXILMetadataAnalysisPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit DXILMetadataAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Legacy pass
diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index dc54dfa64b539..1553400e5a7b1 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -622,15 +622,14 @@ class DXILResourceAnalysis : public AnalysisInfoMixin<DXILResourceAnalysis> {
 };
 
 /// Printer pass for the \c DXILResourceAnalysis results.
-class DXILResourcePrinterPass : public PassInfoMixin<DXILResourcePrinterPass> {
+class DXILResourcePrinterPass
+    : public MandatoryPassInfoMixin<DXILResourcePrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit DXILResourcePrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 class LLVM_ABI DXILResourceWrapperPass : public ModulePass {
diff --git a/llvm/include/llvm/Analysis/Delinearization.h b/llvm/include/llvm/Analysis/Delinearization.h
index 6a11fb99a8b46..f83fba4b21723 100644
--- a/llvm/include/llvm/Analysis/Delinearization.h
+++ b/llvm/include/llvm/Analysis/Delinearization.h
@@ -161,10 +161,9 @@ bool getIndexExpressionsFromGEP(ScalarEvolution &SE,
                                 SmallVectorImpl<const SCEV *> &Sizes);
 
 struct DelinearizationPrinterPass
-    : public PassInfoMixin<DelinearizationPrinterPass> {
+    : public MandatoryPassInfoMixin<DelinearizationPrinterPass> {
   explicit DelinearizationPrinterPass(raw_ostream &OS);
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 
 private:
   raw_ostream &OS;
diff --git a/llvm/include/llvm/Analysis/DemandedBits.h b/llvm/include/llvm/Analysis/DemandedBits.h
index 8d623b625fab8..d4629a0019b6b 100644
--- a/llvm/include/llvm/Analysis/DemandedBits.h
+++ b/llvm/include/llvm/Analysis/DemandedBits.h
@@ -116,15 +116,14 @@ class DemandedBitsAnalysis : public AnalysisInfoMixin<DemandedBitsAnalysis> {
 };
 
 /// Printer pass for DemandedBits
-class DemandedBitsPrinterPass : public PassInfoMixin<DemandedBitsPrinterPass> {
+class DemandedBitsPrinterPass
+    : public MandatoryPassInfoMixin<DemandedBitsPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit DemandedBitsPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Analysis/DependenceAnalysis.h b/llvm/include/llvm/Analysis/DependenceAnalysis.h
index eed89878bc4e5..8c11728f14f1f 100644
--- a/llvm/include/llvm/Analysis/DependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/DependenceAnalysis.h
@@ -727,14 +727,12 @@ class DependenceAnalysis : public AnalysisInfoMixin<DependenceAnalysis> {
 
 /// Printer pass to dump DA results.
 struct DependenceAnalysisPrinterPass
-    : public PassInfoMixin<DependenceAnalysisPrinterPass> {
+    : public MandatoryPassInfoMixin<DependenceAnalysisPrinterPass> {
   DependenceAnalysisPrinterPass(raw_ostream &OS, bool NormalizeResults = false)
       : OS(OS), NormalizeResults(NormalizeResults) {}
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 
-  static bool isRequired() { return true; }
-
 private:
   raw_ostream &OS;
   bool NormalizeResults;
diff --git a/llvm/include/llvm/Analysis/DominanceFrontier.h b/llvm/include/llvm/Analysis/DominanceFrontier.h
index b76e6efd812fd..43ee353cb5e23 100644
--- a/llvm/include/llvm/Analysis/DominanceFrontier.h
+++ b/llvm/include/llvm/Analysis/DominanceFrontier.h
@@ -146,15 +146,13 @@ class DominanceFrontierAnalysis
 
 /// Printer pass for the \c DominanceFrontier.
 class DominanceFrontierPrinterPass
-    : public PassInfoMixin<DominanceFrontierPrinterPass> {
+    : public MandatoryPassInfoMixin<DominanceFrontierPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit DominanceFrontierPrinterPass(raw_ostream &OS);
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index aa3e20c914ab7..50af826c293df 100644
--- a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -173,20 +173,18 @@ class FunctionPropertiesAnalysis
 
 /// Printer pass for the FunctionPropertiesAnalysis results.
 class FunctionPropertiesPrinterPass
-    : public PassInfoMixin<FunctionPropertiesPrinterPass> {
+    : public MandatoryPassInfoMixin<FunctionPropertiesPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit FunctionPropertiesPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Statistics pass for the FunctionPropertiesAnalysis results.
 class FunctionPropertiesStatisticsPass
-    : public PassInfoMixin<FunctionPropertiesStatisticsPass> {
+    : public OptionalPassInfoMixin<FunctionPropertiesStatisticsPass> {
   bool IsPreOptimization;
 
 public:
diff --git a/llvm/include/llvm/Analysis/GlobalsModRef.h b/llvm/include/llvm/Analysis/GlobalsModRef.h
index 10275ac0d784c..108135e15adf4 100644
--- a/llvm/include/llvm/Analysis/GlobalsModRef.h
+++ b/llvm/include/llvm/Analysis/GlobalsModRef.h
@@ -138,7 +138,7 @@ class GlobalsAA : public AnalysisInfoMixin<GlobalsAA> {
   LLVM_ABI GlobalsAAResult run(Module &M, ModuleAnalysisManager &AM);
 };
 
-struct RecomputeGlobalsAAPass : PassInfoMixin<RecomputeGlobalsAAPass> {
+struct RecomputeGlobalsAAPass : OptionalPassInfoMixin<RecomputeGlobalsAAPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Analysis/HashRecognize.h b/llvm/include/llvm/Analysis/HashRecognize.h
index 6dea3d24885ff..71f8142cf056d 100644
--- a/llvm/include/llvm/Analysis/HashRecognize.h
+++ b/llvm/include/llvm/Analysis/HashRecognize.h
@@ -94,7 +94,7 @@ class HashRecognize {
 };
 
 class HashRecognizePrinterPass
-    : public PassInfoMixin<HashRecognizePrinterPass> {
+    : public OptionalPassInfoMixin<HashRecognizePrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h
index 968873c918393..adf98c8db77ee 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -652,23 +652,22 @@ class IR2VecVocabAnalysis : public AnalysisInfoMixin<IR2VecVocabAnalysis> {
 
 /// This pass prints the IR2Vec embeddings for instructions, basic blocks, and
 /// functions.
-class IR2VecPrinterPass : public PassInfoMixin<IR2VecPrinterPass> {
+class IR2VecPrinterPass : public MandatoryPassInfoMixin<IR2VecPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit IR2VecPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-  static bool isRequired() { return true; }
 };
 
 /// This pass prints the embeddings in the vocabulary
-class IR2VecVocabPrinterPass : public PassInfoMixin<IR2VecVocabPrinterPass> {
+class IR2VecVocabPrinterPass
+    : public MandatoryPassInfoMixin<IR2VecVocabPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit IR2VecVocabPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index ceb5672f2aaf2..dd38951ff4170 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -1195,13 +1195,12 @@ class IRSimilarityAnalysis : public AnalysisInfoMixin<IRSimilarityAnalysis> {
 
 /// Printer pass that uses \c IRSimilarityAnalysis.
 class IRSimilarityAnalysisPrinterPass
-    : public PassInfoMixin<IRSimilarityAnalysisPrinterPass> {
+    : public MandatoryPassInfoMixin<IRSimilarityAnalysisPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit IRSimilarityAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h b/llvm/include/llvm/Analysis/InlineAdvisor.h
index 50ba3c13da70f..3e5f4f7f21664 100644
--- a/llvm/include/llvm/Analysis/InlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/InlineAdvisor.h
@@ -339,7 +339,7 @@ class InlineAdvisorAnalysis : public AnalysisInfoMixin<InlineAdvisorAnalysis> {
 
 /// Printer pass for the InlineAdvisorAnalysis results.
 class InlineAdvisorAnalysisPrinterPass
-    : public PassInfoMixin<InlineAdvisorAnalysisPrinterPass> {
+    : public MandatoryPassInfoMixin<InlineAdvisorAnalysisPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -350,7 +350,6 @@ class InlineAdvisorAnalysisPrinterPass
   LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &InitialC,
                                  CGSCCAnalysisManager &AM, LazyCallGraph &CG,
                                  CGSCCUpdateResult &UR);
-  static bool isRequired() { return true; }
 };
 
 LLVM_ABI std::unique_ptr<InlineAdvisor>
diff --git a/llvm/include/llvm/Analysis/InlineCost.h b/llvm/include/llvm/Analysis/InlineCost.h
index 1faf480c590ac..78d4fa39b6fbe 100644
--- a/llvm/include/llvm/Analysis/InlineCost.h
+++ b/llvm/include/llvm/Analysis/InlineCost.h
@@ -351,13 +351,12 @@ LLVM_ABI InlineResult isInlineViable(Function &Callee);
 // debugging and analysis. The main purpose of the pass is to see and test
 // inliner's decisions when creating new optimizations to InlineCost.
 struct InlineCostAnnotationPrinterPass
-    : PassInfoMixin<InlineCostAnnotationPrinterPass> {
+    : MandatoryPassInfoMixin<InlineCostAnnotationPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit InlineCostAnnotationPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
-  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/include/llvm/Analysis/InstCount.h b/llvm/include/llvm/Analysis/InstCount.h
index 4a19dbad57513..31afc7e7b1c47 100644
--- a/llvm/include/llvm/Analysis/InstCount.h
+++ b/llvm/include/llvm/Analysis/InstCount.h
@@ -19,7 +19,7 @@ namespace llvm {
 
 class Function;
 
-class InstCountPass : public PassInfoMixin<InstCountPass> {
+class InstCountPass : public OptionalPassInfoMixin<InstCountPass> {
   bool IsPreOptimization;
 
 public:
diff --git a/llvm/include/llvm/Analysis/KernelInfo.h b/llvm/include/llvm/Analysis/KernelInfo.h
index 75d92c202212b..dac249ea28a07 100644
--- a/llvm/include/llvm/Analysis/KernelInfo.h
+++ b/llvm/include/llvm/Analysis/KernelInfo.h
@@ -21,15 +21,13 @@ namespace llvm {
 
 class TargetMachine;
 
-class KernelInfoPrinter : public PassInfoMixin<KernelInfoPrinter> {
+class KernelInfoPrinter : public MandatoryPassInfoMixin<KernelInfoPrinter> {
   TargetMachine *TM;
 
 public:
   explicit KernelInfoPrinter(TargetMachine *TM) : TM(TM) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 } // namespace llvm
 #endif // LLVM_ANALYSIS_KERNELINFO_H
diff --git a/llvm/include/llvm/Analysis/LazyCallGraph.h b/llvm/include/llvm/Analysis/LazyCallGraph.h
index 17215d6cd0bf1..7812291f92238 100644
--- a/llvm/include/llvm/Analysis/LazyCallGraph.h
+++ b/llvm/include/llvm/Analysis/LazyCallGraph.h
@@ -1283,30 +1283,26 @@ class LazyCallGraphAnalysis : public AnalysisInfoMixin<LazyCallGraphAnalysis> {
 ///
 /// This is primarily useful for testing the analysis.
 class LazyCallGraphPrinterPass
-    : public PassInfoMixin<LazyCallGraphPrinterPass> {
+    : public MandatoryPassInfoMixin<LazyCallGraphPrinterPass> {
   raw_ostream &OS;
 
 public:
   LLVM_ABI explicit LazyCallGraphPrinterPass(raw_ostream &OS);
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// A pass which prints the call graph as a DOT file to a \c raw_ostream.
 ///
 /// This is primarily useful for visualization purposes.
 class LazyCallGraphDOTPrinterPass
-    : public PassInfoMixin<LazyCallGraphDOTPrinterPass> {
+    : public MandatoryPassInfoMixin<LazyCallGraphDOTPrinterPass> {
   raw_ostream &OS;
 
 public:
   LLVM_ABI explicit LazyCallGraphDOTPrinterPass(raw_ostream &OS);
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 extern template struct LLVM_TEMPLATE_ABI
diff --git a/llvm/include/llvm/Analysis/LazyValueInfo.h b/llvm/include/llvm/Analysis/LazyValueInfo.h
index 0c6831a720896..a24a90a5d2305 100644
--- a/llvm/include/llvm/Analysis/LazyValueInfo.h
+++ b/llvm/include/llvm/Analysis/LazyValueInfo.h
@@ -147,15 +147,13 @@ class LazyValueAnalysis : public AnalysisInfoMixin<LazyValueAnalysis> {
 
 /// Printer pass for the LazyValueAnalysis results.
 class LazyValueInfoPrinterPass
-    : public PassInfoMixin<LazyValueInfoPrinterPass> {
+    : public MandatoryPassInfoMixin<LazyValueInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit LazyValueInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Wrapper around LazyValueInfo.
diff --git a/llvm/include/llvm/Analysis/Lint.h b/llvm/include/llvm/Analysis/Lint.h
index b0bc0ff4e1d89..9920ab7ec9ac1 100644
--- a/llvm/include/llvm/Analysis/Lint.h
+++ b/llvm/include/llvm/Analysis/Lint.h
@@ -34,7 +34,7 @@ void lintModule(const Module &M, bool AbortOnError = false);
 // Lint a function.
 void lintFunction(const Function &F, bool AbortOnError = false);
 
-class LintPass : public PassInfoMixin<LintPass> {
+class LintPass : public OptionalPassInfoMixin<LintPass> {
   const bool AbortOnError;
 
 public:
diff --git a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
index 5184944e36232..a695caedbce79 100644
--- a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
@@ -278,7 +278,8 @@ raw_ostream &operator<<(raw_ostream &OS, const IndexedReference &R);
 raw_ostream &operator<<(raw_ostream &OS, const CacheCost &CC);
 
 /// Printer pass for the \c CacheCost results.
-class LoopCachePrinterPass : public PassInfoMixin<LoopCachePrinterPass> {
+class LoopCachePrinterPass
+    : public MandatoryPassInfoMixin<LoopCachePrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -286,8 +287,6 @@ class LoopCachePrinterPass : public PassInfoMixin<LoopCachePrinterPass> {
 
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
-
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h
index d7131b909d8a2..3114b6ce61814 100644
--- a/llvm/include/llvm/Analysis/LoopInfo.h
+++ b/llvm/include/llvm/Analysis/LoopInfo.h
@@ -577,19 +577,17 @@ class LoopAnalysis : public AnalysisInfoMixin<LoopAnalysis> {
 };
 
 /// Printer pass for the \c LoopAnalysis results.
-class LoopPrinterPass : public PassInfoMixin<LoopPrinterPass> {
+class LoopPrinterPass : public MandatoryPassInfoMixin<LoopPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit LoopPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// Verifier pass for the \c LoopAnalysis results.
-struct LoopVerifierPass : public PassInfoMixin<LoopVerifierPass> {
+struct LoopVerifierPass : public MandatoryPassInfoMixin<LoopVerifierPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// The legacy pass manager's analysis pass to compute loop information.
diff --git a/llvm/include/llvm/Analysis/LoopNestAnalysis.h b/llvm/include/llvm/Analysis/LoopNestAnalysis.h
index 943517c130032..959b86e3fe0c9 100644
--- a/llvm/include/llvm/Analysis/LoopNestAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopNestAnalysis.h
@@ -211,7 +211,7 @@ class LoopNestAnalysis : public AnalysisInfoMixin<LoopNestAnalysis> {
 };
 
 /// Printer pass for the \c LoopNest results.
-class LoopNestPrinterPass : public PassInfoMixin<LoopNestPrinterPass> {
+class LoopNestPrinterPass : public MandatoryPassInfoMixin<LoopNestPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -220,8 +220,6 @@ class LoopNestPrinterPass : public PassInfoMixin<LoopNestPrinterPass> {
   LLVM_ABI PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                                  LoopStandardAnalysisResults &AR,
                                  LPMUpdater &U);
-
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Analysis/MemDerefPrinter.h b/llvm/include/llvm/Analysis/MemDerefPrinter.h
index ba376dadb2a75..c17bd56241a14 100644
--- a/llvm/include/llvm/Analysis/MemDerefPrinter.h
+++ b/llvm/include/llvm/Analysis/MemDerefPrinter.h
@@ -12,13 +12,12 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-class MemDerefPrinterPass : public PassInfoMixin<MemDerefPrinterPass> {
+class MemDerefPrinterPass : public MandatoryPassInfoMixin<MemDerefPrinterPass> {
   raw_ostream &OS;
 
 public:
   MemDerefPrinterPass(raw_ostream &OS) : OS(OS) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/include/llvm/Analysis/MemorySSA.h b/llvm/include/llvm/Analysis/MemorySSA.h
index 9e7e90f004a2d..38b8dd391852b 100644
--- a/llvm/include/llvm/Analysis/MemorySSA.h
+++ b/llvm/include/llvm/Analysis/MemorySSA.h
@@ -943,7 +943,8 @@ class MemorySSAAnalysis : public AnalysisInfoMixin<MemorySSAAnalysis> {
 };
 
 /// Printer pass for \c MemorySSA.
-class MemorySSAPrinterPass : public PassInfoMixin<MemorySSAPrinterPass> {
+class MemorySSAPrinterPass
+    : public MandatoryPassInfoMixin<MemorySSAPrinterPass> {
   raw_ostream &OS;
   bool EnsureOptimizedUses;
 
@@ -952,27 +953,22 @@ class MemorySSAPrinterPass : public PassInfoMixin<MemorySSAPrinterPass> {
       : OS(OS), EnsureOptimizedUses(EnsureOptimizedUses) {}
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Printer pass for \c MemorySSA via the walker.
 class MemorySSAWalkerPrinterPass
-    : public PassInfoMixin<MemorySSAWalkerPrinterPass> {
+    : public MandatoryPassInfoMixin<MemorySSAWalkerPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit MemorySSAWalkerPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Verifier pass for \c MemorySSA.
-struct MemorySSAVerifierPass : PassInfoMixin<MemorySSAVerifierPass> {
+struct MemorySSAVerifierPass : MandatoryPassInfoMixin<MemorySSAVerifierPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// Legacy analysis pass which computes \c MemorySSA.
diff --git a/llvm/include/llvm/Analysis/ModuleDebugInfoPrinter.h b/llvm/include/llvm/Analysis/ModuleDebugInfoPrinter.h
index e69db780a2061..48d64c1b2ca90 100644
--- a/llvm/include/llvm/Analysis/ModuleDebugInfoPrinter.h
+++ b/llvm/include/llvm/Analysis/ModuleDebugInfoPrinter.h
@@ -16,14 +16,13 @@ namespace llvm {
 class raw_ostream;
 
 class ModuleDebugInfoPrinterPass
-    : public PassInfoMixin<ModuleDebugInfoPrinterPass> {
+    : public MandatoryPassInfoMixin<ModuleDebugInfoPrinterPass> {
   DebugInfoFinder Finder;
   raw_ostream &OS;
 
 public:
   explicit ModuleDebugInfoPrinterPass(raw_ostream &OS);
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Analysis/MustExecute.h b/llvm/include/llvm/Analysis/MustExecute.h
index 838f9e645c6c8..2b31cca54d54e 100644
--- a/llvm/include/llvm/Analysis/MustExecute.h
+++ b/llvm/include/llvm/Analysis/MustExecute.h
@@ -543,23 +543,22 @@ struct MustBeExecutedContextExplorer {
   MustBeExecutedIterator EndIterator;
 };
 
-class MustExecutePrinterPass : public PassInfoMixin<MustExecutePrinterPass> {
+class MustExecutePrinterPass
+    : public MandatoryPassInfoMixin<MustExecutePrinterPass> {
   raw_ostream &OS;
 
 public:
   MustExecutePrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 class MustBeExecutedContextPrinterPass
-    : public PassInfoMixin<MustBeExecutedContextPrinterPass> {
+    : public MandatoryPassInfoMixin<MustBeExecutedContextPrinterPass> {
   raw_ostream &OS;
 
 public:
   MustBeExecutedContextPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Analysis/PhiValues.h b/llvm/include/llvm/Analysis/PhiValues.h
index fc51d7b095acc..25347d3c77770 100644
--- a/llvm/include/llvm/Analysis/PhiValues.h
+++ b/llvm/include/llvm/Analysis/PhiValues.h
@@ -127,13 +127,13 @@ class PhiValuesAnalysis : public AnalysisInfoMixin<PhiValuesAnalysis> {
 /// This pass doesn't print whatever information the PhiValues happens to hold,
 /// but instead first uses the PhiValues to analyze all the phis in the function
 /// so the complete information is printed.
-class PhiValuesPrinterPass : public PassInfoMixin<PhiValuesPrinterPass> {
+class PhiValuesPrinterPass
+    : public MandatoryPassInfoMixin<PhiValuesPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit PhiValuesPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// Wrapper pass for the legacy pass manager
diff --git a/llvm/include/llvm/Analysis/PostDominators.h b/llvm/include/llvm/Analysis/PostDominators.h
index 79dc1409919e1..d058f052264a1 100644
--- a/llvm/include/llvm/Analysis/PostDominators.h
+++ b/llvm/include/llvm/Analysis/PostDominators.h
@@ -62,15 +62,13 @@ class PostDominatorTreeAnalysis
 
 /// Printer pass for the \c PostDominatorTree.
 class PostDominatorTreePrinterPass
-    : public PassInfoMixin<PostDominatorTreePrinterPass> {
+    : public MandatoryPassInfoMixin<PostDominatorTreePrinterPass> {
   raw_ostream &OS;
 
 public:
   LLVM_ABI explicit PostDominatorTreePrinterPass(raw_ostream &OS);
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 struct LLVM_ABI PostDominatorTreeWrapperPass : public FunctionPass {
diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
index ef6663efc9df8..2e86aa5482693 100644
--- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
+++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
@@ -387,13 +387,12 @@ class ProfileSummaryAnalysis
 
 /// Printer pass that uses \c ProfileSummaryAnalysis.
 class ProfileSummaryPrinterPass
-    : public PassInfoMixin<ProfileSummaryPrinterPass> {
+    : public MandatoryPassInfoMixin<ProfileSummaryPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit ProfileSummaryPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Analysis/RegionInfo.h b/llvm/include/llvm/Analysis/RegionInfo.h
index 474bd3a9483e7..318e48f862f9b 100644
--- a/llvm/include/llvm/Analysis/RegionInfo.h
+++ b/llvm/include/llvm/Analysis/RegionInfo.h
@@ -974,21 +974,19 @@ class RegionInfoAnalysis : public AnalysisInfoMixin<RegionInfoAnalysis> {
 };
 
 /// Printer pass for the \c RegionInfo.
-class RegionInfoPrinterPass : public PassInfoMixin<RegionInfoPrinterPass> {
+class RegionInfoPrinterPass
+    : public MandatoryPassInfoMixin<RegionInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit RegionInfoPrinterPass(raw_ostream &OS);
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Verifier pass for the \c RegionInfo.
-struct RegionInfoVerifierPass : PassInfoMixin<RegionInfoVerifierPass> {
+struct RegionInfoVerifierPass : MandatoryPassInfoMixin<RegionInfoVerifierPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 template <>
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 5c01da0855f66..4cffe49f79504 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -2547,23 +2547,20 @@ class ScalarEvolutionAnalysis
 
 /// Verifier pass for the \c ScalarEvolutionAnalysis results.
 class ScalarEvolutionVerifierPass
-    : public PassInfoMixin<ScalarEvolutionVerifierPass> {
+    : public MandatoryPassInfoMixin<ScalarEvolutionVerifierPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// Printer pass for the \c ScalarEvolutionAnalysis results.
 class ScalarEvolutionPrinterPass
-    : public PassInfoMixin<ScalarEvolutionPrinterPass> {
+    : public MandatoryPassInfoMixin<ScalarEvolutionPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit ScalarEvolutionPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 class LLVM_ABI ScalarEvolutionWrapperPass : public FunctionPass {
diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionDivision.h b/llvm/include/llvm/Analysis/ScalarEvolutionDivision.h
index d3df7e346b4a5..43f366e6550d4 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolutionDivision.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolutionDivision.h
@@ -82,7 +82,8 @@ struct SCEVDivision : public SCEVVisitor<SCEVDivision, void> {
   const SCEV *Denominator, *Quotient, *Remainder, *Zero, *One;
 };
 
-class SCEVDivisionPrinterPass : public PassInfoMixin<SCEVDivisionPrinterPass> {
+class SCEVDivisionPrinterPass
+    : public OptionalPassInfoMixin<SCEVDivisionPrinterPass> {
   raw_ostream &OS;
   void runImpl(Function &F, ScalarEvolution &SE);
 
diff --git a/llvm/include/llvm/Analysis/StackLifetime.h b/llvm/include/llvm/Analysis/StackLifetime.h
index 13f837a22281a..28edba708bc2a 100644
--- a/llvm/include/llvm/Analysis/StackLifetime.h
+++ b/llvm/include/llvm/Analysis/StackLifetime.h
@@ -180,7 +180,7 @@ inline raw_ostream &operator<<(raw_ostream &OS,
 
 /// Printer pass for testing.
 class StackLifetimePrinterPass
-    : public PassInfoMixin<StackLifetimePrinterPass> {
+    : public MandatoryPassInfoMixin<StackLifetimePrinterPass> {
   StackLifetime::LivenessType Type;
   raw_ostream &OS;
 
@@ -188,7 +188,7 @@ class StackLifetimePrinterPass
   StackLifetimePrinterPass(raw_ostream &OS, StackLifetime::LivenessType Type)
       : Type(Type), OS(OS) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
+
   void printPipeline(raw_ostream &OS,
                      function_ref<StringRef(StringRef)> MapClassName2PassName);
 };
diff --git a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
index b7b816fa4021e..6b6ddd44fbb6d 100644
--- a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
+++ b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
@@ -99,13 +99,13 @@ class StackSafetyAnalysis : public AnalysisInfoMixin<StackSafetyAnalysis> {
 };
 
 /// Printer pass for the \c StackSafetyAnalysis results.
-class StackSafetyPrinterPass : public PassInfoMixin<StackSafetyPrinterPass> {
+class StackSafetyPrinterPass
+    : public MandatoryPassInfoMixin<StackSafetyPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit StackSafetyPrinterPass(raw_ostream &OS) : OS(OS) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// StackSafetyInfo wrapper for the legacy pass manager
@@ -138,13 +138,12 @@ class StackSafetyGlobalAnalysis
 
 /// Printer pass for the \c StackSafetyGlobalAnalysis results.
 class StackSafetyGlobalPrinterPass
-    : public PassInfoMixin<StackSafetyGlobalPrinterPass> {
+    : public MandatoryPassInfoMixin<StackSafetyGlobalPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit StackSafetyGlobalPrinterPass(raw_ostream &OS) : OS(OS) {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// This pass performs the global (interprocedural) stack safety analysis
diff --git a/llvm/include/llvm/Analysis/StructuralHash.h b/llvm/include/llvm/Analysis/StructuralHash.h
index 4c9f063bc7d2c..013fbede3c3ed 100644
--- a/llvm/include/llvm/Analysis/StructuralHash.h
+++ b/llvm/include/llvm/Analysis/StructuralHash.h
@@ -21,7 +21,7 @@ enum class StructuralHashOptions {
 
 /// Printer pass for  StructuralHashes
 class StructuralHashPrinterPass
-    : public PassInfoMixin<StructuralHashPrinterPass> {
+    : public MandatoryPassInfoMixin<StructuralHashPrinterPass> {
   raw_ostream &OS;
   const StructuralHashOptions Options;
 
@@ -31,8 +31,6 @@ class StructuralHashPrinterPass
       : OS(OS), Options(Options) {}
 
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Analysis/UniformityAnalysis.h b/llvm/include/llvm/Analysis/UniformityAnalysis.h
index 15715c837dd23..3c9422353c24e 100644
--- a/llvm/include/llvm/Analysis/UniformityAnalysis.h
+++ b/llvm/include/llvm/Analysis/UniformityAnalysis.h
@@ -42,15 +42,13 @@ class UniformityInfoAnalysis
 
 /// Printer pass for the \c UniformityInfo.
 class UniformityInfoPrinterPass
-    : public PassInfoMixin<UniformityInfoPrinterPass> {
+    : public MandatoryPassInfoMixin<UniformityInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit UniformityInfoPrinterPass(raw_ostream &OS);
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Legacy analysis pass which computes a \ref CycleInfo.
diff --git a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
index 3ce5db4ef1061..af97e5024efe9 100644
--- a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
+++ b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
@@ -40,7 +40,7 @@ LLVM_ABI bool isBitcodeWriterPass(Pass *P);
 ///
 /// Note that this is intended for use with the new pass manager. To construct
 /// a pass for the legacy pass manager, use the function above.
-class BitcodeWriterPass : public PassInfoMixin<BitcodeWriterPass> {
+class BitcodeWriterPass : public MandatoryPassInfoMixin<BitcodeWriterPass> {
   raw_ostream &OS;
   bool ShouldPreserveUseListOrder;
   bool EmitSummaryIndex;
@@ -64,10 +64,7 @@ class BitcodeWriterPass : public PassInfoMixin<BitcodeWriterPass> {
   /// Run the bitcode writer pass, and output the module to the selected
   /// output stream.
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
-
-  static bool isRequired() { return true; }
 };
-
 }
 
 #endif
diff --git a/llvm/include/llvm/CodeGen/AssignmentTrackingAnalysis.h b/llvm/include/llvm/CodeGen/AssignmentTrackingAnalysis.h
index fb0ecd828b68f..4e9f3af2111a7 100644
--- a/llvm/include/llvm/CodeGen/AssignmentTrackingAnalysis.h
+++ b/llvm/include/llvm/CodeGen/AssignmentTrackingAnalysis.h
@@ -113,7 +113,7 @@ class DebugAssignmentTrackingAnalysis
 };
 
 class DebugAssignmentTrackingPrinterPass
-    : public PassInfoMixin<DebugAssignmentTrackingPrinterPass> {
+    : public OptionalPassInfoMixin<DebugAssignmentTrackingPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/AtomicExpand.h b/llvm/include/llvm/CodeGen/AtomicExpand.h
index 34f520f462e96..7b9d44773e83f 100644
--- a/llvm/include/llvm/CodeGen/AtomicExpand.h
+++ b/llvm/include/llvm/CodeGen/AtomicExpand.h
@@ -16,7 +16,7 @@ namespace llvm {
 class Function;
 class TargetMachine;
 
-class AtomicExpandPass : public PassInfoMixin<AtomicExpandPass> {
+class AtomicExpandPass : public OptionalPassInfoMixin<AtomicExpandPass> {
 private:
   const TargetMachine *TM;
 
diff --git a/llvm/include/llvm/CodeGen/BranchFoldingPass.h b/llvm/include/llvm/CodeGen/BranchFoldingPass.h
index ae07be28c5962..80ba50d1a06cf 100644
--- a/llvm/include/llvm/CodeGen/BranchFoldingPass.h
+++ b/llvm/include/llvm/CodeGen/BranchFoldingPass.h
@@ -12,7 +12,7 @@
 
 namespace llvm {
 
-class BranchFolderPass : public PassInfoMixin<BranchFolderPass> {
+class BranchFolderPass : public OptionalPassInfoMixin<BranchFolderPass> {
   bool EnableTailMerge;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/BranchRelaxation.h b/llvm/include/llvm/CodeGen/BranchRelaxation.h
index 2007cf05b3aa1..1a3ab6ad86dfa 100644
--- a/llvm/include/llvm/CodeGen/BranchRelaxation.h
+++ b/llvm/include/llvm/CodeGen/BranchRelaxation.h
@@ -13,11 +13,11 @@
 
 namespace llvm {
 
-class BranchRelaxationPass : public PassInfoMixin<BranchRelaxationPass> {
+class BranchRelaxationPass
+    : public MandatoryPassInfoMixin<BranchRelaxationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/CodeGenPrepare.h b/llvm/include/llvm/CodeGen/CodeGenPrepare.h
index e673d0f5831a0..dee8c5986ec59 100644
--- a/llvm/include/llvm/CodeGen/CodeGenPrepare.h
+++ b/llvm/include/llvm/CodeGen/CodeGenPrepare.h
@@ -21,7 +21,7 @@ namespace llvm {
 class Function;
 class TargetMachine;
 
-class CodeGenPreparePass : public PassInfoMixin<CodeGenPreparePass> {
+class CodeGenPreparePass : public OptionalPassInfoMixin<CodeGenPreparePass> {
 private:
   const TargetMachine *TM;
 
diff --git a/llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h b/llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h
index 7b74f2a8cadc0..d01e530f601db 100644
--- a/llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h
+++ b/llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h
@@ -22,7 +22,7 @@ class Function;
 class TargetMachine;
 
 struct ComplexDeinterleavingPass
-    : public PassInfoMixin<ComplexDeinterleavingPass> {
+    : public OptionalPassInfoMixin<ComplexDeinterleavingPass> {
 private:
   const TargetMachine *TM;
 
diff --git a/llvm/include/llvm/CodeGen/DeadMachineInstructionElim.h b/llvm/include/llvm/CodeGen/DeadMachineInstructionElim.h
index 56cfa1e087181..7881ac020949a 100644
--- a/llvm/include/llvm/CodeGen/DeadMachineInstructionElim.h
+++ b/llvm/include/llvm/CodeGen/DeadMachineInstructionElim.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class DeadMachineInstructionElimPass
-    : public PassInfoMixin<DeadMachineInstructionElimPass> {
+    : public OptionalPassInfoMixin<DeadMachineInstructionElimPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/DetectDeadLanes.h b/llvm/include/llvm/CodeGen/DetectDeadLanes.h
index 5efe65962cf07..2e523c0335d2c 100644
--- a/llvm/include/llvm/CodeGen/DetectDeadLanes.h
+++ b/llvm/include/llvm/CodeGen/DetectDeadLanes.h
@@ -116,11 +116,10 @@ class DeadLaneDetector {
   BitVector DefinedByCopy;
 };
 
-class DetectDeadLanesPass : public PassInfoMixin<DetectDeadLanesPass> {
+class DetectDeadLanesPass : public MandatoryPassInfoMixin<DetectDeadLanesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/CodeGen/DwarfEHPrepare.h b/llvm/include/llvm/CodeGen/DwarfEHPrepare.h
index 5b68b8cf83eb4..e4202928f6b2a 100644
--- a/llvm/include/llvm/CodeGen/DwarfEHPrepare.h
+++ b/llvm/include/llvm/CodeGen/DwarfEHPrepare.h
@@ -20,7 +20,7 @@ namespace llvm {
 
 class TargetMachine;
 
-class DwarfEHPreparePass : public PassInfoMixin<DwarfEHPreparePass> {
+class DwarfEHPreparePass : public OptionalPassInfoMixin<DwarfEHPreparePass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/EarlyIfConversion.h b/llvm/include/llvm/CodeGen/EarlyIfConversion.h
index 78bf12ade02c3..61c9c576af9d0 100644
--- a/llvm/include/llvm/CodeGen/EarlyIfConversion.h
+++ b/llvm/include/llvm/CodeGen/EarlyIfConversion.h
@@ -13,7 +13,8 @@
 
 namespace llvm {
 
-class EarlyIfConverterPass : public PassInfoMixin<EarlyIfConverterPass> {
+class EarlyIfConverterPass
+    : public OptionalPassInfoMixin<EarlyIfConverterPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/ExpandIRInsts.h b/llvm/include/llvm/CodeGen/ExpandIRInsts.h
index 5d3fcf75cd530..18adf05f429bb 100644
--- a/llvm/include/llvm/CodeGen/ExpandIRInsts.h
+++ b/llvm/include/llvm/CodeGen/ExpandIRInsts.h
@@ -16,7 +16,7 @@ namespace llvm {
 
 class TargetMachine;
 
-class ExpandIRInstsPass : public PassInfoMixin<ExpandIRInstsPass> {
+class ExpandIRInstsPass : public MandatoryPassInfoMixin<ExpandIRInstsPass> {
 private:
   const TargetMachine *TM;
   CodeGenOptLevel OptLevel;
@@ -25,7 +25,7 @@ class ExpandIRInstsPass : public PassInfoMixin<ExpandIRInstsPass> {
   explicit ExpandIRInstsPass(const TargetMachine &TM, CodeGenOptLevel OptLevel);
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
+
   void printPipeline(raw_ostream &OS,
                      function_ref<StringRef(StringRef)> MapClassName2PassName);
 };
diff --git a/llvm/include/llvm/CodeGen/ExpandPostRAPseudos.h b/llvm/include/llvm/CodeGen/ExpandPostRAPseudos.h
index 7110be3b3c2b5..79e6c1d6f3167 100644
--- a/llvm/include/llvm/CodeGen/ExpandPostRAPseudos.h
+++ b/llvm/include/llvm/CodeGen/ExpandPostRAPseudos.h
@@ -13,13 +13,13 @@
 
 namespace llvm {
 
-class ExpandPostRAPseudosPass : public PassInfoMixin<ExpandPostRAPseudosPass> {
+class ExpandPostRAPseudosPass
+    : public MandatoryPassInfoMixin<ExpandPostRAPseudosPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
   // We need to expand pseudoinstructions regardless of optimization level or
   // otherwise later passes (e.g., AsmPrinter) will fail.
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/ExpandReductions.h b/llvm/include/llvm/CodeGen/ExpandReductions.h
index 91c2507a9e395..7cb49646bb2c2 100644
--- a/llvm/include/llvm/CodeGen/ExpandReductions.h
+++ b/llvm/include/llvm/CodeGen/ExpandReductions.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class ExpandReductionsPass
-    : public PassInfoMixin<ExpandReductionsPass> {
+    : public OptionalPassInfoMixin<ExpandReductionsPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/CodeGen/FEntryInserter.h b/llvm/include/llvm/CodeGen/FEntryInserter.h
index 4a82975cad879..6160217ccd381 100644
--- a/llvm/include/llvm/CodeGen/FEntryInserter.h
+++ b/llvm/include/llvm/CodeGen/FEntryInserter.h
@@ -13,11 +13,10 @@
 
 namespace llvm {
 
-class FEntryInserterPass : public PassInfoMixin<FEntryInserterPass> {
+class FEntryInserterPass : public MandatoryPassInfoMixin<FEntryInserterPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/FinalizeISel.h b/llvm/include/llvm/CodeGen/FinalizeISel.h
index b2c28e330126f..4fc06ef76b4e1 100644
--- a/llvm/include/llvm/CodeGen/FinalizeISel.h
+++ b/llvm/include/llvm/CodeGen/FinalizeISel.h
@@ -13,10 +13,9 @@
 
 namespace llvm {
 
-class FinalizeISelPass : public PassInfoMixin<FinalizeISelPass> {
+class FinalizeISelPass : public MandatoryPassInfoMixin<FinalizeISelPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/FixupStatepointCallerSaved.h b/llvm/include/llvm/CodeGen/FixupStatepointCallerSaved.h
index 43c40340032ce..8f0a7f34bdcec 100644
--- a/llvm/include/llvm/CodeGen/FixupStatepointCallerSaved.h
+++ b/llvm/include/llvm/CodeGen/FixupStatepointCallerSaved.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class FixupStatepointCallerSavedPass
-    : public PassInfoMixin<FixupStatepointCallerSavedPass> {
+    : public OptionalPassInfoMixin<FixupStatepointCallerSavedPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/GCEmptyBasicBlocks.h b/llvm/include/llvm/CodeGen/GCEmptyBasicBlocks.h
index a795ece07cdf5..dbd476d60c546 100644
--- a/llvm/include/llvm/CodeGen/GCEmptyBasicBlocks.h
+++ b/llvm/include/llvm/CodeGen/GCEmptyBasicBlocks.h
@@ -13,7 +13,8 @@
 
 namespace llvm {
 
-class GCEmptyBasicBlocksPass : public PassInfoMixin<GCEmptyBasicBlocksPass> {
+class GCEmptyBasicBlocksPass
+    : public OptionalPassInfoMixin<GCEmptyBasicBlocksPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/GCMetadata.h b/llvm/include/llvm/CodeGen/GCMetadata.h
index 5b9ee2869aa1b..dc69887686c46 100644
--- a/llvm/include/llvm/CodeGen/GCMetadata.h
+++ b/llvm/include/llvm/CodeGen/GCMetadata.h
@@ -226,7 +226,7 @@ class GCFunctionAnalysis : public AnalysisInfoMixin<GCFunctionAnalysis> {
 /// and custom intrinsic lowering.
 ///
 /// This pass requires `CollectorMetadataAnalysis`.
-class GCLoweringPass : public PassInfoMixin<GCLoweringPass> {
+class GCLoweringPass : public OptionalPassInfoMixin<GCLoweringPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h b/llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h
index 5b6cb05553bc9..02f9df7425623 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h
@@ -193,7 +193,7 @@ class GISelValueTrackingAnalysis
 };
 
 class GISelValueTrackingPrinterPass
-    : public PassInfoMixin<GISelValueTrackingPrinterPass> {
+    : public OptionalPassInfoMixin<GISelValueTrackingPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/GlobalMerge.h b/llvm/include/llvm/CodeGen/GlobalMerge.h
index 2220e5cfff5fb..960b355b4d3ea 100644
--- a/llvm/include/llvm/CodeGen/GlobalMerge.h
+++ b/llvm/include/llvm/CodeGen/GlobalMerge.h
@@ -40,7 +40,7 @@ struct GlobalMergeOptions {
 };
 
 // FIXME: This pass must run before AsmPrinterPass::doInitialization!
-class GlobalMergePass : public PassInfoMixin<GlobalMergePass> {
+class GlobalMergePass : public OptionalPassInfoMixin<GlobalMergePass> {
   const TargetMachine *TM;
   GlobalMergeOptions Options;
 
diff --git a/llvm/include/llvm/CodeGen/GlobalMergeFunctions.h b/llvm/include/llvm/CodeGen/GlobalMergeFunctions.h
index 54ea68a418846..1142c313d710d 100644
--- a/llvm/include/llvm/CodeGen/GlobalMergeFunctions.h
+++ b/llvm/include/llvm/CodeGen/GlobalMergeFunctions.h
@@ -77,7 +77,7 @@ class GlobalMergeFunc {
 };
 
 /// Global function merging pass for new pass manager.
-struct GlobalMergeFuncPass : public PassInfoMixin<GlobalMergeFuncPass> {
+struct GlobalMergeFuncPass : public OptionalPassInfoMixin<GlobalMergeFuncPass> {
   const ModuleSummaryIndex *ImportSummary = nullptr;
   GlobalMergeFuncPass() = default;
   GlobalMergeFuncPass(const ModuleSummaryIndex *ImportSummary)
diff --git a/llvm/include/llvm/CodeGen/HardwareLoops.h b/llvm/include/llvm/CodeGen/HardwareLoops.h
index c7b6e0f5ae567..100255efc273a 100644
--- a/llvm/include/llvm/CodeGen/HardwareLoops.h
+++ b/llvm/include/llvm/CodeGen/HardwareLoops.h
@@ -61,7 +61,7 @@ struct HardwareLoopOptions {
   }
 };
 
-class HardwareLoopsPass : public PassInfoMixin<HardwareLoopsPass> {
+class HardwareLoopsPass : public OptionalPassInfoMixin<HardwareLoopsPass> {
   HardwareLoopOptions Opts;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/IndirectBrExpand.h b/llvm/include/llvm/CodeGen/IndirectBrExpand.h
index 572a712fc28fe..47ba7327280a1 100644
--- a/llvm/include/llvm/CodeGen/IndirectBrExpand.h
+++ b/llvm/include/llvm/CodeGen/IndirectBrExpand.h
@@ -15,7 +15,8 @@ namespace llvm {
 
 class TargetMachine;
 
-class IndirectBrExpandPass : public PassInfoMixin<IndirectBrExpandPass> {
+class IndirectBrExpandPass
+    : public OptionalPassInfoMixin<IndirectBrExpandPass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/InitUndef.h b/llvm/include/llvm/CodeGen/InitUndef.h
index c4359afccfa00..a4399b2b25fa7 100644
--- a/llvm/include/llvm/CodeGen/InitUndef.h
+++ b/llvm/include/llvm/CodeGen/InitUndef.h
@@ -13,11 +13,10 @@
 
 namespace llvm {
 
-class InitUndefPass : public PassInfoMixin<InitUndefPass> {
+class InitUndefPass : public MandatoryPassInfoMixin<InitUndefPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/InlineAsmPrepare.h b/llvm/include/llvm/CodeGen/InlineAsmPrepare.h
index a400a78390dff..1ded964b03b9c 100644
--- a/llvm/include/llvm/CodeGen/InlineAsmPrepare.h
+++ b/llvm/include/llvm/CodeGen/InlineAsmPrepare.h
@@ -13,7 +13,8 @@
 
 namespace llvm {
 
-class InlineAsmPreparePass : public PassInfoMixin<InlineAsmPreparePass> {
+class InlineAsmPreparePass
+    : public OptionalPassInfoMixin<InlineAsmPreparePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
diff --git a/llvm/include/llvm/CodeGen/InterleavedAccess.h b/llvm/include/llvm/CodeGen/InterleavedAccess.h
index 42bfa84ddc26d..2a004227724aa 100644
--- a/llvm/include/llvm/CodeGen/InterleavedAccess.h
+++ b/llvm/include/llvm/CodeGen/InterleavedAccess.h
@@ -21,7 +21,8 @@ namespace llvm {
 
 class TargetMachine;
 
-class InterleavedAccessPass : public PassInfoMixin<InterleavedAccessPass> {
+class InterleavedAccessPass
+    : public OptionalPassInfoMixin<InterleavedAccessPass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/InterleavedLoadCombine.h b/llvm/include/llvm/CodeGen/InterleavedLoadCombine.h
index 2750fd42bbfc8..0118361c3f7db 100644
--- a/llvm/include/llvm/CodeGen/InterleavedLoadCombine.h
+++ b/llvm/include/llvm/CodeGen/InterleavedLoadCombine.h
@@ -16,7 +16,7 @@ namespace llvm {
 class TargetMachine;
 
 class InterleavedLoadCombinePass
-    : public PassInfoMixin<InterleavedLoadCombinePass> {
+    : public OptionalPassInfoMixin<InterleavedLoadCombinePass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/JMCInstrumenter.h b/llvm/include/llvm/CodeGen/JMCInstrumenter.h
index addac1654826c..ee2d78c6cd922 100644
--- a/llvm/include/llvm/CodeGen/JMCInstrumenter.h
+++ b/llvm/include/llvm/CodeGen/JMCInstrumenter.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class JMCInstrumenterPass : public PassInfoMixin<JMCInstrumenterPass> {
+class JMCInstrumenterPass : public OptionalPassInfoMixin<JMCInstrumenterPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h b/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h
index db8c233f15f64..5e15c315a0c7c 100644
--- a/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h
+++ b/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class LiveDebugValuesPass : public PassInfoMixin<LiveDebugValuesPass> {
+class LiveDebugValuesPass : public OptionalPassInfoMixin<LiveDebugValuesPass> {
   const bool ShouldEmitDebugEntryValues;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/LiveDebugVariables.h b/llvm/include/llvm/CodeGen/LiveDebugVariables.h
index 9d737a8f66c92..de008cfe767af 100644
--- a/llvm/include/llvm/CodeGen/LiveDebugVariables.h
+++ b/llvm/include/llvm/CodeGen/LiveDebugVariables.h
@@ -108,7 +108,7 @@ class LiveDebugVariablesAnalysis
 };
 
 class LiveDebugVariablesPrinterPass
-    : public PassInfoMixin<LiveDebugVariablesPrinterPass> {
+    : public OptionalPassInfoMixin<LiveDebugVariablesPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/LiveIntervals.h b/llvm/include/llvm/CodeGen/LiveIntervals.h
index e79d5b32eae42..ec4a04d4bbc95 100644
--- a/llvm/include/llvm/CodeGen/LiveIntervals.h
+++ b/llvm/include/llvm/CodeGen/LiveIntervals.h
@@ -528,14 +528,13 @@ class LiveIntervalsAnalysis : public AnalysisInfoMixin<LiveIntervalsAnalysis> {
 };
 
 class LiveIntervalsPrinterPass
-    : public PassInfoMixin<LiveIntervalsPrinterPass> {
+    : public MandatoryPassInfoMixin<LiveIntervalsPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit LiveIntervalsPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 class LLVM_ABI LiveIntervalsWrapperPass : public MachineFunctionPass {
diff --git a/llvm/include/llvm/CodeGen/LiveStacks.h b/llvm/include/llvm/CodeGen/LiveStacks.h
index 04ff4584182b8..5eda0b13cd3fd 100644
--- a/llvm/include/llvm/CodeGen/LiveStacks.h
+++ b/llvm/include/llvm/CodeGen/LiveStacks.h
@@ -124,7 +124,8 @@ class LiveStacksAnalysis : public AnalysisInfoMixin<LiveStacksAnalysis> {
   LiveStacks run(MachineFunction &MF, MachineFunctionAnalysisManager &);
 };
 
-class LiveStacksPrinterPass : public PassInfoMixin<LiveStacksPrinterPass> {
+class LiveStacksPrinterPass
+    : public OptionalPassInfoMixin<LiveStacksPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/LiveVariables.h b/llvm/include/llvm/CodeGen/LiveVariables.h
index f51834f44baad..c667a1cff4ec9 100644
--- a/llvm/include/llvm/CodeGen/LiveVariables.h
+++ b/llvm/include/llvm/CodeGen/LiveVariables.h
@@ -310,14 +310,13 @@ class LiveVariablesAnalysis : public AnalysisInfoMixin<LiveVariablesAnalysis> {
 };
 
 class LiveVariablesPrinterPass
-    : public PassInfoMixin<LiveVariablesPrinterPass> {
+    : public MandatoryPassInfoMixin<LiveVariablesPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit LiveVariablesPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 class LLVM_ABI LiveVariablesWrapperPass : public MachineFunctionPass {
diff --git a/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h b/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
index b02667d5c6699..8eebe6c60125a 100644
--- a/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
+++ b/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
@@ -14,10 +14,9 @@
 namespace llvm {
 
 class LocalStackSlotAllocationPass
-    : public PassInfoMixin<LocalStackSlotAllocationPass> {
+    : public MandatoryPassInfoMixin<LocalStackSlotAllocationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/LowerEmuTLS.h b/llvm/include/llvm/CodeGen/LowerEmuTLS.h
index ecd1352a89f42..75aec168223d4 100644
--- a/llvm/include/llvm/CodeGen/LowerEmuTLS.h
+++ b/llvm/include/llvm/CodeGen/LowerEmuTLS.h
@@ -19,7 +19,7 @@
 
 namespace llvm {
 
-class LowerEmuTLSPass : public PassInfoMixin<LowerEmuTLSPass> {
+class LowerEmuTLSPass : public OptionalPassInfoMixin<LowerEmuTLSPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/include/llvm/CodeGen/MIRPrinter.h b/llvm/include/llvm/CodeGen/MIRPrinter.h
index c8c8b12e559da..df2c3d124a1c7 100644
--- a/llvm/include/llvm/CodeGen/MIRPrinter.h
+++ b/llvm/include/llvm/CodeGen/MIRPrinter.h
@@ -26,23 +26,21 @@ class MachineModuleInfo;
 class Module;
 template <typename T> class SmallVectorImpl;
 
-class PrintMIRPreparePass : public PassInfoMixin<PrintMIRPreparePass> {
+class PrintMIRPreparePass : public MandatoryPassInfoMixin<PrintMIRPreparePass> {
   raw_ostream &OS;
 
 public:
   PrintMIRPreparePass(raw_ostream &OS = errs()) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
-class PrintMIRPass : public PassInfoMixin<PrintMIRPass> {
+class PrintMIRPass : public MandatoryPassInfoMixin<PrintMIRPass> {
   raw_ostream &OS;
 
 public:
   PrintMIRPass(raw_ostream &OS = errs()) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 /// Print LLVM IR using the MIR serialization format to the given output stream.
diff --git a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
index 794075201d646..ba789e3acce86 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
@@ -125,7 +125,7 @@ class MachineBlockFrequencyAnalysis
 
 /// Printer pass for the \c MachineBlockFrequencyInfo results.
 class MachineBlockFrequencyPrinterPass
-    : public PassInfoMixin<MachineBlockFrequencyPrinterPass> {
+    : public MandatoryPassInfoMixin<MachineBlockFrequencyPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -133,8 +133,6 @@ class MachineBlockFrequencyPrinterPass
 
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-
-  static bool isRequired() { return true; }
 };
 
 class LLVM_ABI MachineBlockFrequencyInfoWrapperPass
diff --git a/llvm/include/llvm/CodeGen/MachineBlockPlacement.h b/llvm/include/llvm/CodeGen/MachineBlockPlacement.h
index f88e72c2a177b..5e630e4e79d72 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockPlacement.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockPlacement.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class MachineBlockPlacementPass
-    : public PassInfoMixin<MachineBlockPlacementPass> {
+    : public MandatoryPassInfoMixin<MachineBlockPlacementPass> {
 
   bool AllowTailMerge = true;
 
@@ -23,7 +23,6 @@ class MachineBlockPlacementPass
       : AllowTailMerge(AllowTailMerge) {}
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 
   void
   printPipeline(raw_ostream &OS,
@@ -31,12 +30,11 @@ class MachineBlockPlacementPass
 };
 
 class MachineBlockPlacementStatsPass
-    : public PassInfoMixin<MachineBlockPlacementStatsPass> {
+    : public MandatoryPassInfoMixin<MachineBlockPlacementStatsPass> {
 
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/MachineBranchProbabilityInfo.h b/llvm/include/llvm/CodeGen/MachineBranchProbabilityInfo.h
index df02a3e7918c4..6780d2dbd0a7d 100644
--- a/llvm/include/llvm/CodeGen/MachineBranchProbabilityInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBranchProbabilityInfo.h
@@ -66,7 +66,7 @@ class MachineBranchProbabilityAnalysis
 };
 
 class MachineBranchProbabilityPrinterPass
-    : public PassInfoMixin<MachineBranchProbabilityPrinterPass> {
+    : public OptionalPassInfoMixin<MachineBranchProbabilityPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineCSE.h b/llvm/include/llvm/CodeGen/MachineCSE.h
index b2b0d414ae673..47390108ff45e 100644
--- a/llvm/include/llvm/CodeGen/MachineCSE.h
+++ b/llvm/include/llvm/CodeGen/MachineCSE.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class MachineCSEPass : public PassInfoMixin<MachineCSEPass> {
+class MachineCSEPass : public OptionalPassInfoMixin<MachineCSEPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/MachineCopyPropagation.h b/llvm/include/llvm/CodeGen/MachineCopyPropagation.h
index 8355752e747c0..0e2298ac65c50 100644
--- a/llvm/include/llvm/CodeGen/MachineCopyPropagation.h
+++ b/llvm/include/llvm/CodeGen/MachineCopyPropagation.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class MachineCopyPropagationPass
-    : public PassInfoMixin<MachineCopyPropagationPass> {
+    : public OptionalPassInfoMixin<MachineCopyPropagationPass> {
   bool UseCopyInstr;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h b/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
index 67d87a111e03a..dac1d909ab211 100644
--- a/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
@@ -63,14 +63,13 @@ class MachineCycleAnalysis : public AnalysisInfoMixin<MachineCycleAnalysis> {
 };
 
 class MachineCycleInfoPrinterPass
-    : public PassInfoMixin<MachineCycleInfoPrinterPass> {
+    : public MandatoryPassInfoMixin<MachineCycleInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit MachineCycleInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/CodeGen/MachineDominators.h b/llvm/include/llvm/CodeGen/MachineDominators.h
index faea0b7de525f..36103ccbaba2e 100644
--- a/llvm/include/llvm/CodeGen/MachineDominators.h
+++ b/llvm/include/llvm/CodeGen/MachineDominators.h
@@ -112,14 +112,13 @@ class MachineDominatorTreeAnalysis
 
 /// \brief Machine function pass which print \c MachineDominatorTree.
 class MachineDominatorTreePrinterPass
-    : public PassInfoMixin<MachineDominatorTreePrinterPass> {
+    : public MandatoryPassInfoMixin<MachineDominatorTreePrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit MachineDominatorTreePrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 /// \brief Analysis pass which computes a \c MachineDominatorTree.
diff --git a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
index bea1c7893c136..b8372de4f94f0 100644
--- a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
@@ -46,7 +46,8 @@ class MachineFunctionAnalysis
   LLVM_ABI Result run(Function &F, FunctionAnalysisManager &FAM);
 };
 
-class FreeMachineFunctionPass : public PassInfoMixin<FreeMachineFunctionPass> {
+class FreeMachineFunctionPass
+    : public OptionalPassInfoMixin<FreeMachineFunctionPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
diff --git a/llvm/include/llvm/CodeGen/MachineInstrBundle.h b/llvm/include/llvm/CodeGen/MachineInstrBundle.h
index 6c5063fb1f063..a581b6ef270b1 100644
--- a/llvm/include/llvm/CodeGen/MachineInstrBundle.h
+++ b/llvm/include/llvm/CodeGen/MachineInstrBundle.h
@@ -295,14 +295,15 @@ LLVM_ABI PhysRegInfo AnalyzePhysRegInBundle(const MachineInstr &MI,
                                             Register Reg,
                                             const TargetRegisterInfo *TRI);
 
-class FinalizeBundleTestPass : public PassInfoMixin<FinalizeBundleTestPass> {
+class FinalizeBundleTestPass
+    : public OptionalPassInfoMixin<FinalizeBundleTestPass> {
 public:
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
 };
 
 class UnpackMachineBundlesPass
-    : public PassInfoMixin<UnpackMachineBundlesPass> {
+    : public OptionalPassInfoMixin<UnpackMachineBundlesPass> {
 
 public:
   UnpackMachineBundlesPass(
diff --git a/llvm/include/llvm/CodeGen/MachineLICM.h b/llvm/include/llvm/CodeGen/MachineLICM.h
index a4078b55353bb..d1890519cca57 100644
--- a/llvm/include/llvm/CodeGen/MachineLICM.h
+++ b/llvm/include/llvm/CodeGen/MachineLICM.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 template <typename DerivedT, bool PreRegAlloc>
-class MachineLICMBasePass : public PassInfoMixin<DerivedT> {
+class MachineLICMBasePass : public OptionalPassInfoMixin<DerivedT> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/MachineLateInstrsCleanup.h b/llvm/include/llvm/CodeGen/MachineLateInstrsCleanup.h
index 8562e1ad38a7e..053fdfba31150 100644
--- a/llvm/include/llvm/CodeGen/MachineLateInstrsCleanup.h
+++ b/llvm/include/llvm/CodeGen/MachineLateInstrsCleanup.h
@@ -13,7 +13,7 @@
 namespace llvm {
 
 class MachineLateInstrsCleanupPass
-    : public PassInfoMixin<MachineLateInstrsCleanupPass> {
+    : public OptionalPassInfoMixin<MachineLateInstrsCleanupPass> {
 public:
   PreservedAnalyses run(MachineFunction &MachineFunction,
                         MachineFunctionAnalysisManager &MachineFunctionAM);
diff --git a/llvm/include/llvm/CodeGen/MachineLoopInfo.h b/llvm/include/llvm/CodeGen/MachineLoopInfo.h
index bcec6df39e73c..ebe3d59ca877b 100644
--- a/llvm/include/llvm/CodeGen/MachineLoopInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineLoopInfo.h
@@ -148,14 +148,14 @@ class MachineLoopAnalysis : public AnalysisInfoMixin<MachineLoopAnalysis> {
 };
 
 /// Printer pass for the \c LoopAnalysis results.
-class MachineLoopPrinterPass : public PassInfoMixin<MachineLoopPrinterPass> {
+class MachineLoopPrinterPass
+    : public MandatoryPassInfoMixin<MachineLoopPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit MachineLoopPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 class LLVM_ABI MachineLoopInfoWrapperPass : public MachineFunctionPass {
diff --git a/llvm/include/llvm/CodeGen/MachinePassManager.h b/llvm/include/llvm/CodeGen/MachinePassManager.h
index f7b888e45a7ec..4ff1756b8bae9 100644
--- a/llvm/include/llvm/CodeGen/MachinePassManager.h
+++ b/llvm/include/llvm/CodeGen/MachinePassManager.h
@@ -189,7 +189,7 @@ class FunctionAnalysisManagerMachineFunctionProxy
 };
 
 class FunctionToMachineFunctionPassAdaptor
-    : public PassInfoMixin<FunctionToMachineFunctionPassAdaptor> {
+    : public MandatoryPassInfoMixin<FunctionToMachineFunctionPassAdaptor> {
 public:
   using PassConceptT =
       detail::PassConcept<MachineFunction, MachineFunctionAnalysisManager>;
@@ -204,8 +204,6 @@ class FunctionToMachineFunctionPassAdaptor
   printPipeline(raw_ostream &OS,
                 function_ref<StringRef(StringRef)> MapClassName2PassName);
 
-  static bool isRequired() { return true; }
-
 private:
   std::unique_ptr<PassConceptT> Pass;
 };
diff --git a/llvm/include/llvm/CodeGen/MachinePostDominators.h b/llvm/include/llvm/CodeGen/MachinePostDominators.h
index 8b7c9690d6c8d..a1b7730c1af21 100644
--- a/llvm/include/llvm/CodeGen/MachinePostDominators.h
+++ b/llvm/include/llvm/CodeGen/MachinePostDominators.h
@@ -81,14 +81,13 @@ class MachinePostDominatorTreeAnalysis
 };
 
 class MachinePostDominatorTreePrinterPass
-    : public PassInfoMixin<MachinePostDominatorTreePrinterPass> {
+    : public MandatoryPassInfoMixin<MachinePostDominatorTreePrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit MachinePostDominatorTreePrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 class LLVM_ABI MachinePostDominatorTreeWrapperPass
diff --git a/llvm/include/llvm/CodeGen/MachineScheduler.h b/llvm/include/llvm/CodeGen/MachineScheduler.h
index 0c7efd8ab1d8f..f7faa3e6f31a6 100644
--- a/llvm/include/llvm/CodeGen/MachineScheduler.h
+++ b/llvm/include/llvm/CodeGen/MachineScheduler.h
@@ -1455,7 +1455,8 @@ ScheduleDAGMI *createSchedPostRA(MachineSchedContext *C) {
   return DAG;
 }
 
-class MachineSchedulerPass : public PassInfoMixin<MachineSchedulerPass> {
+class MachineSchedulerPass
+    : public OptionalPassInfoMixin<MachineSchedulerPass> {
   // FIXME: Remove this member once RegisterClassInfo is queryable as an
   // analysis.
   std::unique_ptr<impl_detail::MachineSchedulerImpl> Impl;
@@ -1470,7 +1471,7 @@ class MachineSchedulerPass : public PassInfoMixin<MachineSchedulerPass> {
 };
 
 class PostMachineSchedulerPass
-    : public PassInfoMixin<PostMachineSchedulerPass> {
+    : public OptionalPassInfoMixin<PostMachineSchedulerPass> {
   // FIXME: Remove this member once RegisterClassInfo is queryable as an
   // analysis.
   std::unique_ptr<impl_detail::PostMachineSchedulerImpl> Impl;
diff --git a/llvm/include/llvm/CodeGen/MachineSink.h b/llvm/include/llvm/CodeGen/MachineSink.h
index 71bd7229b7598..d6160995ded25 100644
--- a/llvm/include/llvm/CodeGen/MachineSink.h
+++ b/llvm/include/llvm/CodeGen/MachineSink.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class MachineSinkingPass : public PassInfoMixin<MachineSinkingPass> {
+class MachineSinkingPass : public OptionalPassInfoMixin<MachineSinkingPass> {
   bool EnableSinkAndFold;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineTraceMetrics.h b/llvm/include/llvm/CodeGen/MachineTraceMetrics.h
index b29984cd95a4b..b21313013fca7 100644
--- a/llvm/include/llvm/CodeGen/MachineTraceMetrics.h
+++ b/llvm/include/llvm/CodeGen/MachineTraceMetrics.h
@@ -462,10 +462,9 @@ class MachineTraceMetricsAnalysis
 
 /// Verifier pass for \c MachineTraceMetrics.
 struct MachineTraceMetricsVerifierPass
-    : PassInfoMixin<MachineTraceMetricsVerifierPass> {
+    : MandatoryPassInfoMixin<MachineTraceMetricsVerifierPass> {
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 class MachineTraceMetricsWrapperPass : public MachineFunctionPass {
diff --git a/llvm/include/llvm/CodeGen/MachineUniformityAnalysis.h b/llvm/include/llvm/CodeGen/MachineUniformityAnalysis.h
index ad37204f12534..4c16c2be21df8 100644
--- a/llvm/include/llvm/CodeGen/MachineUniformityAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineUniformityAnalysis.h
@@ -64,14 +64,13 @@ class MachineUniformityAnalysis
 };
 
 class MachineUniformityPrinterPass
-    : public PassInfoMixin<MachineUniformityAnalysis> {
+    : public MandatoryPassInfoMixin<MachineUniformityPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit MachineUniformityPrinterPass(raw_ostream &OS) : OS(OS) {}
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/MachineVerifier.h b/llvm/include/llvm/CodeGen/MachineVerifier.h
index 22a1caff52f06..f6520ef78dda2 100644
--- a/llvm/include/llvm/CodeGen/MachineVerifier.h
+++ b/llvm/include/llvm/CodeGen/MachineVerifier.h
@@ -14,7 +14,7 @@
 #include <string>
 
 namespace llvm {
-class MachineVerifierPass : public PassInfoMixin<MachineVerifierPass> {
+class MachineVerifierPass : public MandatoryPassInfoMixin<MachineVerifierPass> {
   std::string Banner;
 
 public:
@@ -22,7 +22,6 @@ class MachineVerifierPass : public PassInfoMixin<MachineVerifierPass> {
       : Banner(Banner) {}
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/OptimizePHIs.h b/llvm/include/llvm/CodeGen/OptimizePHIs.h
index ca64ad98a985b..e944daf77feb9 100644
--- a/llvm/include/llvm/CodeGen/OptimizePHIs.h
+++ b/llvm/include/llvm/CodeGen/OptimizePHIs.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class OptimizePHIsPass : public PassInfoMixin<OptimizePHIsPass> {
+class OptimizePHIsPass : public OptionalPassInfoMixin<OptimizePHIsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/PEI.h b/llvm/include/llvm/CodeGen/PEI.h
index 95503b7861b39..f78f75e2dd05c 100644
--- a/llvm/include/llvm/CodeGen/PEI.h
+++ b/llvm/include/llvm/CodeGen/PEI.h
@@ -14,12 +14,10 @@
 namespace llvm {
 
 class PrologEpilogInserterPass
-    : public PassInfoMixin<PrologEpilogInserterPass> {
+    : public MandatoryPassInfoMixin<PrologEpilogInserterPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/PHIElimination.h b/llvm/include/llvm/CodeGen/PHIElimination.h
index d3c884b8413c7..84d8c67076be9 100644
--- a/llvm/include/llvm/CodeGen/PHIElimination.h
+++ b/llvm/include/llvm/CodeGen/PHIElimination.h
@@ -13,11 +13,10 @@
 
 namespace llvm {
 
-class PHIEliminationPass : public PassInfoMixin<PHIEliminationPass> {
+class PHIEliminationPass : public MandatoryPassInfoMixin<PHIEliminationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/PatchableFunction.h b/llvm/include/llvm/CodeGen/PatchableFunction.h
index 095e159010b6c..7872f3a21bd85 100644
--- a/llvm/include/llvm/CodeGen/PatchableFunction.h
+++ b/llvm/include/llvm/CodeGen/PatchableFunction.h
@@ -13,7 +13,8 @@
 
 namespace llvm {
 
-class PatchableFunctionPass : public PassInfoMixin<PatchableFunctionPass> {
+class PatchableFunctionPass
+    : public MandatoryPassInfoMixin<PatchableFunctionPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -21,7 +22,6 @@ class PatchableFunctionPass : public PassInfoMixin<PatchableFunctionPass> {
   MachineFunctionProperties getRequiredProperties() const {
     return MachineFunctionProperties().setNoVRegs();
   }
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/PeepholeOptimizer.h b/llvm/include/llvm/CodeGen/PeepholeOptimizer.h
index 7f57e6dc35779..1b334edbfe8cb 100644
--- a/llvm/include/llvm/CodeGen/PeepholeOptimizer.h
+++ b/llvm/include/llvm/CodeGen/PeepholeOptimizer.h
@@ -13,7 +13,8 @@
 
 namespace llvm {
 
-class PeepholeOptimizerPass : public PassInfoMixin<PeepholeOptimizerPass> {
+class PeepholeOptimizerPass
+    : public OptionalPassInfoMixin<PeepholeOptimizerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/PostRAHazardRecognizer.h b/llvm/include/llvm/CodeGen/PostRAHazardRecognizer.h
index 3e0c04ac5e403..4523304eebe21 100644
--- a/llvm/include/llvm/CodeGen/PostRAHazardRecognizer.h
+++ b/llvm/include/llvm/CodeGen/PostRAHazardRecognizer.h
@@ -14,11 +14,10 @@
 namespace llvm {
 
 class PostRAHazardRecognizerPass
-    : public PassInfoMixin<PostRAHazardRecognizerPass> {
+    : public MandatoryPassInfoMixin<PostRAHazardRecognizerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/PostRAMachineSink.h b/llvm/include/llvm/CodeGen/PostRAMachineSink.h
index 4ab088f17cafc..26aaadfed4d2c 100644
--- a/llvm/include/llvm/CodeGen/PostRAMachineSink.h
+++ b/llvm/include/llvm/CodeGen/PostRAMachineSink.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class PostRAMachineSinkingPass
-    : public PassInfoMixin<PostRAMachineSinkingPass> {
+    : public OptionalPassInfoMixin<PostRAMachineSinkingPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/PostRASchedulerList.h b/llvm/include/llvm/CodeGen/PostRASchedulerList.h
index e450dc8101078..75f3e8a1ac23e 100644
--- a/llvm/include/llvm/CodeGen/PostRASchedulerList.h
+++ b/llvm/include/llvm/CodeGen/PostRASchedulerList.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class PostRASchedulerPass : public PassInfoMixin<PostRASchedulerPass> {
+class PostRASchedulerPass : public OptionalPassInfoMixin<PostRASchedulerPass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/PreISelIntrinsicLowering.h b/llvm/include/llvm/CodeGen/PreISelIntrinsicLowering.h
index 955a2437cb94c..c163402b37775 100644
--- a/llvm/include/llvm/CodeGen/PreISelIntrinsicLowering.h
+++ b/llvm/include/llvm/CodeGen/PreISelIntrinsicLowering.h
@@ -21,7 +21,7 @@ class Module;
 class TargetMachine;
 
 struct PreISelIntrinsicLoweringPass
-    : PassInfoMixin<PreISelIntrinsicLoweringPass> {
+    : OptionalPassInfoMixin<PreISelIntrinsicLoweringPass> {
   const TargetMachine *TM;
 
   PreISelIntrinsicLoweringPass(const TargetMachine *TM) : TM(TM) {}
diff --git a/llvm/include/llvm/CodeGen/ProcessImplicitDefs.h b/llvm/include/llvm/CodeGen/ProcessImplicitDefs.h
index 12a97d3efec66..964d7e169ba05 100644
--- a/llvm/include/llvm/CodeGen/ProcessImplicitDefs.h
+++ b/llvm/include/llvm/CodeGen/ProcessImplicitDefs.h
@@ -13,7 +13,8 @@
 
 namespace llvm {
 
-class ProcessImplicitDefsPass : public PassInfoMixin<ProcessImplicitDefsPass> {
+class ProcessImplicitDefsPass
+    : public OptionalPassInfoMixin<ProcessImplicitDefsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
index b6ca1d6e9b328..5e617cf537863 100644
--- a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
+++ b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
@@ -325,7 +325,8 @@ class ReachingDefAnalysis : public AnalysisInfoMixin<ReachingDefAnalysis> {
 };
 
 /// Printer pass for the \c ReachingDefInfo results.
-class ReachingDefPrinterPass : public PassInfoMixin<ReachingDefPrinterPass> {
+class ReachingDefPrinterPass
+    : public MandatoryPassInfoMixin<ReachingDefPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -333,8 +334,6 @@ class ReachingDefPrinterPass : public PassInfoMixin<ReachingDefPrinterPass> {
 
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-
-  static bool isRequired() { return true; }
 };
 
 class ReachingDefInfoWrapperPass : public MachineFunctionPass {
diff --git a/llvm/include/llvm/CodeGen/RegAllocFast.h b/llvm/include/llvm/CodeGen/RegAllocFast.h
index d3a13e22fc8b1..4f18b3a77beea 100644
--- a/llvm/include/llvm/CodeGen/RegAllocFast.h
+++ b/llvm/include/llvm/CodeGen/RegAllocFast.h
@@ -14,7 +14,7 @@
 
 namespace llvm {
 
-class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
+class RegAllocFastPass : public MandatoryPassInfoMixin<RegAllocFastPass> {
 public:
   struct Options {
     RegAllocFilterFunc Filter;
@@ -48,8 +48,6 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
   void printPipeline(raw_ostream &OS,
                      function_ref<StringRef(StringRef)> MapClassName2PassName);
 
-  static bool isRequired() { return true; }
-
 private:
   Options Opts;
 };
diff --git a/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h b/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
index 6b34ee3ff2543..28518a1153955 100644
--- a/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
+++ b/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
@@ -15,7 +15,7 @@
 
 using namespace llvm;
 
-class RAGreedyPass : public PassInfoMixin<RAGreedyPass> {
+class RAGreedyPass : public MandatoryPassInfoMixin<RAGreedyPass> {
 public:
   struct Options {
     RegAllocFilterFunc Filter;
@@ -38,7 +38,6 @@ class RAGreedyPass : public PassInfoMixin<RAGreedyPass> {
   void
   printPipeline(raw_ostream &OS,
                 function_ref<StringRef(StringRef)> MapClassName2PassName) const;
-  static bool isRequired() { return true; }
 
 private:
   Options Opts;
diff --git a/llvm/include/llvm/CodeGen/RegUsageInfoPropagate.h b/llvm/include/llvm/CodeGen/RegUsageInfoPropagate.h
index 73624015e37d9..3b030b1f1a7df 100644
--- a/llvm/include/llvm/CodeGen/RegUsageInfoPropagate.h
+++ b/llvm/include/llvm/CodeGen/RegUsageInfoPropagate.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class RegUsageInfoPropagationPass
-    : public PassInfoMixin<RegUsageInfoPropagationPass> {
+    : public OptionalPassInfoMixin<RegUsageInfoPropagationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/RegisterCoalescerPass.h b/llvm/include/llvm/CodeGen/RegisterCoalescerPass.h
index 7211d1e79306e..55bc6b8397ccf 100644
--- a/llvm/include/llvm/CodeGen/RegisterCoalescerPass.h
+++ b/llvm/include/llvm/CodeGen/RegisterCoalescerPass.h
@@ -12,7 +12,8 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class RegisterCoalescerPass : public PassInfoMixin<RegisterCoalescerPass> {
+class RegisterCoalescerPass
+    : public OptionalPassInfoMixin<RegisterCoalescerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/RegisterUsageInfo.h b/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
index 9a1d9a4a47120..6be03151eb259 100644
--- a/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
+++ b/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
@@ -96,13 +96,12 @@ class PhysicalRegisterUsageAnalysis
 };
 
 class PhysicalRegisterUsageInfoPrinterPass
-    : public PassInfoMixin<PhysicalRegisterUsageInfoPrinterPass> {
+    : public MandatoryPassInfoMixin<PhysicalRegisterUsageInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit PhysicalRegisterUsageInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/CodeGen/RemoveLoadsIntoFakeUses.h b/llvm/include/llvm/CodeGen/RemoveLoadsIntoFakeUses.h
index 70cd2fe0c3cc4..62b2a7ed71dd8 100644
--- a/llvm/include/llvm/CodeGen/RemoveLoadsIntoFakeUses.h
+++ b/llvm/include/llvm/CodeGen/RemoveLoadsIntoFakeUses.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class RemoveLoadsIntoFakeUsesPass
-    : public PassInfoMixin<RemoveLoadsIntoFakeUsesPass> {
+    : public OptionalPassInfoMixin<RemoveLoadsIntoFakeUsesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/RemoveRedundantDebugValues.h b/llvm/include/llvm/CodeGen/RemoveRedundantDebugValues.h
index 7d6dfa9bb830d..8a60e0f107e12 100644
--- a/llvm/include/llvm/CodeGen/RemoveRedundantDebugValues.h
+++ b/llvm/include/llvm/CodeGen/RemoveRedundantDebugValues.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class RemoveRedundantDebugValuesPass
-    : public PassInfoMixin<RemoveRedundantDebugValuesPass> {
+    : public OptionalPassInfoMixin<RemoveRedundantDebugValuesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/RenameIndependentSubregs.h b/llvm/include/llvm/CodeGen/RenameIndependentSubregs.h
index 2f6afe6bea620..2419eaaf7a19b 100644
--- a/llvm/include/llvm/CodeGen/RenameIndependentSubregs.h
+++ b/llvm/include/llvm/CodeGen/RenameIndependentSubregs.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class RenameIndependentSubregsPass
-    : public PassInfoMixin<RenameIndependentSubregsPass> {
+    : public OptionalPassInfoMixin<RenameIndependentSubregsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/ReplaceWithVeclib.h b/llvm/include/llvm/CodeGen/ReplaceWithVeclib.h
index 785d298a8c5f1..770fd4618570c 100644
--- a/llvm/include/llvm/CodeGen/ReplaceWithVeclib.h
+++ b/llvm/include/llvm/CodeGen/ReplaceWithVeclib.h
@@ -21,7 +21,7 @@
 
 namespace llvm {
 class Function;
-struct ReplaceWithVeclib : public PassInfoMixin<ReplaceWithVeclib> {
+struct ReplaceWithVeclib : public OptionalPassInfoMixin<ReplaceWithVeclib> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/CodeGen/SafeStack.h b/llvm/include/llvm/CodeGen/SafeStack.h
index 05ad40e6c68c5..fd917c83f6dac 100644
--- a/llvm/include/llvm/CodeGen/SafeStack.h
+++ b/llvm/include/llvm/CodeGen/SafeStack.h
@@ -15,7 +15,7 @@ namespace llvm {
 
 class TargetMachine;
 
-class SafeStackPass : public PassInfoMixin<SafeStackPass> {
+class SafeStackPass : public OptionalPassInfoMixin<SafeStackPass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/SanitizerBinaryMetadata.h b/llvm/include/llvm/CodeGen/SanitizerBinaryMetadata.h
index 6cf2e11aa911e..6568ea59aefe4 100644
--- a/llvm/include/llvm/CodeGen/SanitizerBinaryMetadata.h
+++ b/llvm/include/llvm/CodeGen/SanitizerBinaryMetadata.h
@@ -14,11 +14,10 @@
 namespace llvm {
 
 class MachineSanitizerBinaryMetadataPass
-    : public PassInfoMixin<MachineSanitizerBinaryMetadataPass> {
+    : public MandatoryPassInfoMixin<MachineSanitizerBinaryMetadataPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/SelectOptimize.h b/llvm/include/llvm/CodeGen/SelectOptimize.h
index 33f66bb16c4de..76e73cb615c32 100644
--- a/llvm/include/llvm/CodeGen/SelectOptimize.h
+++ b/llvm/include/llvm/CodeGen/SelectOptimize.h
@@ -21,7 +21,7 @@ namespace llvm {
 
 class TargetMachine;
 
-class SelectOptimizePass : public PassInfoMixin<SelectOptimizePass> {
+class SelectOptimizePass : public OptionalPassInfoMixin<SelectOptimizePass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
index 58f141bbc4862..10b844063aa0f 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
@@ -581,7 +581,8 @@ class SelectionDAGISelLegacy : public MachineFunctionPass {
   bool runOnMachineFunction(MachineFunction &MF) override;
 };
 
-class SelectionDAGISelPass : public PassInfoMixin<SelectionDAGISelPass> {
+class SelectionDAGISelPass
+    : public MandatoryPassInfoMixin<SelectionDAGISelPass> {
   std::unique_ptr<SelectionDAGISel> Selector;
 
 protected:
@@ -591,7 +592,6 @@ class SelectionDAGISelPass : public PassInfoMixin<SelectionDAGISelPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 }
 
diff --git a/llvm/include/llvm/CodeGen/ShadowStackGCLowering.h b/llvm/include/llvm/CodeGen/ShadowStackGCLowering.h
index 1586c6cf545bf..432662f5883f5 100644
--- a/llvm/include/llvm/CodeGen/ShadowStackGCLowering.h
+++ b/llvm/include/llvm/CodeGen/ShadowStackGCLowering.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class ShadowStackGCLoweringPass
-    : public PassInfoMixin<ShadowStackGCLoweringPass> {
+    : public OptionalPassInfoMixin<ShadowStackGCLoweringPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/include/llvm/CodeGen/ShrinkWrap.h b/llvm/include/llvm/CodeGen/ShrinkWrap.h
index 805924be306e8..54ce1185724ab 100644
--- a/llvm/include/llvm/CodeGen/ShrinkWrap.h
+++ b/llvm/include/llvm/CodeGen/ShrinkWrap.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class ShrinkWrapPass : public PassInfoMixin<ShrinkWrapPass> {
+class ShrinkWrapPass : public OptionalPassInfoMixin<ShrinkWrapPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/SjLjEHPrepare.h b/llvm/include/llvm/CodeGen/SjLjEHPrepare.h
index c1fd680ff8afa..99899d94dfcc9 100644
--- a/llvm/include/llvm/CodeGen/SjLjEHPrepare.h
+++ b/llvm/include/llvm/CodeGen/SjLjEHPrepare.h
@@ -15,7 +15,7 @@ namespace llvm {
 
 class TargetMachine;
 
-class SjLjEHPreparePass : public PassInfoMixin<SjLjEHPreparePass> {
+class SjLjEHPreparePass : public OptionalPassInfoMixin<SjLjEHPreparePass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h
index 6d897e427cf79..cc5dc0d344c2b 100644
--- a/llvm/include/llvm/CodeGen/SlotIndexes.h
+++ b/llvm/include/llvm/CodeGen/SlotIndexes.h
@@ -659,14 +659,14 @@ class raw_ostream;
     LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &);
   };
 
-  class SlotIndexesPrinterPass : public PassInfoMixin<SlotIndexesPrinterPass> {
+  class SlotIndexesPrinterPass
+      : public MandatoryPassInfoMixin<SlotIndexesPrinterPass> {
     raw_ostream &OS;
 
   public:
     explicit SlotIndexesPrinterPass(raw_ostream &OS) : OS(OS) {}
     LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                    MachineFunctionAnalysisManager &MFAM);
-    static bool isRequired() { return true; }
   };
 
   class LLVM_ABI SlotIndexesWrapperPass : public MachineFunctionPass {
diff --git a/llvm/include/llvm/CodeGen/StackColoring.h b/llvm/include/llvm/CodeGen/StackColoring.h
index 65f8916f42a91..0d020981cc04b 100644
--- a/llvm/include/llvm/CodeGen/StackColoring.h
+++ b/llvm/include/llvm/CodeGen/StackColoring.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class StackColoringPass : public PassInfoMixin<StackColoringPass> {
+class StackColoringPass : public OptionalPassInfoMixin<StackColoringPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/StackFrameLayoutAnalysisPass.h b/llvm/include/llvm/CodeGen/StackFrameLayoutAnalysisPass.h
index 5283cda30da12..5909e2f227046 100644
--- a/llvm/include/llvm/CodeGen/StackFrameLayoutAnalysisPass.h
+++ b/llvm/include/llvm/CodeGen/StackFrameLayoutAnalysisPass.h
@@ -14,11 +14,10 @@
 namespace llvm {
 
 class StackFrameLayoutAnalysisPass
-    : public PassInfoMixin<StackFrameLayoutAnalysisPass> {
+    : public MandatoryPassInfoMixin<StackFrameLayoutAnalysisPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/StackProtector.h b/llvm/include/llvm/CodeGen/StackProtector.h
index fbe79353b9c33..6e336ccf45aca 100644
--- a/llvm/include/llvm/CodeGen/StackProtector.h
+++ b/llvm/include/llvm/CodeGen/StackProtector.h
@@ -82,7 +82,7 @@ class SSPLayoutAnalysis : public AnalysisInfoMixin<SSPLayoutAnalysis> {
                                      SSPLayoutMap *Layout = nullptr);
 };
 
-class StackProtectorPass : public PassInfoMixin<StackProtectorPass> {
+class StackProtectorPass : public OptionalPassInfoMixin<StackProtectorPass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/StackSlotColoring.h b/llvm/include/llvm/CodeGen/StackSlotColoring.h
index 8db59a339280d..ee6bfc739ada7 100644
--- a/llvm/include/llvm/CodeGen/StackSlotColoring.h
+++ b/llvm/include/llvm/CodeGen/StackSlotColoring.h
@@ -13,7 +13,8 @@
 
 namespace llvm {
 
-class StackSlotColoringPass : public PassInfoMixin<StackSlotColoringPass> {
+class StackSlotColoringPass
+    : public OptionalPassInfoMixin<StackSlotColoringPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/TailDuplication.h b/llvm/include/llvm/CodeGen/TailDuplication.h
index d1cc4b0d065f0..b40f8d93ea089 100644
--- a/llvm/include/llvm/CodeGen/TailDuplication.h
+++ b/llvm/include/llvm/CodeGen/TailDuplication.h
@@ -16,7 +16,7 @@
 namespace llvm {
 
 template <typename DerivedT, bool PreRegAlloc>
-class TailDuplicatePassBase : public PassInfoMixin<DerivedT> {
+class TailDuplicatePassBase : public OptionalPassInfoMixin<DerivedT> {
 private:
   std::unique_ptr<MBFIWrapper> MBFIW;
 
diff --git a/llvm/include/llvm/CodeGen/TwoAddressInstructionPass.h b/llvm/include/llvm/CodeGen/TwoAddressInstructionPass.h
index a51c7c99d9bb3..2383404ba35c8 100644
--- a/llvm/include/llvm/CodeGen/TwoAddressInstructionPass.h
+++ b/llvm/include/llvm/CodeGen/TwoAddressInstructionPass.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class TwoAddressInstructionPass
-    : public PassInfoMixin<TwoAddressInstructionPass> {
+    : public OptionalPassInfoMixin<TwoAddressInstructionPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/TypePromotion.h b/llvm/include/llvm/CodeGen/TypePromotion.h
index ba32a21066257..455b79f3c5cbd 100644
--- a/llvm/include/llvm/CodeGen/TypePromotion.h
+++ b/llvm/include/llvm/CodeGen/TypePromotion.h
@@ -21,7 +21,7 @@ namespace llvm {
 class Function;
 class TargetMachine;
 
-class TypePromotionPass : public PassInfoMixin<TypePromotionPass> {
+class TypePromotionPass : public OptionalPassInfoMixin<TypePromotionPass> {
 private:
   const TargetMachine *TM;
 
diff --git a/llvm/include/llvm/CodeGen/UnreachableBlockElim.h b/llvm/include/llvm/CodeGen/UnreachableBlockElim.h
index 3c2b701512df6..df47af488ba60 100644
--- a/llvm/include/llvm/CodeGen/UnreachableBlockElim.h
+++ b/llvm/include/llvm/CodeGen/UnreachableBlockElim.h
@@ -28,13 +28,13 @@
 namespace llvm {
 
 class UnreachableBlockElimPass
-    : public PassInfoMixin<UnreachableBlockElimPass> {
+    : public OptionalPassInfoMixin<UnreachableBlockElimPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 class UnreachableMachineBlockElimPass
-    : public PassInfoMixin<UnreachableMachineBlockElimPass> {
+    : public OptionalPassInfoMixin<UnreachableMachineBlockElimPass> {
 public:
   PreservedAnalyses run(MachineFunction &F, MachineFunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/CodeGen/VirtRegMap.h b/llvm/include/llvm/CodeGen/VirtRegMap.h
index 405ae3905ebe5..10466de9cb2e0 100644
--- a/llvm/include/llvm/CodeGen/VirtRegMap.h
+++ b/llvm/include/llvm/CodeGen/VirtRegMap.h
@@ -228,17 +228,17 @@ class VirtRegMapAnalysis : public AnalysisInfoMixin<VirtRegMapAnalysis> {
                           MachineFunctionAnalysisManager &MAM);
 };
 
-class VirtRegMapPrinterPass : public PassInfoMixin<VirtRegMapPrinterPass> {
+class VirtRegMapPrinterPass
+    : public MandatoryPassInfoMixin<VirtRegMapPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit VirtRegMapPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
-class VirtRegRewriterPass : public PassInfoMixin<VirtRegRewriterPass> {
+class VirtRegRewriterPass : public MandatoryPassInfoMixin<VirtRegRewriterPass> {
   bool ClearVirtRegs = true;
 
 public:
@@ -247,8 +247,6 @@ class VirtRegRewriterPass : public PassInfoMixin<VirtRegRewriterPass> {
   LLVM_ABI PreservedAnalyses run(MachineFunction &MF,
                                  MachineFunctionAnalysisManager &MFAM);
 
-  static bool isRequired() { return true; }
-
   LLVM_ABI void printPipeline(raw_ostream &OS,
                               function_ref<StringRef(StringRef)>) const;
 
diff --git a/llvm/include/llvm/CodeGen/WasmEHPrepare.h b/llvm/include/llvm/CodeGen/WasmEHPrepare.h
index 8b3c07573a0d3..90a26c322bfb9 100644
--- a/llvm/include/llvm/CodeGen/WasmEHPrepare.h
+++ b/llvm/include/llvm/CodeGen/WasmEHPrepare.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class WasmEHPreparePass : public PassInfoMixin<WasmEHPreparePass> {
+class WasmEHPreparePass : public OptionalPassInfoMixin<WasmEHPreparePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
diff --git a/llvm/include/llvm/CodeGen/WinEHPrepare.h b/llvm/include/llvm/CodeGen/WinEHPrepare.h
index 0a47934d6126b..dc99f59351d84 100644
--- a/llvm/include/llvm/CodeGen/WinEHPrepare.h
+++ b/llvm/include/llvm/CodeGen/WinEHPrepare.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class WinEHPreparePass : public PassInfoMixin<WinEHPreparePass> {
+class WinEHPreparePass : public OptionalPassInfoMixin<WinEHPreparePass> {
   bool DemoteCatchSwitchPHIOnly;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/XRayInstrumentation.h b/llvm/include/llvm/CodeGen/XRayInstrumentation.h
index cc65d61627fc0..bfb38fffbec0d 100644
--- a/llvm/include/llvm/CodeGen/XRayInstrumentation.h
+++ b/llvm/include/llvm/CodeGen/XRayInstrumentation.h
@@ -13,11 +13,11 @@
 
 namespace llvm {
 
-class XRayInstrumentationPass : public PassInfoMixin<XRayInstrumentationPass> {
+class XRayInstrumentationPass
+    : public MandatoryPassInfoMixin<XRayInstrumentationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h
index cb8f6fa1b132b..c966f1b8726f9 100644
--- a/llvm/include/llvm/IR/DebugInfo.h
+++ b/llvm/include/llvm/IR/DebugInfo.h
@@ -323,7 +323,8 @@ LLVM_ABI std::optional<AssignmentInfo> getAssignmentInfo(const DataLayout &DL,
 /// be left with their dbg.declare intrinsics.
 /// The pass sets the debug-info-assignment-tracking module flag to true to
 /// indicate assignment tracking has been enabled.
-class AssignmentTrackingPass : public PassInfoMixin<AssignmentTrackingPass> {
+class AssignmentTrackingPass
+    : public OptionalPassInfoMixin<AssignmentTrackingPass> {
   /// Note: this method does not set the debug-info-assignment-tracking module
   /// flag.
   bool runOnFunction(Function &F);
diff --git a/llvm/include/llvm/IR/Dominators.h b/llvm/include/llvm/IR/Dominators.h
index d860c1453bd73..a846eba903a61 100644
--- a/llvm/include/llvm/IR/Dominators.h
+++ b/llvm/include/llvm/IR/Dominators.h
@@ -289,21 +289,19 @@ class DominatorTreeAnalysis : public AnalysisInfoMixin<DominatorTreeAnalysis> {
 
 /// Printer pass for the \c DominatorTree.
 class DominatorTreePrinterPass
-    : public PassInfoMixin<DominatorTreePrinterPass> {
+    : public MandatoryPassInfoMixin<DominatorTreePrinterPass> {
   raw_ostream &OS;
 
 public:
   LLVM_ABI explicit DominatorTreePrinterPass(raw_ostream &OS);
 
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 /// Verifier pass for the \c DominatorTree.
-struct DominatorTreeVerifierPass : PassInfoMixin<DominatorTreeVerifierPass> {
+struct DominatorTreeVerifierPass
+    : MandatoryPassInfoMixin<DominatorTreeVerifierPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// Enables verification of dominator trees.
diff --git a/llvm/include/llvm/IR/PassInstrumentation.h b/llvm/include/llvm/IR/PassInstrumentation.h
index c25e2891d33d5..a7ecd3aa5e2a4 100644
--- a/llvm/include/llvm/IR/PassInstrumentation.h
+++ b/llvm/include/llvm/IR/PassInstrumentation.h
@@ -212,13 +212,8 @@ class PassInstrumentation {
   // created from (1). Here we want to make case (1) skippable unconditionally
   // since they are regular passes. We call PassConcept::isRequired to decide
   // for case (2).
-  template <typename PassT>
-  using has_required_t = decltype(std::declval<PassT &>().isRequired());
-
   template <typename PassT> static bool isRequired(const PassT &Pass) {
-    if constexpr (is_detected<has_required_t, PassT>::value)
-      return Pass.isRequired();
-    return false;
+    return Pass.isRequired();
   }
 
 public:
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index 4d4c4bcfe943d..6fc1a307f97ce 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -67,6 +67,9 @@ template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
 /// passes.
 ///
 /// This provides some boilerplate for types that are passes.
+///
+/// Actual passes should inherit from MandatoryPassInfoMixin or
+/// OptionalPassInfoMixin.
 template <typename DerivedT> struct PassInfoMixin {
   /// Gets the name of the pass we are mixed into.
   static StringRef name() {
@@ -83,6 +86,21 @@ template <typename DerivedT> struct PassInfoMixin {
     auto PassName = MapClassName2PassName(ClassName);
     OS << PassName;
   }
+
+  // TODO: remove once out of tree users are updated.
+  static bool isRequired() { return false; }
+};
+
+/// A CRTP mix-in for passes that should not be skipped.
+template <typename DerivedT>
+struct MandatoryPassInfoMixin : PassInfoMixin<DerivedT> {
+  static bool isRequired() { return true; }
+};
+
+/// A CRTP mix-in for passes that can be skipped.
+template <typename DerivedT>
+struct OptionalPassInfoMixin : PassInfoMixin<DerivedT> {
+  static bool isRequired() { return false; }
 };
 
 /// A CRTP mix-in that provides informational APIs needed for analysis passes.
@@ -90,7 +108,7 @@ template <typename DerivedT> struct PassInfoMixin {
 /// This provides some boilerplate for types that are analysis passes. It
 /// automatically mixes in \c PassInfoMixin.
 template <typename DerivedT>
-struct AnalysisInfoMixin : PassInfoMixin<DerivedT> {
+struct AnalysisInfoMixin : OptionalPassInfoMixin<DerivedT> {
   /// Returns an opaque, unique ID for this analysis type.
   ///
   /// This ID is a pointer type that is guaranteed to be 8-byte aligned and thus
@@ -159,7 +177,7 @@ getAnalysisResult(AnalysisManager<IRUnitT, AnalysisArgTs...> &AM, IRUnitT &IR,
 template <typename IRUnitT,
           typename AnalysisManagerT = AnalysisManager<IRUnitT>,
           typename... ExtraArgTs>
-class PassManager : public PassInfoMixin<
+class PassManager : public MandatoryPassInfoMixin<
                         PassManager<IRUnitT, AnalysisManagerT, ExtraArgTs...>> {
 public:
   /// Construct a pass manager.
@@ -216,8 +234,6 @@ class PassManager : public PassInfoMixin<
   /// Returns if the pass manager contains any passes.
   bool isEmpty() const { return Passes.empty(); }
 
-  static bool isRequired() { return true; }
-
 protected:
   using PassConceptT =
       detail::PassConcept<IRUnitT, AnalysisManagerT, ExtraArgTs...>;
@@ -848,7 +864,7 @@ using ModuleAnalysisManagerFunctionProxy =
 /// analyses are not invalidated while the function passes are running, so they
 /// may be stale.  Function analyses will not be stale.
 class ModuleToFunctionPassAdaptor
-    : public PassInfoMixin<ModuleToFunctionPassAdaptor> {
+    : public MandatoryPassInfoMixin<ModuleToFunctionPassAdaptor> {
 public:
   using PassConceptT = detail::PassConcept<Function, FunctionAnalysisManager>;
 
@@ -862,8 +878,6 @@ class ModuleToFunctionPassAdaptor
   printPipeline(raw_ostream &OS,
                 function_ref<StringRef(StringRef)> MapClassName2PassName);
 
-  static bool isRequired() { return true; }
-
 private:
   std::unique_ptr<PassConceptT> Pass;
   bool EagerlyInvalidate;
@@ -898,8 +912,8 @@ template <typename AnalysisT, typename IRUnitT,
           typename AnalysisManagerT = AnalysisManager<IRUnitT>,
           typename... ExtraArgTs>
 struct RequireAnalysisPass
-    : PassInfoMixin<RequireAnalysisPass<AnalysisT, IRUnitT, AnalysisManagerT,
-                                        ExtraArgTs...>> {
+    : MandatoryPassInfoMixin<RequireAnalysisPass<
+          AnalysisT, IRUnitT, AnalysisManagerT, ExtraArgTs...>> {
   /// Run this pass over some unit of IR.
   ///
   /// This pass can be run over any unit of IR and use any analysis manager
@@ -919,14 +933,13 @@ struct RequireAnalysisPass
     auto PassName = MapClassName2PassName(ClassName);
     OS << "require<" << PassName << '>';
   }
-  static bool isRequired() { return true; }
 };
 
 /// A no-op pass template which simply forces a specific analysis result
 /// to be invalidated.
 template <typename AnalysisT>
 struct InvalidateAnalysisPass
-    : PassInfoMixin<InvalidateAnalysisPass<AnalysisT>> {
+    : MandatoryPassInfoMixin<InvalidateAnalysisPass<AnalysisT>> {
   /// Run this pass over some unit of IR.
   ///
   /// This pass can be run over any unit of IR and use any analysis manager,
@@ -951,7 +964,8 @@ struct InvalidateAnalysisPass
 ///
 /// Because this preserves no analyses, any analysis passes queried after this
 /// pass runs will recompute fresh results.
-struct InvalidateAllAnalysesPass : PassInfoMixin<InvalidateAllAnalysesPass> {
+struct InvalidateAllAnalysesPass
+    : MandatoryPassInfoMixin<InvalidateAllAnalysesPass> {
   /// Run this pass over some unit of IR.
   template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
   PreservedAnalyses run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...) {
diff --git a/llvm/include/llvm/IR/PassManagerInternal.h b/llvm/include/llvm/IR/PassManagerInternal.h
index 2f84ae24383e9..da55722cc6716 100644
--- a/llvm/include/llvm/IR/PassManagerInternal.h
+++ b/llvm/include/llvm/IR/PassManagerInternal.h
@@ -57,8 +57,10 @@ struct PassConcept {
 
   /// Polymorphic method to let a pass optionally exempted from skipping by
   /// PassInstrumentation.
-  /// To opt-in, pass should implement `static bool isRequired()`. It's no-op
-  /// to have `isRequired` always return false since that is the default.
+  /// To opt-in, pass should implement `static bool isRequired()`, or inherit
+  /// from `MandatoryPassInfoMixin` or `OptionalPassInfoMixin`.
+  /// It's no-op to have `isRequired` always return false since that is the
+  /// default.
   virtual bool isRequired() const = 0;
 };
 
@@ -99,16 +101,7 @@ struct PassModel : PassConcept<IRUnitT, AnalysisManagerT, ExtraArgTs...> {
 
   StringRef name() const override { return PassT::name(); }
 
-  template <typename T>
-  using has_required_t = decltype(std::declval<T &>().isRequired());
-
-  template <typename T> static bool passIsRequiredImpl() {
-    if constexpr (is_detected<has_required_t, T>::value)
-      return T::isRequired();
-    return false;
-  }
-
-  bool isRequired() const override { return passIsRequiredImpl<PassT>(); }
+  bool isRequired() const override { return PassT::isRequired(); }
 
   PassT Pass;
 };
diff --git a/llvm/include/llvm/IR/SafepointIRVerifier.h b/llvm/include/llvm/IR/SafepointIRVerifier.h
index 2ee998e4c68ff..aa1e1e51db78c 100644
--- a/llvm/include/llvm/IR/SafepointIRVerifier.h
+++ b/llvm/include/llvm/IR/SafepointIRVerifier.h
@@ -34,14 +34,13 @@ FunctionPass *createSafepointIRVerifierPass();
 
 /// Create an instance of the safepoint verifier pass which can be added to
 /// a pass pipeline to check for relocation bugs.
-class SafepointIRVerifierPass : public PassInfoMixin<SafepointIRVerifierPass> {
+class SafepointIRVerifierPass
+    : public MandatoryPassInfoMixin<SafepointIRVerifierPass> {
 
 public:
   explicit SafepointIRVerifierPass() = default;
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 }
 
diff --git a/llvm/include/llvm/IR/Verifier.h b/llvm/include/llvm/IR/Verifier.h
index b15b4d8ca99fe..19b2d42437437 100644
--- a/llvm/include/llvm/IR/Verifier.h
+++ b/llvm/include/llvm/IR/Verifier.h
@@ -131,7 +131,7 @@ class VerifierAnalysis : public AnalysisInfoMixin<VerifierAnalysis> {
 ///
 /// Note that this creates a pass suitable for the legacy pass manager. It has
 /// nothing to do with \c VerifierPass.
-class VerifierPass : public PassInfoMixin<VerifierPass> {
+class VerifierPass : public MandatoryPassInfoMixin<VerifierPass> {
   bool FatalErrors;
 
 public:
@@ -139,7 +139,6 @@ class VerifierPass : public PassInfoMixin<VerifierPass> {
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/IRPrinter/IRPrintingPasses.h b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
index 0d5dd1124733e..b1f1e4c87f48a 100644
--- a/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
+++ b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
@@ -30,7 +30,7 @@ class Pass;
 
 /// Pass (for the new pass manager) for printing a Module as
 /// LLVM's text IR assembly.
-class PrintModulePass : public PassInfoMixin<PrintModulePass> {
+class PrintModulePass : public MandatoryPassInfoMixin<PrintModulePass> {
   raw_ostream &OS;
   std::string Banner;
   bool ShouldPreserveUseListOrder;
@@ -43,12 +43,11 @@ class PrintModulePass : public PassInfoMixin<PrintModulePass> {
                            bool EmitSummaryIndex = false);
 
   LLVM_ABI PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
-  static bool isRequired() { return true; }
 };
 
 /// Pass (for the new pass manager) for printing a Function as
 /// LLVM's text IR assembly.
-class PrintFunctionPass : public PassInfoMixin<PrintFunctionPass> {
+class PrintFunctionPass : public MandatoryPassInfoMixin<PrintFunctionPass> {
   raw_ostream &OS;
   std::string Banner;
 
@@ -57,7 +56,6 @@ class PrintFunctionPass : public PassInfoMixin<PrintFunctionPass> {
   LLVM_ABI PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
 
   LLVM_ABI PreservedAnalyses run(Function &F, AnalysisManager<Function> &);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 42625b6ea0229..b7a44df238871 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -131,21 +131,21 @@ namespace llvm {
 // FIXME: Dummy target independent passes definitions that have not yet been
 // ported to new pass manager. Once they do, remove these.
 #define DUMMY_FUNCTION_PASS(NAME, PASS_NAME)                                   \
-  struct PASS_NAME : public PassInfoMixin<PASS_NAME> {                         \
+  struct PASS_NAME : public OptionalPassInfoMixin<PASS_NAME> {                 \
     template <typename... Ts> PASS_NAME(Ts &&...) {}                           \
     PreservedAnalyses run(Function &, FunctionAnalysisManager &) {             \
       return PreservedAnalyses::all();                                         \
     }                                                                          \
   };
 #define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME)                             \
-  struct PASS_NAME : public PassInfoMixin<PASS_NAME> {                         \
+  struct PASS_NAME : public OptionalPassInfoMixin<PASS_NAME> {                 \
     template <typename... Ts> PASS_NAME(Ts &&...) {}                           \
     PreservedAnalyses run(Module &, ModuleAnalysisManager &) {                 \
       return PreservedAnalyses::all();                                         \
     }                                                                          \
   };
 #define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME)                           \
-  struct PASS_NAME : public PassInfoMixin<PASS_NAME> {                         \
+  struct PASS_NAME : public OptionalPassInfoMixin<PASS_NAME> {                 \
     template <typename... Ts> PASS_NAME(Ts &&...) {}                           \
     PreservedAnalyses run(MachineFunction &,                                   \
                           MachineFunctionAnalysisManager &) {                  \
diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h
index 00d4874d5109b..83d5dbbed751c 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -910,7 +910,7 @@ bool parseAnalysisUtilityPasses(
 // These are special since they are only for testing purposes.
 
 /// No-op module pass which does nothing.
-struct NoOpModulePass : PassInfoMixin<NoOpModulePass> {
+struct NoOpModulePass : OptionalPassInfoMixin<NoOpModulePass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &) {
     return PreservedAnalyses::all();
   }
@@ -927,7 +927,7 @@ class NoOpModuleAnalysis : public AnalysisInfoMixin<NoOpModuleAnalysis> {
 };
 
 /// No-op CGSCC pass which does nothing.
-struct NoOpCGSCCPass : PassInfoMixin<NoOpCGSCCPass> {
+struct NoOpCGSCCPass : OptionalPassInfoMixin<NoOpCGSCCPass> {
   PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &,
                         LazyCallGraph &, CGSCCUpdateResult &UR) {
     return PreservedAnalyses::all();
@@ -947,7 +947,7 @@ class NoOpCGSCCAnalysis : public AnalysisInfoMixin<NoOpCGSCCAnalysis> {
 };
 
 /// No-op function pass which does nothing.
-struct NoOpFunctionPass : PassInfoMixin<NoOpFunctionPass> {
+struct NoOpFunctionPass : OptionalPassInfoMixin<NoOpFunctionPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &) {
     return PreservedAnalyses::all();
   }
@@ -964,7 +964,7 @@ class NoOpFunctionAnalysis : public AnalysisInfoMixin<NoOpFunctionAnalysis> {
 };
 
 /// No-op loop nest pass which does nothing.
-struct NoOpLoopNestPass : PassInfoMixin<NoOpLoopNestPass> {
+struct NoOpLoopNestPass : OptionalPassInfoMixin<NoOpLoopNestPass> {
   PreservedAnalyses run(LoopNest &L, LoopAnalysisManager &,
                         LoopStandardAnalysisResults &, LPMUpdater &) {
     return PreservedAnalyses::all();
@@ -972,7 +972,7 @@ struct NoOpLoopNestPass : PassInfoMixin<NoOpLoopNestPass> {
 };
 
 /// No-op loop pass which does nothing.
-struct NoOpLoopPass : PassInfoMixin<NoOpLoopPass> {
+struct NoOpLoopPass : OptionalPassInfoMixin<NoOpLoopPass> {
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &,
                         LoopStandardAnalysisResults &, LPMUpdater &) {
     return PreservedAnalyses::all();
@@ -980,7 +980,8 @@ struct NoOpLoopPass : PassInfoMixin<NoOpLoopPass> {
 };
 
 /// No-op machine function pass which does nothing.
-struct NoOpMachineFunctionPass : public PassInfoMixin<NoOpMachineFunctionPass> {
+struct NoOpMachineFunctionPass
+    : public OptionalPassInfoMixin<NoOpMachineFunctionPass> {
   PreservedAnalyses run(MachineFunction &, MachineFunctionAnalysisManager &) {
     return PreservedAnalyses::all();
   }
diff --git a/llvm/include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h b/llvm/include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h
index 3568417510f10..ad358a2dadd13 100644
--- a/llvm/include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h
+++ b/llvm/include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h
@@ -20,7 +20,7 @@
 namespace llvm {
 
 class AggressiveInstCombinePass
-    : public PassInfoMixin<AggressiveInstCombinePass> {
+    : public OptionalPassInfoMixin<AggressiveInstCombinePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/CFGuard.h b/llvm/include/llvm/Transforms/CFGuard.h
index 175d62851f363..542c92a64ff40 100644
--- a/llvm/include/llvm/Transforms/CFGuard.h
+++ b/llvm/include/llvm/Transforms/CFGuard.h
@@ -20,7 +20,7 @@ class CallBase;
 class FunctionPass;
 class GlobalValue;
 
-class CFGuardPass : public PassInfoMixin<CFGuardPass> {
+class CFGuardPass : public OptionalPassInfoMixin<CFGuardPass> {
 public:
   enum class Mechanism { Check, Dispatch };
 
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroAnnotationElide.h b/llvm/include/llvm/Transforms/Coroutines/CoroAnnotationElide.h
index 2061098b6ea6a..6f2c4b74b38a4 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroAnnotationElide.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroAnnotationElide.h
@@ -23,13 +23,12 @@
 
 namespace llvm {
 
-struct CoroAnnotationElidePass : PassInfoMixin<CoroAnnotationElidePass> {
+struct CoroAnnotationElidePass
+    : OptionalPassInfoMixin<CoroAnnotationElidePass> {
   CoroAnnotationElidePass() = default;
 
   PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
                         LazyCallGraph &CG, CGSCCUpdateResult &UR);
-
-  static bool isRequired() { return false; }
 };
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroCleanup.h b/llvm/include/llvm/Transforms/Coroutines/CoroCleanup.h
index 3000a38258f4f..3a3a92d112dc2 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroCleanup.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroCleanup.h
@@ -20,9 +20,8 @@ namespace llvm {
 
 class Module;
 
-struct CoroCleanupPass : PassInfoMixin<CoroCleanupPass> {
+struct CoroCleanupPass : MandatoryPassInfoMixin<CoroCleanupPass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-  static bool isRequired() { return true; }
 };
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroConditionalWrapper.h b/llvm/include/llvm/Transforms/Coroutines/CoroConditionalWrapper.h
index 86b0449b8713d..b3f91ff2e7b2b 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroConditionalWrapper.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroConditionalWrapper.h
@@ -17,10 +17,10 @@ class Module;
 
 // Only runs passes in the contained pass manager if the module contains any
 // coroutine intrinsic declarations.
-struct CoroConditionalWrapper : PassInfoMixin<CoroConditionalWrapper> {
+struct CoroConditionalWrapper : MandatoryPassInfoMixin<CoroConditionalWrapper> {
   CoroConditionalWrapper(ModulePassManager &&);
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
+
   void printPipeline(raw_ostream &OS,
                      function_ref<StringRef(StringRef)> MapClassName2PassName);
 
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroEarly.h b/llvm/include/llvm/Transforms/Coroutines/CoroEarly.h
index d55dcc6dfa6db..d887dc562d6c4 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroEarly.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroEarly.h
@@ -23,9 +23,8 @@ namespace llvm {
 
 class Module;
 
-struct CoroEarlyPass : PassInfoMixin<CoroEarlyPass> {
+struct CoroEarlyPass : MandatoryPassInfoMixin<CoroEarlyPass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroElide.h b/llvm/include/llvm/Transforms/Coroutines/CoroElide.h
index ff73cf20c5bf2..9f3fd80a39107 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroElide.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroElide.h
@@ -22,9 +22,8 @@ namespace llvm {
 
 class Function;
 
-struct CoroElidePass : PassInfoMixin<CoroElidePass> {
+struct CoroElidePass : MandatoryPassInfoMixin<CoroElidePass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h b/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
index f7cc6f29879f9..136e3ace8cd05 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
@@ -28,7 +28,7 @@ class BaseABI;
 struct Shape;
 } // namespace coro
 
-struct CoroSplitPass : PassInfoMixin<CoroSplitPass> {
+struct CoroSplitPass : MandatoryPassInfoMixin<CoroSplitPass> {
   using BaseABITy =
       std::function<std::unique_ptr<coro::BaseABI>(Function &, coro::Shape &)>;
 
@@ -50,8 +50,6 @@ struct CoroSplitPass : PassInfoMixin<CoroSplitPass> {
                                  CGSCCAnalysisManager &AM, LazyCallGraph &CG,
                                  CGSCCUpdateResult &UR);
 
-  static bool isRequired() { return true; }
-
   // Generator for an ABI transformer
   BaseABITy CreateAndInitABI;
 
diff --git a/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h b/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
index b6b753c6f5cfe..1ef480778c558 100644
--- a/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
+++ b/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
@@ -26,26 +26,21 @@ namespace llvm {
 class Module;
 
 class HipStdParAcceleratorCodeSelectionPass
-  : public PassInfoMixin<HipStdParAcceleratorCodeSelectionPass> {
+    : public MandatoryPassInfoMixin<HipStdParAcceleratorCodeSelectionPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-
-  static bool isRequired() { return true; }
 };
 
 class HipStdParAllocationInterpositionPass
-  : public PassInfoMixin<HipStdParAllocationInterpositionPass> {
+    : public MandatoryPassInfoMixin<HipStdParAllocationInterpositionPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-
-  static bool isRequired() { return true; }
 };
 
-class HipStdParMathFixupPass : public PassInfoMixin<HipStdParMathFixupPass> {
+class HipStdParMathFixupPass
+    : public MandatoryPassInfoMixin<HipStdParMathFixupPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/IPO/AlwaysInliner.h b/llvm/include/llvm/Transforms/IPO/AlwaysInliner.h
index 679126b011d8e..7641f851dd5af 100644
--- a/llvm/include/llvm/Transforms/IPO/AlwaysInliner.h
+++ b/llvm/include/llvm/Transforms/IPO/AlwaysInliner.h
@@ -30,7 +30,7 @@ class Pass;
 /// be the simplest possible pass to remove always_inline function definitions'
 /// uses by inlining them. The \c GlobalDCE pass can be used to remove these
 /// functions once all users are gone.
-class AlwaysInlinerPass : public PassInfoMixin<AlwaysInlinerPass> {
+class AlwaysInlinerPass : public MandatoryPassInfoMixin<AlwaysInlinerPass> {
   bool InsertLifetime;
 
 public:
@@ -38,7 +38,6 @@ class AlwaysInlinerPass : public PassInfoMixin<AlwaysInlinerPass> {
       : InsertLifetime(InsertLifetime) {}
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
-  static bool isRequired() { return true; }
 };
 
 /// Create a legacy pass manager instance of a pass to inline and remove
diff --git a/llvm/include/llvm/Transforms/IPO/Annotation2Metadata.h b/llvm/include/llvm/Transforms/IPO/Annotation2Metadata.h
index dee2759d854f7..b8ccf1ee2f0c6 100644
--- a/llvm/include/llvm/Transforms/IPO/Annotation2Metadata.h
+++ b/llvm/include/llvm/Transforms/IPO/Annotation2Metadata.h
@@ -21,7 +21,8 @@ namespace llvm {
 class Module;
 
 /// Pass to convert @llvm.global.annotations to !annotation metadata.
-struct Annotation2MetadataPass : public PassInfoMixin<Annotation2MetadataPass> {
+struct Annotation2MetadataPass
+    : public OptionalPassInfoMixin<Annotation2MetadataPass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h b/llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h
index 3865f098b8de0..c0be591f606a7 100644
--- a/llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h
+++ b/llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h
@@ -20,7 +20,8 @@ namespace llvm {
 /// This pass walks the functions in each SCC and for each one tries to
 /// transform it and all of its callers to replace indirect arguments with
 /// direct (by-value) arguments.
-class ArgumentPromotionPass : public PassInfoMixin<ArgumentPromotionPass> {
+class ArgumentPromotionPass
+    : public OptionalPassInfoMixin<ArgumentPromotionPass> {
   unsigned MaxElements;
 
 public:
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index cee9cb8e7322b..6d187041d77d0 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -3474,10 +3474,10 @@ LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
                                  const IntegerRangeState &State);
 ///}
 
-struct AttributorPass : public PassInfoMixin<AttributorPass> {
+struct AttributorPass : public OptionalPassInfoMixin<AttributorPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
-struct AttributorCGSCCPass : public PassInfoMixin<AttributorCGSCCPass> {
+struct AttributorCGSCCPass : public OptionalPassInfoMixin<AttributorCGSCCPass> {
   LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &C,
                                  CGSCCAnalysisManager &AM, LazyCallGraph &CG,
                                  CGSCCUpdateResult &UR);
@@ -3485,14 +3485,14 @@ struct AttributorCGSCCPass : public PassInfoMixin<AttributorCGSCCPass> {
 
 /// A more lightweight version of the Attributor which only runs attribute
 /// inference but no simplifications.
-struct AttributorLightPass : public PassInfoMixin<AttributorLightPass> {
+struct AttributorLightPass : public OptionalPassInfoMixin<AttributorLightPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
 /// A more lightweight version of the Attributor which only runs attribute
 /// inference but no simplifications.
 struct AttributorLightCGSCCPass
-    : public PassInfoMixin<AttributorLightCGSCCPass> {
+    : public OptionalPassInfoMixin<AttributorLightCGSCCPass> {
   LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &C,
                                  CGSCCAnalysisManager &AM, LazyCallGraph &CG,
                                  CGSCCUpdateResult &UR);
diff --git a/llvm/include/llvm/Transforms/IPO/BlockExtractor.h b/llvm/include/llvm/Transforms/IPO/BlockExtractor.h
index 2f8db6f32818c..3ccef32131bf9 100644
--- a/llvm/include/llvm/Transforms/IPO/BlockExtractor.h
+++ b/llvm/include/llvm/Transforms/IPO/BlockExtractor.h
@@ -22,7 +22,7 @@
 namespace llvm {
 class BasicBlock;
 
-struct BlockExtractorPass : PassInfoMixin<BlockExtractorPass> {
+struct BlockExtractorPass : OptionalPassInfoMixin<BlockExtractorPass> {
   LLVM_ABI
   BlockExtractorPass(std::vector<std::vector<BasicBlock *>> &&GroupsOfBlocks,
                      bool EraseFunctions);
diff --git a/llvm/include/llvm/Transforms/IPO/CalledValuePropagation.h b/llvm/include/llvm/Transforms/IPO/CalledValuePropagation.h
index 782633799ede6..b14abd3880c30 100644
--- a/llvm/include/llvm/Transforms/IPO/CalledValuePropagation.h
+++ b/llvm/include/llvm/Transforms/IPO/CalledValuePropagation.h
@@ -24,7 +24,7 @@
 namespace llvm {
 
 class CalledValuePropagationPass
-    : public PassInfoMixin<CalledValuePropagationPass> {
+    : public OptionalPassInfoMixin<CalledValuePropagationPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/ConstantMerge.h b/llvm/include/llvm/Transforms/IPO/ConstantMerge.h
index 12d38b5f58fa0..9bdfce0c8e522 100644
--- a/llvm/include/llvm/Transforms/IPO/ConstantMerge.h
+++ b/llvm/include/llvm/Transforms/IPO/ConstantMerge.h
@@ -26,7 +26,7 @@ namespace llvm {
 class Module;
 
 /// A pass that merges duplicate global constants into a single constant.
-class ConstantMergePass : public PassInfoMixin<ConstantMergePass> {
+class ConstantMergePass : public OptionalPassInfoMixin<ConstantMergePass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/CrossDSOCFI.h b/llvm/include/llvm/Transforms/IPO/CrossDSOCFI.h
index d34a510811018..a833cd5775892 100644
--- a/llvm/include/llvm/Transforms/IPO/CrossDSOCFI.h
+++ b/llvm/include/llvm/Transforms/IPO/CrossDSOCFI.h
@@ -17,7 +17,7 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-class CrossDSOCFIPass : public PassInfoMixin<CrossDSOCFIPass> {
+class CrossDSOCFIPass : public OptionalPassInfoMixin<CrossDSOCFIPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h b/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
index efa9c4bdc496e..943c7440fc7f6 100644
--- a/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
+++ b/llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
@@ -36,7 +36,7 @@ class Value;
 
 /// Eliminate dead arguments (and return values) from functions.
 class DeadArgumentEliminationPass
-    : public PassInfoMixin<DeadArgumentEliminationPass> {
+    : public OptionalPassInfoMixin<DeadArgumentEliminationPass> {
 public:
   /// Struct that represents (part of) either a return value or a function
   /// argument.  Used so that arguments and return values can be used
diff --git a/llvm/include/llvm/Transforms/IPO/ElimAvailExtern.h b/llvm/include/llvm/Transforms/IPO/ElimAvailExtern.h
index 92c319b3cce30..bba2df9f9f613 100644
--- a/llvm/include/llvm/Transforms/IPO/ElimAvailExtern.h
+++ b/llvm/include/llvm/Transforms/IPO/ElimAvailExtern.h
@@ -22,7 +22,7 @@ class Module;
 
 /// A pass that transforms external global definitions into declarations.
 class EliminateAvailableExternallyPass
-    : public PassInfoMixin<EliminateAvailableExternallyPass> {
+    : public OptionalPassInfoMixin<EliminateAvailableExternallyPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/EmbedBitcodePass.h b/llvm/include/llvm/Transforms/IPO/EmbedBitcodePass.h
index dcd6d5f446c03..7983bfe5e47c2 100644
--- a/llvm/include/llvm/Transforms/IPO/EmbedBitcodePass.h
+++ b/llvm/include/llvm/Transforms/IPO/EmbedBitcodePass.h
@@ -35,7 +35,7 @@ struct EmbedBitcodeOptions {
 
 /// Pass embeds a copy of the module optimized with the provided pass pipeline
 /// into a global variable.
-class EmbedBitcodePass : public PassInfoMixin<EmbedBitcodePass> {
+class EmbedBitcodePass : public MandatoryPassInfoMixin<EmbedBitcodePass> {
   bool IsThinLTO;
   bool EmitLTOSummary;
 
@@ -46,8 +46,6 @@ class EmbedBitcodePass : public PassInfoMixin<EmbedBitcodePass> {
       : IsThinLTO(IsThinLTO), EmitLTOSummary(EmitLTOSummary) {}
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
-
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm.
diff --git a/llvm/include/llvm/Transforms/IPO/ExpandVariadics.h b/llvm/include/llvm/Transforms/IPO/ExpandVariadics.h
index 4c5a1b61e2d44..e21d012f6a81a 100644
--- a/llvm/include/llvm/Transforms/IPO/ExpandVariadics.h
+++ b/llvm/include/llvm/Transforms/IPO/ExpandVariadics.h
@@ -23,7 +23,7 @@ enum class ExpandVariadicsMode {
   Lowering,    // Change variadic calling convention
 };
 
-class ExpandVariadicsPass : public PassInfoMixin<ExpandVariadicsPass> {
+class ExpandVariadicsPass : public OptionalPassInfoMixin<ExpandVariadicsPass> {
   const ExpandVariadicsMode Mode;
 
 public:
diff --git a/llvm/include/llvm/Transforms/IPO/ExtractGV.h b/llvm/include/llvm/Transforms/IPO/ExtractGV.h
index eed7dfb8b6a14..ad10e1fec6174 100644
--- a/llvm/include/llvm/Transforms/IPO/ExtractGV.h
+++ b/llvm/include/llvm/Transforms/IPO/ExtractGV.h
@@ -16,7 +16,7 @@
 namespace llvm {
 class GlobalValue;
 
-class ExtractGVPass : public PassInfoMixin<ExtractGVPass> {
+class ExtractGVPass : public OptionalPassInfoMixin<ExtractGVPass> {
 private:
   SetVector<GlobalValue *> Named;
   bool deleteStuff;
diff --git a/llvm/include/llvm/Transforms/IPO/FatLTOCleanup.h b/llvm/include/llvm/Transforms/IPO/FatLTOCleanup.h
index 6fc1b2623e163..1e0e04a97a42f 100644
--- a/llvm/include/llvm/Transforms/IPO/FatLTOCleanup.h
+++ b/llvm/include/llvm/Transforms/IPO/FatLTOCleanup.h
@@ -24,11 +24,10 @@ namespace llvm {
 class Module;
 class ModuleSummaryIndex;
 
-class FatLtoCleanup : public PassInfoMixin<FatLtoCleanup> {
+class FatLtoCleanup : public MandatoryPassInfoMixin<FatLtoCleanup> {
 public:
   FatLtoCleanup() = default;
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Transforms/IPO/ForceFunctionAttrs.h b/llvm/include/llvm/Transforms/IPO/ForceFunctionAttrs.h
index 52667e19bc88b..5084e28bf8c34 100644
--- a/llvm/include/llvm/Transforms/IPO/ForceFunctionAttrs.h
+++ b/llvm/include/llvm/Transforms/IPO/ForceFunctionAttrs.h
@@ -20,10 +20,9 @@ class Module;
 
 /// Pass which forces specific function attributes into the IR, primarily as
 /// a debugging tool.
-struct ForceFunctionAttrsPass : PassInfoMixin<ForceFunctionAttrsPass> {
+struct ForceFunctionAttrsPass : OptionalPassInfoMixin<ForceFunctionAttrsPass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
-
 }
 
 #endif // LLVM_TRANSFORMS_IPO_FORCEFUNCTIONATTRS_H
diff --git a/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h b/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
index eaca0a8fdac0b..f01e890e0f6fb 100644
--- a/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
+++ b/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
@@ -48,7 +48,8 @@ LLVM_ABI bool thinLTOPropagateFunctionAttrs(
 /// access memory, or only read memory, and give them the readnone/readonly
 /// attribute. It also discovers function arguments that are not captured by
 /// the function and marks them with the nocapture attribute.
-struct PostOrderFunctionAttrsPass : PassInfoMixin<PostOrderFunctionAttrsPass> {
+struct PostOrderFunctionAttrsPass
+    : OptionalPassInfoMixin<PostOrderFunctionAttrsPass> {
   PostOrderFunctionAttrsPass(bool SkipNonRecursive = false)
       : SkipNonRecursive(SkipNonRecursive) {}
   LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &C,
@@ -74,7 +75,7 @@ struct PostOrderFunctionAttrsPass : PassInfoMixin<PostOrderFunctionAttrsPass> {
 // this is a boring module pass, but eventually it should be an RPO CGSCC pass
 // when such infrastructure is available.
 class ReversePostOrderFunctionAttrsPass
-    : public PassInfoMixin<ReversePostOrderFunctionAttrsPass> {
+    : public OptionalPassInfoMixin<ReversePostOrderFunctionAttrsPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
@@ -88,7 +89,7 @@ class ReversePostOrderFunctionAttrsPass
 /// taken or any function in the module has external linkage, to safely handle
 /// indirect and library function calls from current function.
 class NoRecurseLTOInferencePass
-    : public PassInfoMixin<NoRecurseLTOInferencePass> {
+    : public OptionalPassInfoMixin<NoRecurseLTOInferencePass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/FunctionImport.h b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
index e6ae9ee831d50..f3d0360944eee 100644
--- a/llvm/include/llvm/Transforms/IPO/FunctionImport.h
+++ b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
@@ -331,7 +331,7 @@ class FunctionImporter {
 };
 
 /// The function importing pass
-class FunctionImportPass : public PassInfoMixin<FunctionImportPass> {
+class FunctionImportPass : public OptionalPassInfoMixin<FunctionImportPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/GlobalDCE.h b/llvm/include/llvm/Transforms/IPO/GlobalDCE.h
index fb263599a5c13..9a0c8c20c13d1 100644
--- a/llvm/include/llvm/Transforms/IPO/GlobalDCE.h
+++ b/llvm/include/llvm/Transforms/IPO/GlobalDCE.h
@@ -35,7 +35,7 @@ class Value;
 class ModulePass;
 
 /// Pass to remove unused function declarations.
-class GlobalDCEPass : public PassInfoMixin<GlobalDCEPass> {
+class GlobalDCEPass : public OptionalPassInfoMixin<GlobalDCEPass> {
 public:
   GlobalDCEPass(bool InLTOPostLink = false) : InLTOPostLink(InLTOPostLink) {}
 
diff --git a/llvm/include/llvm/Transforms/IPO/GlobalOpt.h b/llvm/include/llvm/Transforms/IPO/GlobalOpt.h
index 48a861ff2cf8f..a482e12c75010 100644
--- a/llvm/include/llvm/Transforms/IPO/GlobalOpt.h
+++ b/llvm/include/llvm/Transforms/IPO/GlobalOpt.h
@@ -22,7 +22,7 @@ namespace llvm {
 class Module;
 
 /// Optimize globals that never have their address taken.
-class GlobalOptPass : public PassInfoMixin<GlobalOptPass> {
+class GlobalOptPass : public OptionalPassInfoMixin<GlobalOptPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/GlobalSplit.h b/llvm/include/llvm/Transforms/IPO/GlobalSplit.h
index 690b23a2d7853..84aebf0d13a0f 100644
--- a/llvm/include/llvm/Transforms/IPO/GlobalSplit.h
+++ b/llvm/include/llvm/Transforms/IPO/GlobalSplit.h
@@ -23,7 +23,7 @@ namespace llvm {
 class Module;
 
 /// Pass to perform split of global variables.
-class GlobalSplitPass : public PassInfoMixin<GlobalSplitPass> {
+class GlobalSplitPass : public OptionalPassInfoMixin<GlobalSplitPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/HotColdSplitting.h b/llvm/include/llvm/Transforms/IPO/HotColdSplitting.h
index 4308c0879dbcd..c0fa942082440 100644
--- a/llvm/include/llvm/Transforms/IPO/HotColdSplitting.h
+++ b/llvm/include/llvm/Transforms/IPO/HotColdSplitting.h
@@ -64,7 +64,8 @@ class HotColdSplitting {
 };
 
 /// Pass to outline cold regions.
-class HotColdSplittingPass : public PassInfoMixin<HotColdSplittingPass> {
+class HotColdSplittingPass
+    : public OptionalPassInfoMixin<HotColdSplittingPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/IROutliner.h b/llvm/include/llvm/Transforms/IPO/IROutliner.h
index dccbe5a2038e0..7f400af38a311 100644
--- a/llvm/include/llvm/Transforms/IPO/IROutliner.h
+++ b/llvm/include/llvm/Transforms/IPO/IROutliner.h
@@ -465,7 +465,7 @@ class IROutliner {
 };
 
 /// Pass to outline similar regions.
-class IROutlinerPass : public PassInfoMixin<IROutlinerPass> {
+class IROutlinerPass : public OptionalPassInfoMixin<IROutlinerPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/InferFunctionAttrs.h b/llvm/include/llvm/Transforms/IPO/InferFunctionAttrs.h
index 272b96037c753..f0ac18a18af36 100644
--- a/llvm/include/llvm/Transforms/IPO/InferFunctionAttrs.h
+++ b/llvm/include/llvm/Transforms/IPO/InferFunctionAttrs.h
@@ -22,10 +22,9 @@ class Module;
 
 /// A pass which infers function attributes from the names and signatures of
 /// function declarations in a module.
-struct InferFunctionAttrsPass : PassInfoMixin<InferFunctionAttrsPass> {
+struct InferFunctionAttrsPass : OptionalPassInfoMixin<InferFunctionAttrsPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
-
 }
 
 #endif // LLVM_TRANSFORMS_IPO_INFERFUNCTIONATTRS_H
diff --git a/llvm/include/llvm/Transforms/IPO/Inliner.h b/llvm/include/llvm/Transforms/IPO/Inliner.h
index dd877b5cdc724..e5cd816547ec9 100644
--- a/llvm/include/llvm/Transforms/IPO/Inliner.h
+++ b/llvm/include/llvm/Transforms/IPO/Inliner.h
@@ -33,7 +33,7 @@ namespace llvm {
 /// every attempt to be simpler. DCE of functions requires complex reasoning
 /// about comdat groups, etc. Instead, it is expected that other more focused
 /// passes be composed to achieve the same end result.
-class InlinerPass : public PassInfoMixin<InlinerPass> {
+class InlinerPass : public OptionalPassInfoMixin<InlinerPass> {
 public:
   InlinerPass(bool OnlyMandatory = false,
               ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None)
@@ -62,7 +62,7 @@ class InlinerPass : public PassInfoMixin<InlinerPass> {
 /// a given module. An InlineAdvisor is configured and kept alive for the
 /// duration of the ModuleInlinerWrapperPass::run.
 class ModuleInlinerWrapperPass
-    : public PassInfoMixin<ModuleInlinerWrapperPass> {
+    : public OptionalPassInfoMixin<ModuleInlinerWrapperPass> {
 public:
   LLVM_ABI ModuleInlinerWrapperPass(
       InlineParams Params = getInlineParams(), bool MandatoryFirst = true,
diff --git a/llvm/include/llvm/Transforms/IPO/Internalize.h b/llvm/include/llvm/Transforms/IPO/Internalize.h
index 9d13f09d7d81d..498632f8cb9e5 100644
--- a/llvm/include/llvm/Transforms/IPO/Internalize.h
+++ b/llvm/include/llvm/Transforms/IPO/Internalize.h
@@ -34,7 +34,7 @@ class Module;
 
 /// A pass that internalizes all functions and variables other than those that
 /// must be preserved according to \c MustPreserveGV.
-class InternalizePass : public PassInfoMixin<InternalizePass> {
+class InternalizePass : public OptionalPassInfoMixin<InternalizePass> {
   struct ComdatInfo {
     // The number of members. A comdat with one member which is not externally
     // visible can be freely dropped.
diff --git a/llvm/include/llvm/Transforms/IPO/LoopExtractor.h b/llvm/include/llvm/Transforms/IPO/LoopExtractor.h
index aa697484d0e95..3230dccd98948 100644
--- a/llvm/include/llvm/Transforms/IPO/LoopExtractor.h
+++ b/llvm/include/llvm/Transforms/IPO/LoopExtractor.h
@@ -20,7 +20,7 @@
 
 namespace llvm {
 
-struct LoopExtractorPass : public PassInfoMixin<LoopExtractorPass> {
+struct LoopExtractorPass : public OptionalPassInfoMixin<LoopExtractorPass> {
   LoopExtractorPass(unsigned NumLoops = ~0) : NumLoops(NumLoops) {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
   void printPipeline(raw_ostream &OS,
diff --git a/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h b/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
index bb8b40955077e..101c8786306d0 100644
--- a/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
+++ b/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
@@ -202,7 +202,7 @@ enum class DropTestKind {
 
 } // end namespace lowertypetests
 
-class LowerTypeTestsPass : public PassInfoMixin<LowerTypeTestsPass> {
+class LowerTypeTestsPass : public MandatoryPassInfoMixin<LowerTypeTestsPass> {
   bool UseCommandLine = false;
 
   ModuleSummaryIndex *ExportSummary = nullptr;
@@ -218,11 +218,12 @@ class LowerTypeTestsPass : public PassInfoMixin<LowerTypeTestsPass> {
                          lowertypetests::DropTestKind::None)
       : ExportSummary(ExportSummary), ImportSummary(ImportSummary),
         DropTypeTests(DropTypeTests) {}
-  static bool isRequired() { return true; }
+
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
-class SimplifyTypeTestsPass : public PassInfoMixin<SimplifyTypeTestsPass> {
+class SimplifyTypeTestsPass
+    : public OptionalPassInfoMixin<SimplifyTypeTestsPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/MemProfContextDisambiguation.h b/llvm/include/llvm/Transforms/IPO/MemProfContextDisambiguation.h
index bab7c8cca53ed..6196b8070d4f5 100644
--- a/llvm/include/llvm/Transforms/IPO/MemProfContextDisambiguation.h
+++ b/llvm/include/llvm/Transforms/IPO/MemProfContextDisambiguation.h
@@ -29,7 +29,7 @@ class Module;
 class OptimizationRemarkEmitter;
 
 class MemProfContextDisambiguation
-    : public PassInfoMixin<MemProfContextDisambiguation> {
+    : public OptionalPassInfoMixin<MemProfContextDisambiguation> {
   /// Run the context disambiguator on \p M, returns true if any changes made.
   bool processModule(
       Module &M,
@@ -104,7 +104,7 @@ class MemProfContextDisambiguation
 /// when we don't have an index that has recorded that we are linking with
 /// allocation libraries containing the necessary APIs for downstream
 /// transformations.
-class MemProfRemoveInfo : public PassInfoMixin<MemProfRemoveInfo> {
+class MemProfRemoveInfo : public OptionalPassInfoMixin<MemProfRemoveInfo> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/MergeFunctions.h b/llvm/include/llvm/Transforms/IPO/MergeFunctions.h
index 559d5a77618ad..75399d3297a05 100644
--- a/llvm/include/llvm/Transforms/IPO/MergeFunctions.h
+++ b/llvm/include/llvm/Transforms/IPO/MergeFunctions.h
@@ -24,7 +24,7 @@ class Module;
 class Function;
 
 /// Merge identical functions.
-class MergeFunctionsPass : public PassInfoMixin<MergeFunctionsPass> {
+class MergeFunctionsPass : public OptionalPassInfoMixin<MergeFunctionsPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 
diff --git a/llvm/include/llvm/Transforms/IPO/ModuleInliner.h b/llvm/include/llvm/Transforms/IPO/ModuleInliner.h
index 6b09d18ee81c1..1c7bb7b32c990 100644
--- a/llvm/include/llvm/Transforms/IPO/ModuleInliner.h
+++ b/llvm/include/llvm/Transforms/IPO/ModuleInliner.h
@@ -25,7 +25,7 @@ namespace llvm {
 /// heuristics in the module level such like PriorityInlineOrder. It can be
 /// tuned with a number of parameters to control what cost model is used and
 /// what tradeoffs are made when making the decision.
-class ModuleInlinerPass : public PassInfoMixin<ModuleInlinerPass> {
+class ModuleInlinerPass : public OptionalPassInfoMixin<ModuleInlinerPass> {
 public:
   ModuleInlinerPass(InlineParams Params = getInlineParams(),
                     InliningAdvisorMode Mode = InliningAdvisorMode::Default,
diff --git a/llvm/include/llvm/Transforms/IPO/OpenMPOpt.h b/llvm/include/llvm/Transforms/IPO/OpenMPOpt.h
index 2499c2bbccf45..eca3b042fd007 100644
--- a/llvm/include/llvm/Transforms/IPO/OpenMPOpt.h
+++ b/llvm/include/llvm/Transforms/IPO/OpenMPOpt.h
@@ -39,7 +39,7 @@ KernelSet getDeviceKernels(Module &M);
 } // namespace omp
 
 /// OpenMP optimizations pass.
-class OpenMPOptPass : public PassInfoMixin<OpenMPOptPass> {
+class OpenMPOptPass : public OptionalPassInfoMixin<OpenMPOptPass> {
 public:
   OpenMPOptPass() = default;
   OpenMPOptPass(ThinOrFullLTOPhase LTOPhase) : LTOPhase(LTOPhase) {}
@@ -50,7 +50,7 @@ class OpenMPOptPass : public PassInfoMixin<OpenMPOptPass> {
   const ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None;
 };
 
-class OpenMPOptCGSCCPass : public PassInfoMixin<OpenMPOptCGSCCPass> {
+class OpenMPOptCGSCCPass : public OptionalPassInfoMixin<OpenMPOptCGSCCPass> {
 public:
   OpenMPOptCGSCCPass() = default;
   OpenMPOptCGSCCPass(ThinOrFullLTOPhase LTOPhase) : LTOPhase(LTOPhase) {}
diff --git a/llvm/include/llvm/Transforms/IPO/PartialInlining.h b/llvm/include/llvm/Transforms/IPO/PartialInlining.h
index 3b8297d659875..4baf13f894ece 100644
--- a/llvm/include/llvm/Transforms/IPO/PartialInlining.h
+++ b/llvm/include/llvm/Transforms/IPO/PartialInlining.h
@@ -21,7 +21,7 @@ namespace llvm {
 class Module;
 
 /// Pass to remove unused function declarations.
-class PartialInlinerPass : public PassInfoMixin<PartialInlinerPass> {
+class PartialInlinerPass : public OptionalPassInfoMixin<PartialInlinerPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/SCCP.h b/llvm/include/llvm/Transforms/IPO/SCCP.h
index 980737253eef5..27a7164a57533 100644
--- a/llvm/include/llvm/Transforms/IPO/SCCP.h
+++ b/llvm/include/llvm/Transforms/IPO/SCCP.h
@@ -45,7 +45,7 @@ struct IPSCCPOptions {
 };
 
 /// Pass to perform interprocedural constant propagation.
-class IPSCCPPass : public PassInfoMixin<IPSCCPPass> {
+class IPSCCPPass : public OptionalPassInfoMixin<IPSCCPPass> {
   IPSCCPOptions Options;
 
 public:
diff --git a/llvm/include/llvm/Transforms/IPO/SampleProfile.h b/llvm/include/llvm/Transforms/IPO/SampleProfile.h
index 5cb57f5b109da..ab8c754c16fbe 100644
--- a/llvm/include/llvm/Transforms/IPO/SampleProfile.h
+++ b/llvm/include/llvm/Transforms/IPO/SampleProfile.h
@@ -37,7 +37,8 @@ class FileSystem;
 } // namespace vfs
 
 /// The sample profiler data loader pass.
-class SampleProfileLoaderPass : public PassInfoMixin<SampleProfileLoaderPass> {
+class SampleProfileLoaderPass
+    : public OptionalPassInfoMixin<SampleProfileLoaderPass> {
 public:
   LLVM_ABI SampleProfileLoaderPass(
       std::string File = "", std::string RemappingFile = "",
diff --git a/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h b/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
index f05d0c532aa74..bdb01ab353a84 100644
--- a/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
+++ b/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
@@ -113,7 +113,8 @@ class SampleProfileProber {
   uint32_t LastProbeId;
 };
 
-class SampleProfileProbePass : public PassInfoMixin<SampleProfileProbePass> {
+class SampleProfileProbePass
+    : public OptionalPassInfoMixin<SampleProfileProbePass> {
   TargetMachine *TM;
 
 public:
@@ -133,7 +134,8 @@ class SampleProfileProbePass : public PassInfoMixin<SampleProfileProbePass> {
 // pass updates distribution factors for each pseudo probe at the end of the
 // prelink pipeline, to reflect an estimated portion of the real execution
 // count.
-class PseudoProbeUpdatePass : public PassInfoMixin<PseudoProbeUpdatePass> {
+class PseudoProbeUpdatePass
+    : public OptionalPassInfoMixin<PseudoProbeUpdatePass> {
   void runOnFunction(Function &F, FunctionAnalysisManager &FAM);
 
 public:
diff --git a/llvm/include/llvm/Transforms/IPO/StripDeadPrototypes.h b/llvm/include/llvm/Transforms/IPO/StripDeadPrototypes.h
index f307da31bbb2c..88c2d0f6bdb38 100644
--- a/llvm/include/llvm/Transforms/IPO/StripDeadPrototypes.h
+++ b/llvm/include/llvm/Transforms/IPO/StripDeadPrototypes.h
@@ -24,10 +24,10 @@ namespace llvm {
 class Module;
 
 /// Pass to remove unused function declarations.
-struct StripDeadPrototypesPass : PassInfoMixin<StripDeadPrototypesPass> {
+struct StripDeadPrototypesPass
+    : OptionalPassInfoMixin<StripDeadPrototypesPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
-
 }
 
 #endif // LLVM_TRANSFORMS_IPO_STRIPDEADPROTOTYPES_H
diff --git a/llvm/include/llvm/Transforms/IPO/StripSymbols.h b/llvm/include/llvm/Transforms/IPO/StripSymbols.h
index 7843c2ebc38f1..488aa29722bd7 100644
--- a/llvm/include/llvm/Transforms/IPO/StripSymbols.h
+++ b/llvm/include/llvm/Transforms/IPO/StripSymbols.h
@@ -27,23 +27,24 @@
 
 namespace llvm {
 
-struct StripSymbolsPass : PassInfoMixin<StripSymbolsPass> {
+struct StripSymbolsPass : OptionalPassInfoMixin<StripSymbolsPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
-struct StripNonDebugSymbolsPass : PassInfoMixin<StripNonDebugSymbolsPass> {
+struct StripNonDebugSymbolsPass
+    : OptionalPassInfoMixin<StripNonDebugSymbolsPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
-struct StripDebugDeclarePass : PassInfoMixin<StripDebugDeclarePass> {
+struct StripDebugDeclarePass : OptionalPassInfoMixin<StripDebugDeclarePass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
-struct StripDeadDebugInfoPass : PassInfoMixin<StripDeadDebugInfoPass> {
+struct StripDeadDebugInfoPass : OptionalPassInfoMixin<StripDeadDebugInfoPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
-struct StripDeadCGProfilePass : PassInfoMixin<StripDeadCGProfilePass> {
+struct StripDeadCGProfilePass : OptionalPassInfoMixin<StripDeadCGProfilePass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h b/llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
index a21db26f1edbc..d58e2a7ef0520 100644
--- a/llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
+++ b/llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
@@ -24,7 +24,7 @@ class Module;
 class raw_ostream;
 
 class ThinLTOBitcodeWriterPass
-    : public PassInfoMixin<ThinLTOBitcodeWriterPass> {
+    : public MandatoryPassInfoMixin<ThinLTOBitcodeWriterPass> {
   raw_ostream &OS;
   raw_ostream *ThinLinkOS;
   const bool ShouldPreserveUseListOrder;
@@ -38,8 +38,6 @@ class ThinLTOBitcodeWriterPass
         ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
index ba0b22b799ebe..c3a394ab4fb72 100644
--- a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
+++ b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
@@ -222,7 +222,8 @@ LLVM_ABI void setAfterReturnValues(MutableArrayRef<VirtualCallTarget> Targets,
 
 } // end namespace wholeprogramdevirt
 
-struct WholeProgramDevirtPass : public PassInfoMixin<WholeProgramDevirtPass> {
+struct WholeProgramDevirtPass
+    : public OptionalPassInfoMixin<WholeProgramDevirtPass> {
   ModuleSummaryIndex *ExportSummary;
   const ModuleSummaryIndex *ImportSummary;
   bool UseCommandLine = false;
diff --git a/llvm/include/llvm/Transforms/InstCombine/InstCombine.h b/llvm/include/llvm/Transforms/InstCombine/InstCombine.h
index 1f758b8015efc..ad7f819b47680 100644
--- a/llvm/include/llvm/Transforms/InstCombine/InstCombine.h
+++ b/llvm/include/llvm/Transforms/InstCombine/InstCombine.h
@@ -46,7 +46,7 @@ struct InstCombineOptions {
   }
 };
 
-class InstCombinePass : public PassInfoMixin<InstCombinePass> {
+class InstCombinePass : public OptionalPassInfoMixin<InstCombinePass> {
 private:
   InstructionWorklist Worklist;
   InstCombineOptions Options;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
index 2a9fe91b32f3c..d91c24bab8576 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -37,7 +37,8 @@ struct AddressSanitizerOptions {
 ///
 /// This adds 'asan.module_ctor' to 'llvm.global_ctors'. This pass may also
 /// run intependently of the function address sanitizer.
-class AddressSanitizerPass : public PassInfoMixin<AddressSanitizerPass> {
+class AddressSanitizerPass
+    : public MandatoryPassInfoMixin<AddressSanitizerPass> {
 public:
   LLVM_ABI
   AddressSanitizerPass(const AddressSanitizerOptions &Options,
@@ -48,7 +49,6 @@ class AddressSanitizerPass : public PassInfoMixin<AddressSanitizerPass> {
   LLVM_ABI void
   printPipeline(raw_ostream &OS,
                 function_ref<StringRef(StringRef)> MapClassName2PassName);
-  static bool isRequired() { return true; }
 
 private:
   AddressSanitizerOptions Options;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h b/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h
index 299fc03c5d96b..8822c9c7af8c0 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h
@@ -33,11 +33,10 @@ struct AllocTokenOptions {
 
 /// A module pass that rewrites heap allocations to use token-enabled
 /// allocation functions based on various source-level properties.
-class AllocTokenPass : public PassInfoMixin<AllocTokenPass> {
+class AllocTokenPass : public MandatoryPassInfoMixin<AllocTokenPass> {
 public:
   LLVM_ABI explicit AllocTokenPass(AllocTokenOptions Opts = {});
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-  static bool isRequired() { return true; }
 
 private:
   const AllocTokenOptions Options;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h b/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
index e4bfcd395c2d6..5ee9acd7aa9bd 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
@@ -19,7 +19,7 @@ class Function;
 
 /// A pass to instrument code and perform run-time bounds checking on loads,
 /// stores, and other memory intrinsics.
-class BoundsCheckingPass : public PassInfoMixin<BoundsCheckingPass> {
+class BoundsCheckingPass : public MandatoryPassInfoMixin<BoundsCheckingPass> {
 
 public:
   struct Options {
@@ -38,7 +38,6 @@ class BoundsCheckingPass : public PassInfoMixin<BoundsCheckingPass> {
 
   BoundsCheckingPass(Options Opts) : Opts(Opts) {}
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
   LLVM_ABI void
   printPipeline(raw_ostream &OS,
                 function_ref<StringRef(StringRef)> MapClassName2PassName);
diff --git a/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h b/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
index 0011b7b8b36c7..cbc57e7a7833d 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
@@ -16,7 +16,7 @@
 
 namespace llvm {
 class Module;
-class CGProfilePass : public PassInfoMixin<CGProfilePass> {
+class CGProfilePass : public OptionalPassInfoMixin<CGProfilePass> {
 public:
   CGProfilePass(bool InLTO) : InLTO(InLTO) {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
diff --git a/llvm/include/llvm/Transforms/Instrumentation/ControlHeightReduction.h b/llvm/include/llvm/Transforms/Instrumentation/ControlHeightReduction.h
index 0bace514c3619..fb15e6f9cd991 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/ControlHeightReduction.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/ControlHeightReduction.h
@@ -18,8 +18,8 @@
 
 namespace llvm {
 
-class ControlHeightReductionPass :
-      public PassInfoMixin<ControlHeightReductionPass> {
+class ControlHeightReductionPass
+    : public OptionalPassInfoMixin<ControlHeightReductionPass> {
 public:
   ControlHeightReductionPass();
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
diff --git a/llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
index 9c9d6afe1872f..f9c14ea682a65 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
@@ -17,7 +17,8 @@
 namespace llvm {
 class Module;
 
-class DataFlowSanitizerPass : public PassInfoMixin<DataFlowSanitizerPass> {
+class DataFlowSanitizerPass
+    : public MandatoryPassInfoMixin<DataFlowSanitizerPass> {
 private:
   std::vector<std::string> ABIListFiles;
   IntrusiveRefCntPtr<vfs::FileSystem> FS;
@@ -28,7 +29,6 @@ class DataFlowSanitizerPass : public PassInfoMixin<DataFlowSanitizerPass> {
       IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getRealFileSystem())
       : ABIListFiles(ABIListFiles), FS(std::move(FS)) {}
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
index 43ef86b08517a..4d1688cc1676f 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
@@ -19,7 +19,7 @@
 
 namespace llvm {
 /// The gcov-style instrumentation pass
-class GCOVProfilerPass : public PassInfoMixin<GCOVProfilerPass> {
+class GCOVProfilerPass : public OptionalPassInfoMixin<GCOVProfilerPass> {
 public:
   GCOVProfilerPass(
       const GCOVOptions &Options = GCOVOptions::getDefault(),
diff --git a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
index d9292ea7d1613..106aae8d20bb1 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
@@ -37,12 +37,13 @@ struct HWAddressSanitizerOptions {
 /// This is a public interface to the hardware address sanitizer pass for
 /// instrumenting code to check for various memory errors at runtime, similar to
 /// AddressSanitizer but based on partial hardware assistance.
-class HWAddressSanitizerPass : public PassInfoMixin<HWAddressSanitizerPass> {
+class HWAddressSanitizerPass
+    : public MandatoryPassInfoMixin<HWAddressSanitizerPass> {
 public:
   explicit HWAddressSanitizerPass(HWAddressSanitizerOptions Options)
       : Options(Options){};
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
-  static bool isRequired() { return true; }
+
   LLVM_ABI void
   printPipeline(raw_ostream &OS,
                 function_ref<StringRef(StringRef)> MapClassName2PassName);
diff --git a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
index 469c12ee69652..a31bb1711e784 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
@@ -24,7 +24,7 @@ class TargetLibraryInfo;
 /// the profile instrumented code generated by FE or the IR based
 /// instrumentation pass.
 class InstrProfilingLoweringPass
-    : public PassInfoMixin<InstrProfilingLoweringPass> {
+    : public OptionalPassInfoMixin<InstrProfilingLoweringPass> {
   const InstrProfOptions Options = {};
   // Is this lowering for the context-sensitive instrumentation.
   const bool IsCS = false;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/KCFI.h b/llvm/include/llvm/Transforms/Instrumentation/KCFI.h
index 2711930a20b5b..7640aec28b92f 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/KCFI.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/KCFI.h
@@ -18,9 +18,8 @@
 #include "llvm/Support/Compiler.h"
 
 namespace llvm {
-class KCFIPass : public PassInfoMixin<KCFIPass> {
+class KCFIPass : public MandatoryPassInfoMixin<KCFIPass> {
 public:
-  static bool isRequired() { return true; }
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h b/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h
index 7b5e4a21c057c..479dcff623586 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h
@@ -23,7 +23,7 @@ namespace llvm {
 
 // This pass is responsible for removing optional traps, like llvm.ubsantrap
 // from the hot code.
-class LowerAllowCheckPass : public PassInfoMixin<LowerAllowCheckPass> {
+class LowerAllowCheckPass : public MandatoryPassInfoMixin<LowerAllowCheckPass> {
 public:
   struct Options {
     std::vector<unsigned int> cutoffs;
@@ -34,8 +34,6 @@ class LowerAllowCheckPass : public PassInfoMixin<LowerAllowCheckPass> {
       : Opts(std::move(Opts)) {};
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
-  static bool isRequired() { return true; }
-
   LLVM_ABI static bool IsRequested();
   LLVM_ABI void
   printPipeline(raw_ostream &OS,
diff --git a/llvm/include/llvm/Transforms/Instrumentation/MemProfInstrumentation.h b/llvm/include/llvm/Transforms/Instrumentation/MemProfInstrumentation.h
index 521491b87a1e5..98f9f4d5f05d8 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/MemProfInstrumentation.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/MemProfInstrumentation.h
@@ -27,20 +27,19 @@ class Module;
 /// calls to the MemProfiler runtime library functions. The runtime library
 /// essentially replaces malloc() and free() with custom implementations that
 /// record data about the allocations.
-class MemProfilerPass : public PassInfoMixin<MemProfilerPass> {
+class MemProfilerPass : public MandatoryPassInfoMixin<MemProfilerPass> {
 public:
   LLVM_ABI explicit MemProfilerPass();
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// Public interface to the memory profiler module pass for instrumenting code
 /// to profile memory allocations and accesses.
-class ModuleMemProfilerPass : public PassInfoMixin<ModuleMemProfilerPass> {
+class ModuleMemProfilerPass
+    : public MandatoryPassInfoMixin<ModuleMemProfilerPass> {
 public:
   LLVM_ABI explicit ModuleMemProfilerPass();
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Instrumentation/MemProfUse.h b/llvm/include/llvm/Transforms/Instrumentation/MemProfUse.h
index 1fbb2bcb194ef..5402ee25fc35c 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/MemProfUse.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/MemProfUse.h
@@ -29,7 +29,7 @@ namespace vfs {
 class FileSystem;
 } // namespace vfs
 
-class MemProfUsePass : public PassInfoMixin<MemProfUsePass> {
+class MemProfUsePass : public OptionalPassInfoMixin<MemProfUsePass> {
 public:
   LLVM_ABI explicit MemProfUsePass(
       std::string MemoryProfileFile,
diff --git a/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
index 1095e9d76d048..28f2a3b3305d3 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
@@ -40,14 +40,14 @@ struct MemorySanitizerOptions {
 /// inserts calls to runtime library functions. If the functions aren't declared
 /// yet, the pass inserts the declarations. Otherwise the existing globals are
 /// used.
-struct MemorySanitizerPass : public PassInfoMixin<MemorySanitizerPass> {
+struct MemorySanitizerPass
+    : public MandatoryPassInfoMixin<MemorySanitizerPass> {
   MemorySanitizerPass(MemorySanitizerOptions Options) : Options(Options) {}
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
   LLVM_ABI void
   printPipeline(raw_ostream &OS,
                 function_ref<StringRef(StringRef)> MapClassName2PassName);
-  static bool isRequired() { return true; }
 
 private:
   MemorySanitizerOptions Options;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h
index 7ba938e01d819..148fe880cf054 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h
@@ -27,9 +27,8 @@ namespace llvm {
 /// This pass inserts calls to runtime library functions. If the
 /// functions aren't declared yet, the pass inserts the declarations.
 struct NumericalStabilitySanitizerPass
-    : public PassInfoMixin<NumericalStabilitySanitizerPass> {
+    : public MandatoryPassInfoMixin<NumericalStabilitySanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfFlattening.h b/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfFlattening.h
index 96ff265af4371..72aee4767a98e 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfFlattening.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfFlattening.h
@@ -16,7 +16,7 @@
 namespace llvm {
 
 class PGOCtxProfFlatteningPass
-    : public PassInfoMixin<PGOCtxProfFlatteningPass> {
+    : public OptionalPassInfoMixin<PGOCtxProfFlatteningPass> {
   const bool IsPreThinlink;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfLowering.h b/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfLowering.h
index 8010c1c091e40..d4947ca51ff0d 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfLowering.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/PGOCtxProfLowering.h
@@ -16,7 +16,8 @@
 namespace llvm {
 class Type;
 
-class PGOCtxProfLoweringPass : public PassInfoMixin<PGOCtxProfLoweringPass> {
+class PGOCtxProfLoweringPass
+    : public OptionalPassInfoMixin<PGOCtxProfLoweringPass> {
 public:
   explicit PGOCtxProfLoweringPass() = default;
   // True if contextual instrumentation is enabled.
@@ -32,7 +33,8 @@ class PGOCtxProfLoweringPass : public PassInfoMixin<PGOCtxProfLoweringPass> {
 // functions by a (GUID, Hash) tuple, but since the ctxprof "use" waits for
 // thinlto to happen before performing any further optimizations, it's
 // unnecessary to collect profiles for non-prevailing copies.
-class NoinlineNonPrevailing : public PassInfoMixin<NoinlineNonPrevailing> {
+class NoinlineNonPrevailing
+    : public OptionalPassInfoMixin<NoinlineNonPrevailing> {
 public:
   explicit NoinlineNonPrevailing() = default;
 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/PGOForceFunctionAttrs.h b/llvm/include/llvm/Transforms/Instrumentation/PGOForceFunctionAttrs.h
index 785448e0dec4d..231158ec5cd4f 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/PGOForceFunctionAttrs.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/PGOForceFunctionAttrs.h
@@ -15,7 +15,7 @@
 namespace llvm {
 
 struct PGOForceFunctionAttrsPass
-    : public PassInfoMixin<PGOForceFunctionAttrsPass> {
+    : public OptionalPassInfoMixin<PGOForceFunctionAttrsPass> {
   PGOForceFunctionAttrsPass(PGOOptions::ColdFuncOpt ColdType)
       : ColdType(ColdType) {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
diff --git a/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h b/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h
index 9dcd4b53a0dbe..0ae67576ed07a 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h
@@ -37,7 +37,7 @@ class Module;
 // all the COMDAT variables before linking. So we have this pass
 // always run before linking for CSPGO.
 class PGOInstrumentationGenCreateVar
-    : public PassInfoMixin<PGOInstrumentationGenCreateVar> {
+    : public OptionalPassInfoMixin<PGOInstrumentationGenCreateVar> {
 public:
   PGOInstrumentationGenCreateVar(std::string CSInstrName = "",
                                  bool Sampling = false)
@@ -51,7 +51,8 @@ class PGOInstrumentationGenCreateVar
 
 enum class PGOInstrumentationType { Invalid = 0, FDO, CSFDO, CTXPROF };
 /// The instrumentation (profile-instr-gen) pass for IR based PGO.
-class PGOInstrumentationGen : public PassInfoMixin<PGOInstrumentationGen> {
+class PGOInstrumentationGen
+    : public OptionalPassInfoMixin<PGOInstrumentationGen> {
 public:
   PGOInstrumentationGen(
       PGOInstrumentationType InstrumentationType = PGOInstrumentationType ::FDO)
@@ -64,7 +65,8 @@ class PGOInstrumentationGen : public PassInfoMixin<PGOInstrumentationGen> {
 };
 
 /// The profile annotation (profile-instr-use) pass for IR based PGO.
-class PGOInstrumentationUse : public PassInfoMixin<PGOInstrumentationUse> {
+class PGOInstrumentationUse
+    : public OptionalPassInfoMixin<PGOInstrumentationUse> {
 public:
   LLVM_ABI
   PGOInstrumentationUse(std::string Filename = "",
@@ -82,7 +84,8 @@ class PGOInstrumentationUse : public PassInfoMixin<PGOInstrumentationUse> {
 };
 
 /// The indirect function call promotion pass.
-class PGOIndirectCallPromotion : public PassInfoMixin<PGOIndirectCallPromotion> {
+class PGOIndirectCallPromotion
+    : public OptionalPassInfoMixin<PGOIndirectCallPromotion> {
 public:
   PGOIndirectCallPromotion(bool IsInLTO = false, bool SamplePGO = false)
       : InLTO(IsInLTO), SamplePGO(SamplePGO) {}
@@ -95,7 +98,7 @@ class PGOIndirectCallPromotion : public PassInfoMixin<PGOIndirectCallPromotion>
 };
 
 /// The profile size based optimization pass for memory intrinsics.
-class PGOMemOPSizeOpt : public PassInfoMixin<PGOMemOPSizeOpt> {
+class PGOMemOPSizeOpt : public OptionalPassInfoMixin<PGOMemOPSizeOpt> {
 public:
   PGOMemOPSizeOpt() = default;
 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/RealtimeSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/RealtimeSanitizer.h
index 67697c695f1a4..5122c8111a29c 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/RealtimeSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/RealtimeSanitizer.h
@@ -25,9 +25,9 @@
 namespace llvm {
 
 /// Create ctor and init functions.
-struct RealtimeSanitizerPass : public PassInfoMixin<RealtimeSanitizerPass> {
+struct RealtimeSanitizerPass
+    : public MandatoryPassInfoMixin<RealtimeSanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
index 63c5990a41741..f8aa67bac429b 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
@@ -53,14 +53,13 @@ inline constexpr char kSanitizerBinaryMetadataAtomicsSection[] =
 //
 /// The pass should be inserted after optimizations.
 class SanitizerBinaryMetadataPass
-    : public PassInfoMixin<SanitizerBinaryMetadataPass> {
+    : public MandatoryPassInfoMixin<SanitizerBinaryMetadataPass> {
 public:
   LLVM_ABI explicit SanitizerBinaryMetadataPass(
       SanitizerBinaryMetadataOptions Opts = {},
       IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr,
       ArrayRef<std::string> IgnorelistFiles = {});
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 
 private:
   const SanitizerBinaryMetadataOptions Options;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h b/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
index 346e7f06eaa43..ca41d6d175bcb 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
@@ -31,7 +31,8 @@ class FileSystem;
 /// pass instruments functions for coverage, adds initialization calls to the
 /// module for trace PC guards and 8bit counters if they are requested, and
 /// appends globals to llvm.compiler.used.
-class SanitizerCoveragePass : public PassInfoMixin<SanitizerCoveragePass> {
+class SanitizerCoveragePass
+    : public MandatoryPassInfoMixin<SanitizerCoveragePass> {
 public:
   LLVM_ABI explicit SanitizerCoveragePass(
       SanitizerCoverageOptions Options = SanitizerCoverageOptions(),
@@ -39,7 +40,6 @@ class SanitizerCoveragePass : public PassInfoMixin<SanitizerCoveragePass> {
       const std::vector<std::string> &AllowlistFiles = {},
       const std::vector<std::string> &BlocklistFiles = {});
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 
 private:
   SanitizerCoverageOptions Options;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
index dea3b6b754b66..7ee0ea12e30af 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
@@ -25,18 +25,17 @@ class Module;
 /// Instruments functions to detect race conditions reads. This function pass
 /// inserts calls to runtime library functions. If the functions aren't declared
 /// yet, the pass inserts the declarations. Otherwise the existing globals are
-struct ThreadSanitizerPass : public PassInfoMixin<ThreadSanitizerPass> {
+struct ThreadSanitizerPass
+    : public MandatoryPassInfoMixin<ThreadSanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
-  static bool isRequired() { return true; }
 };
 
 /// A module pass for tsan instrumentation.
 ///
 /// Create ctor and init functions.
 struct ModuleThreadSanitizerPass
-  : public PassInfoMixin<ModuleThreadSanitizerPass> {
+    : public MandatoryPassInfoMixin<ModuleThreadSanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Instrumentation/TypeSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/TypeSanitizer.h
index 61a1c3e01c2c6..669b75a156a82 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/TypeSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/TypeSanitizer.h
@@ -21,9 +21,8 @@ class Function;
 class FunctionPass;
 class Module;
 
-struct TypeSanitizerPass : public PassInfoMixin<TypeSanitizerPass> {
+struct TypeSanitizerPass : public MandatoryPassInfoMixin<TypeSanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/ObjCARC.h b/llvm/include/llvm/Transforms/ObjCARC.h
index c4b4c4f0b09c6..5b7b7f2b46382 100644
--- a/llvm/include/llvm/Transforms/ObjCARC.h
+++ b/llvm/include/llvm/Transforms/ObjCARC.h
@@ -27,19 +27,19 @@ class Pass;
 //
 LLVM_ABI Pass *createObjCARCContractPass();
 
-struct ObjCARCOptPass : public PassInfoMixin<ObjCARCOptPass> {
+struct ObjCARCOptPass : public OptionalPassInfoMixin<ObjCARCOptPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-struct ObjCARCContractPass : public PassInfoMixin<ObjCARCContractPass> {
+struct ObjCARCContractPass : public OptionalPassInfoMixin<ObjCARCContractPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-struct ObjCARCExpandPass : public PassInfoMixin<ObjCARCExpandPass> {
+struct ObjCARCExpandPass : public OptionalPassInfoMixin<ObjCARCExpandPass> {
   LLVM_ABI PreservedAnalyses run(Function &M, FunctionAnalysisManager &AM);
 };
 
-struct PAEvalPass : public PassInfoMixin<PAEvalPass> {
+struct PAEvalPass : public OptionalPassInfoMixin<PAEvalPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Scalar/ADCE.h b/llvm/include/llvm/Transforms/Scalar/ADCE.h
index 7d8b7ae68c004..c5adb5f88e2e8 100644
--- a/llvm/include/llvm/Transforms/Scalar/ADCE.h
+++ b/llvm/include/llvm/Transforms/Scalar/ADCE.h
@@ -28,7 +28,7 @@ class Function;
 /// instructions are dead until proven otherwise. This allows it to eliminate
 /// dead computations that other DCE passes do not catch, particularly involving
 /// loop computations.
-struct ADCEPass : PassInfoMixin<ADCEPass> {
+struct ADCEPass : OptionalPassInfoMixin<ADCEPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
 };
 
diff --git a/llvm/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h b/llvm/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
index ab2bb2e4cf1e4..12fa2f968da8f 100644
--- a/llvm/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
+++ b/llvm/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
@@ -29,7 +29,7 @@ class SCEV;
 class Value;
 
 struct AlignmentFromAssumptionsPass
-    : public PassInfoMixin<AlignmentFromAssumptionsPass> {
+    : public OptionalPassInfoMixin<AlignmentFromAssumptionsPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
   // Glue for old PM.
diff --git a/llvm/include/llvm/Transforms/Scalar/AnnotationRemarks.h b/llvm/include/llvm/Transforms/Scalar/AnnotationRemarks.h
index 45983ad9d5716..ac13e08b90573 100644
--- a/llvm/include/llvm/Transforms/Scalar/AnnotationRemarks.h
+++ b/llvm/include/llvm/Transforms/Scalar/AnnotationRemarks.h
@@ -20,9 +20,9 @@ namespace llvm {
 
 class Function;
 
-struct AnnotationRemarksPass : public PassInfoMixin<AnnotationRemarksPass> {
+struct AnnotationRemarksPass
+    : public MandatoryPassInfoMixin<AnnotationRemarksPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/include/llvm/Transforms/Scalar/BDCE.h b/llvm/include/llvm/Transforms/Scalar/BDCE.h
index 0763f31dfad45..46f1d4b9838a2 100644
--- a/llvm/include/llvm/Transforms/Scalar/BDCE.h
+++ b/llvm/include/llvm/Transforms/Scalar/BDCE.h
@@ -23,7 +23,7 @@ namespace llvm {
 class Function;
 
 // The Bit-Tracking Dead Code Elimination pass.
-struct BDCEPass : PassInfoMixin<BDCEPass> {
+struct BDCEPass : OptionalPassInfoMixin<BDCEPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 }
diff --git a/llvm/include/llvm/Transforms/Scalar/CallSiteSplitting.h b/llvm/include/llvm/Transforms/Scalar/CallSiteSplitting.h
index 661340f4598f1..707fc7e2ee74d 100644
--- a/llvm/include/llvm/Transforms/Scalar/CallSiteSplitting.h
+++ b/llvm/include/llvm/Transforms/Scalar/CallSiteSplitting.h
@@ -15,7 +15,7 @@ namespace llvm {
 
 class Function;
 
-struct CallSiteSplittingPass : PassInfoMixin<CallSiteSplittingPass> {
+struct CallSiteSplittingPass : OptionalPassInfoMixin<CallSiteSplittingPass> {
   /// Run the pass over the function.
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h b/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h
index e597665661e34..13af5d87b88eb 100644
--- a/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h
+++ b/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h
@@ -123,7 +123,8 @@ struct ConstantInfo {
 
 } // end namespace consthoist
 
-class ConstantHoistingPass : public PassInfoMixin<ConstantHoistingPass> {
+class ConstantHoistingPass
+    : public OptionalPassInfoMixin<ConstantHoistingPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
diff --git a/llvm/include/llvm/Transforms/Scalar/ConstraintElimination.h b/llvm/include/llvm/Transforms/Scalar/ConstraintElimination.h
index 544a6c2eae552..b85faa1cc7c19 100644
--- a/llvm/include/llvm/Transforms/Scalar/ConstraintElimination.h
+++ b/llvm/include/llvm/Transforms/Scalar/ConstraintElimination.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class ConstraintEliminationPass
-    : public PassInfoMixin<ConstraintEliminationPass> {
+    : public OptionalPassInfoMixin<ConstraintEliminationPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/CorrelatedValuePropagation.h b/llvm/include/llvm/Transforms/Scalar/CorrelatedValuePropagation.h
index 25795de5d951f..8bd5427e06554 100644
--- a/llvm/include/llvm/Transforms/Scalar/CorrelatedValuePropagation.h
+++ b/llvm/include/llvm/Transforms/Scalar/CorrelatedValuePropagation.h
@@ -16,7 +16,7 @@ namespace llvm {
 class Function;
 
 struct CorrelatedValuePropagationPass
-    : PassInfoMixin<CorrelatedValuePropagationPass> {
+    : OptionalPassInfoMixin<CorrelatedValuePropagationPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Scalar/DCE.h b/llvm/include/llvm/Transforms/Scalar/DCE.h
index 8d1616a7b75db..ee7b5da94b70b 100644
--- a/llvm/include/llvm/Transforms/Scalar/DCE.h
+++ b/llvm/include/llvm/Transforms/Scalar/DCE.h
@@ -20,13 +20,13 @@ namespace llvm {
 class Function;
 
 /// Basic Dead Code Elimination pass.
-class DCEPass : public PassInfoMixin<DCEPass> {
+class DCEPass : public OptionalPassInfoMixin<DCEPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 class RedundantDbgInstEliminationPass
-    : public PassInfoMixin<RedundantDbgInstEliminationPass> {
+    : public OptionalPassInfoMixin<RedundantDbgInstEliminationPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/DFAJumpThreading.h b/llvm/include/llvm/Transforms/Scalar/DFAJumpThreading.h
index 4e9fbf65e1636..2a43b54ab41a1 100644
--- a/llvm/include/llvm/Transforms/Scalar/DFAJumpThreading.h
+++ b/llvm/include/llvm/Transforms/Scalar/DFAJumpThreading.h
@@ -19,7 +19,7 @@ namespace llvm {
 
 class Function;
 
-struct DFAJumpThreadingPass : PassInfoMixin<DFAJumpThreadingPass> {
+struct DFAJumpThreadingPass : OptionalPassInfoMixin<DFAJumpThreadingPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Scalar/DeadStoreElimination.h b/llvm/include/llvm/Transforms/Scalar/DeadStoreElimination.h
index b66b0de90c790..1b187ffe2999b 100644
--- a/llvm/include/llvm/Transforms/Scalar/DeadStoreElimination.h
+++ b/llvm/include/llvm/Transforms/Scalar/DeadStoreElimination.h
@@ -25,7 +25,7 @@ class Function;
 
 /// This class implements a trivial dead store elimination. We consider
 /// only the redundant stores that are local to a single Basic Block.
-class DSEPass : public PassInfoMixin<DSEPass> {
+class DSEPass : public OptionalPassInfoMixin<DSEPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/DivRemPairs.h b/llvm/include/llvm/Transforms/Scalar/DivRemPairs.h
index 7401e02cb4ab4..db1de7c1ccf8f 100644
--- a/llvm/include/llvm/Transforms/Scalar/DivRemPairs.h
+++ b/llvm/include/llvm/Transforms/Scalar/DivRemPairs.h
@@ -20,11 +20,10 @@ namespace llvm {
 
 /// Hoist/decompose integer division and remainder instructions to enable CFG
 /// improvements and better codegen.
-struct DivRemPairsPass : public PassInfoMixin<DivRemPairsPass> {
+struct DivRemPairsPass : public OptionalPassInfoMixin<DivRemPairsPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
 };
-
 }
 #endif // LLVM_TRANSFORMS_SCALAR_DIVREMPAIRS_H
 
diff --git a/llvm/include/llvm/Transforms/Scalar/DropUnnecessaryAssumes.h b/llvm/include/llvm/Transforms/Scalar/DropUnnecessaryAssumes.h
index 54ddcc09f7204..4aaa9662256a6 100644
--- a/llvm/include/llvm/Transforms/Scalar/DropUnnecessaryAssumes.h
+++ b/llvm/include/llvm/Transforms/Scalar/DropUnnecessaryAssumes.h
@@ -18,7 +18,7 @@
 namespace llvm {
 
 struct DropUnnecessaryAssumesPass
-    : public PassInfoMixin<DropUnnecessaryAssumesPass> {
+    : public OptionalPassInfoMixin<DropUnnecessaryAssumesPass> {
   DropUnnecessaryAssumesPass(bool DropDereferenceable = false)
       : DropDereferenceable(DropDereferenceable) {}
 
diff --git a/llvm/include/llvm/Transforms/Scalar/EarlyCSE.h b/llvm/include/llvm/Transforms/Scalar/EarlyCSE.h
index cbde7ff18ff79..053571a36208e 100644
--- a/llvm/include/llvm/Transforms/Scalar/EarlyCSE.h
+++ b/llvm/include/llvm/Transforms/Scalar/EarlyCSE.h
@@ -28,7 +28,7 @@ class Function;
 /// canonicalize things as it goes. It is intended to be fast and catch obvious
 /// cases so that instcombine and other passes are more effective. It is
 /// expected that a later pass of GVN will catch the interesting/hard cases.
-struct EarlyCSEPass : PassInfoMixin<EarlyCSEPass> {
+struct EarlyCSEPass : OptionalPassInfoMixin<EarlyCSEPass> {
   EarlyCSEPass(bool UseMemorySSA = false) : UseMemorySSA(UseMemorySSA) {}
 
   /// Run the pass over the function.
diff --git a/llvm/include/llvm/Transforms/Scalar/ExpandMemCmp.h b/llvm/include/llvm/Transforms/Scalar/ExpandMemCmp.h
index 856978df03b7b..7c80c509d45a0 100644
--- a/llvm/include/llvm/Transforms/Scalar/ExpandMemCmp.h
+++ b/llvm/include/llvm/Transforms/Scalar/ExpandMemCmp.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class ExpandMemCmpPass : public PassInfoMixin<ExpandMemCmpPass> {
+class ExpandMemCmpPass : public OptionalPassInfoMixin<ExpandMemCmpPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/FlattenCFG.h b/llvm/include/llvm/Transforms/Scalar/FlattenCFG.h
index ff49a4ab7ceb1..d26847db7de9d 100644
--- a/llvm/include/llvm/Transforms/Scalar/FlattenCFG.h
+++ b/llvm/include/llvm/Transforms/Scalar/FlattenCFG.h
@@ -17,7 +17,7 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-struct FlattenCFGPass : PassInfoMixin<FlattenCFGPass> {
+struct FlattenCFGPass : OptionalPassInfoMixin<FlattenCFGPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Scalar/Float2Int.h b/llvm/include/llvm/Transforms/Scalar/Float2Int.h
index 337e229efcf37..63a7577d69d15 100644
--- a/llvm/include/llvm/Transforms/Scalar/Float2Int.h
+++ b/llvm/include/llvm/Transforms/Scalar/Float2Int.h
@@ -28,7 +28,7 @@ class LLVMContext;
 class Type;
 class Value;
 
-class Float2IntPass : public PassInfoMixin<Float2IntPass> {
+class Float2IntPass : public OptionalPassInfoMixin<Float2IntPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
diff --git a/llvm/include/llvm/Transforms/Scalar/GVN.h b/llvm/include/llvm/Transforms/Scalar/GVN.h
index 36477e41e900c..56a93c9770c99 100644
--- a/llvm/include/llvm/Transforms/Scalar/GVN.h
+++ b/llvm/include/llvm/Transforms/Scalar/GVN.h
@@ -125,7 +125,7 @@ struct GVNOptions {
 ///
 /// FIXME: We should have a good summary of the GVN algorithm implemented by
 /// this particular pass here.
-class GVNPass : public PassInfoMixin<GVNPass> {
+class GVNPass : public OptionalPassInfoMixin<GVNPass> {
   GVNOptions Options;
 
 public:
@@ -428,14 +428,14 @@ LLVM_ABI FunctionPass *createGVNPass();
 
 /// A simple and fast domtree-based GVN pass to hoist common expressions
 /// from sibling branches.
-struct GVNHoistPass : PassInfoMixin<GVNHoistPass> {
+struct GVNHoistPass : OptionalPassInfoMixin<GVNHoistPass> {
   /// Run the pass over the function.
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 /// Uses an "inverted" value numbering to decide the similarity of
 /// expressions and sinks similar expressions into successors.
-struct GVNSinkPass : PassInfoMixin<GVNSinkPass> {
+struct GVNSinkPass : OptionalPassInfoMixin<GVNSinkPass> {
   /// Run the pass over the function.
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/GuardWidening.h b/llvm/include/llvm/Transforms/Scalar/GuardWidening.h
index fa03d5f678fd4..7b8b2e607f2d6 100644
--- a/llvm/include/llvm/Transforms/Scalar/GuardWidening.h
+++ b/llvm/include/llvm/Transforms/Scalar/GuardWidening.h
@@ -24,7 +24,7 @@ class LPMUpdater;
 class Loop;
 class Function;
 
-struct GuardWideningPass : public PassInfoMixin<GuardWideningPass> {
+struct GuardWideningPass : public OptionalPassInfoMixin<GuardWideningPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Scalar/IVUsersPrinter.h b/llvm/include/llvm/Transforms/Scalar/IVUsersPrinter.h
index 6bc01ececcf33..cfebcde77041a 100644
--- a/llvm/include/llvm/Transforms/Scalar/IVUsersPrinter.h
+++ b/llvm/include/llvm/Transforms/Scalar/IVUsersPrinter.h
@@ -18,14 +18,13 @@ class Loop;
 class raw_ostream;
 
 /// Printer pass for the \c IVUsers for a loop.
-class IVUsersPrinterPass : public PassInfoMixin<IVUsersPrinterPass> {
+class IVUsersPrinterPass : public MandatoryPassInfoMixin<IVUsersPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit IVUsersPrinterPass(raw_ostream &OS) : OS(OS) {}
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
-  static bool isRequired() { return true; }
 };
 }
 
diff --git a/llvm/include/llvm/Transforms/Scalar/IndVarSimplify.h b/llvm/include/llvm/Transforms/Scalar/IndVarSimplify.h
index b5d544f1149c6..41b3d2e013b78 100644
--- a/llvm/include/llvm/Transforms/Scalar/IndVarSimplify.h
+++ b/llvm/include/llvm/Transforms/Scalar/IndVarSimplify.h
@@ -22,7 +22,7 @@ namespace llvm {
 class Loop;
 class LPMUpdater;
 
-class IndVarSimplifyPass : public PassInfoMixin<IndVarSimplifyPass> {
+class IndVarSimplifyPass : public OptionalPassInfoMixin<IndVarSimplifyPass> {
   /// Perform IV widening during the pass.
   bool WidenIndVars;
 
diff --git a/llvm/include/llvm/Transforms/Scalar/InductiveRangeCheckElimination.h b/llvm/include/llvm/Transforms/Scalar/InductiveRangeCheckElimination.h
index 11fb80e494867..0639c728e36c0 100644
--- a/llvm/include/llvm/Transforms/Scalar/InductiveRangeCheckElimination.h
+++ b/llvm/include/llvm/Transforms/Scalar/InductiveRangeCheckElimination.h
@@ -18,7 +18,7 @@
 
 namespace llvm {
 
-class IRCEPass : public PassInfoMixin<IRCEPass> {
+class IRCEPass : public OptionalPassInfoMixin<IRCEPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/InferAddressSpaces.h b/llvm/include/llvm/Transforms/Scalar/InferAddressSpaces.h
index 9a56b073f1c6b..ba71471de391d 100644
--- a/llvm/include/llvm/Transforms/Scalar/InferAddressSpaces.h
+++ b/llvm/include/llvm/Transforms/Scalar/InferAddressSpaces.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-struct InferAddressSpacesPass : PassInfoMixin<InferAddressSpacesPass> {
+struct InferAddressSpacesPass : OptionalPassInfoMixin<InferAddressSpacesPass> {
   InferAddressSpacesPass();
   InferAddressSpacesPass(unsigned AddressSpace);
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
diff --git a/llvm/include/llvm/Transforms/Scalar/InferAlignment.h b/llvm/include/llvm/Transforms/Scalar/InferAlignment.h
index f6fc5f3b8d987..8352485604d6c 100644
--- a/llvm/include/llvm/Transforms/Scalar/InferAlignment.h
+++ b/llvm/include/llvm/Transforms/Scalar/InferAlignment.h
@@ -18,7 +18,7 @@
 
 namespace llvm {
 
-struct InferAlignmentPass : public PassInfoMixin<InferAlignmentPass> {
+struct InferAlignmentPass : public OptionalPassInfoMixin<InferAlignmentPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Scalar/InstSimplifyPass.h b/llvm/include/llvm/Transforms/Scalar/InstSimplifyPass.h
index 09a4a95401d84..ea9285b945112 100644
--- a/llvm/include/llvm/Transforms/Scalar/InstSimplifyPass.h
+++ b/llvm/include/llvm/Transforms/Scalar/InstSimplifyPass.h
@@ -29,7 +29,7 @@ namespace llvm {
 /// restricted transform at a pass granularity. However, for a much more
 /// powerful and comprehensive peephole optimization engine, see the
 /// `instcombine` pass instead.
-class InstSimplifyPass : public PassInfoMixin<InstSimplifyPass> {
+class InstSimplifyPass : public OptionalPassInfoMixin<InstSimplifyPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/JumpTableToSwitch.h b/llvm/include/llvm/Transforms/Scalar/JumpTableToSwitch.h
index dfd6e2f3d03ae..88ff749e1a8f6 100644
--- a/llvm/include/llvm/Transforms/Scalar/JumpTableToSwitch.h
+++ b/llvm/include/llvm/Transforms/Scalar/JumpTableToSwitch.h
@@ -15,7 +15,8 @@ namespace llvm {
 
 class Function;
 
-class JumpTableToSwitchPass : public PassInfoMixin<JumpTableToSwitchPass> {
+class JumpTableToSwitchPass
+    : public OptionalPassInfoMixin<JumpTableToSwitchPass> {
   // Necessary until we switch to GUIDs as metadata, after which we can drop it.
   const bool InLTO;
 
diff --git a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
index 348cefb4360e4..f660095bbd7ee 100644
--- a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
+++ b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
@@ -76,7 +76,7 @@ enum ConstantPreference { WantInteger, WantBlockAddress };
 ///
 /// In this case, the unconditional branch at the end of the first if can be
 /// revectored to the false side of the second if.
-class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
+class JumpThreadingPass : public OptionalPassInfoMixin<JumpThreadingPass> {
   Function *F = nullptr;
   FunctionAnalysisManager *FAM = nullptr;
   TargetLibraryInfo *TLI = nullptr;
diff --git a/llvm/include/llvm/Transforms/Scalar/LICM.h b/llvm/include/llvm/Transforms/Scalar/LICM.h
index f7dd40be47e58..d47c61054778c 100644
--- a/llvm/include/llvm/Transforms/Scalar/LICM.h
+++ b/llvm/include/llvm/Transforms/Scalar/LICM.h
@@ -63,7 +63,7 @@ struct LICMOptions {
 };
 
 /// Performs Loop Invariant Code Motion Pass.
-class LICMPass : public PassInfoMixin<LICMPass> {
+class LICMPass : public OptionalPassInfoMixin<LICMPass> {
   LICMOptions Opts;
 
 public:
@@ -81,7 +81,7 @@ class LICMPass : public PassInfoMixin<LICMPass> {
 };
 
 /// Performs LoopNest Invariant Code Motion Pass.
-class LNICMPass : public PassInfoMixin<LNICMPass> {
+class LNICMPass : public OptionalPassInfoMixin<LNICMPass> {
   LICMOptions Opts;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h b/llvm/include/llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h
index 44ba3c24f6afb..de4be2860eb66 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h
@@ -18,7 +18,7 @@ class raw_ostream;
 
 /// Printer pass for the \c LoopAccessInfo results.
 class LoopAccessInfoPrinterPass
-    : public PassInfoMixin<LoopAccessInfoPrinterPass> {
+    : public MandatoryPassInfoMixin<LoopAccessInfoPrinterPass> {
   raw_ostream &OS;
   bool AllowPartial;
 
@@ -26,7 +26,6 @@ class LoopAccessInfoPrinterPass
   explicit LoopAccessInfoPrinterPass(raw_ostream &OS, bool AllowPartial)
       : OS(OS), AllowPartial(AllowPartial) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // End llvm namespace
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopBoundSplit.h b/llvm/include/llvm/Transforms/Scalar/LoopBoundSplit.h
index 0c597bf295b2e..cc5e3cdee0ca5 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopBoundSplit.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopBoundSplit.h
@@ -31,7 +31,7 @@ class Loop;
 ///                                  C
 ///                                }
 ///                              }
-class LoopBoundSplitPass : public PassInfoMixin<LoopBoundSplitPass> {
+class LoopBoundSplitPass : public OptionalPassInfoMixin<LoopBoundSplitPass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopDataPrefetch.h b/llvm/include/llvm/Transforms/Scalar/LoopDataPrefetch.h
index d5e15ffff0750..f1b477f0ec4c5 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopDataPrefetch.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopDataPrefetch.h
@@ -20,7 +20,8 @@ namespace llvm {
 class Function;
 
 /// An optimization pass inserting data prefetches in loops.
-class LoopDataPrefetchPass : public PassInfoMixin<LoopDataPrefetchPass> {
+class LoopDataPrefetchPass
+    : public OptionalPassInfoMixin<LoopDataPrefetchPass> {
 public:
   LoopDataPrefetchPass() = default;
 
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopDeletion.h b/llvm/include/llvm/Transforms/Scalar/LoopDeletion.h
index 459a5cd3ece48..f4e8fd7f2b302 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopDeletion.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopDeletion.h
@@ -21,7 +21,7 @@ namespace llvm {
 class Loop;
 class LPMUpdater;
 
-class LoopDeletionPass : public PassInfoMixin<LoopDeletionPass> {
+class LoopDeletionPass : public OptionalPassInfoMixin<LoopDeletionPass> {
 public:
   LoopDeletionPass() = default;
 
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopDistribute.h b/llvm/include/llvm/Transforms/Scalar/LoopDistribute.h
index 1a82176490c50..bde8b2ec111dd 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopDistribute.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopDistribute.h
@@ -22,7 +22,7 @@ namespace llvm {
 
 class Function;
 
-class LoopDistributePass : public PassInfoMixin<LoopDistributePass> {
+class LoopDistributePass : public OptionalPassInfoMixin<LoopDistributePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopFlatten.h b/llvm/include/llvm/Transforms/Scalar/LoopFlatten.h
index 311b843e83b51..91a1233c243fb 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopFlatten.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopFlatten.h
@@ -20,7 +20,7 @@ namespace llvm {
 class LPMUpdater;
 class LoopNest;
 
-class LoopFlattenPass : public PassInfoMixin<LoopFlattenPass> {
+class LoopFlattenPass : public OptionalPassInfoMixin<LoopFlattenPass> {
 public:
   LoopFlattenPass() = default;
 
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopFuse.h b/llvm/include/llvm/Transforms/Scalar/LoopFuse.h
index d3a02db6bd28d..cc67aa0f33f16 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopFuse.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopFuse.h
@@ -20,7 +20,7 @@ namespace llvm {
 
 class Function;
 
-class LoopFusePass : public PassInfoMixin<LoopFusePass> {
+class LoopFusePass : public OptionalPassInfoMixin<LoopFusePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h b/llvm/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h
index 109b4520878cb..04e9285b781ea 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopIdiomRecognize.h
@@ -46,7 +46,8 @@ struct DisableLIRP {
 };
 
 /// Performs Loop Idiom Recognize Pass.
-class LoopIdiomRecognizePass : public PassInfoMixin<LoopIdiomRecognizePass> {
+class LoopIdiomRecognizePass
+    : public OptionalPassInfoMixin<LoopIdiomRecognizePass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopInstSimplify.h b/llvm/include/llvm/Transforms/Scalar/LoopInstSimplify.h
index f6e86d11ed956..2d1b2fee2e8c3 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopInstSimplify.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopInstSimplify.h
@@ -22,7 +22,8 @@ class Loop;
 class LPMUpdater;
 
 /// Performs Loop Inst Simplify Pass.
-class LoopInstSimplifyPass : public PassInfoMixin<LoopInstSimplifyPass> {
+class LoopInstSimplifyPass
+    : public OptionalPassInfoMixin<LoopInstSimplifyPass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopInterchange.h b/llvm/include/llvm/Transforms/Scalar/LoopInterchange.h
index 8fa14d747f5c0..868a4b74eee9d 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopInterchange.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopInterchange.h
@@ -17,7 +17,7 @@ namespace llvm {
 class LPMUpdater;
 class LoopNest;
 
-struct LoopInterchangePass : public PassInfoMixin<LoopInterchangePass> {
+struct LoopInterchangePass : public OptionalPassInfoMixin<LoopInterchangePass> {
   PreservedAnalyses run(LoopNest &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopLoadElimination.h b/llvm/include/llvm/Transforms/Scalar/LoopLoadElimination.h
index 65b9aabb8f518..acd0170dee235 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopLoadElimination.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopLoadElimination.h
@@ -24,7 +24,8 @@ class Function;
 
 /// Pass to forward loads in a loop around the backedge to subsequent
 /// iterations.
-struct LoopLoadEliminationPass : public PassInfoMixin<LoopLoadEliminationPass> {
+struct LoopLoadEliminationPass
+    : public OptionalPassInfoMixin<LoopLoadEliminationPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index 1842d2dc5f05a..6e4d3828803f0 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -70,7 +70,7 @@ using HasRunOnLoopT = decltype(std::declval<PassT>().run(
 template <>
 class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
                   LPMUpdater &>
-    : public PassInfoMixin<
+    : public MandatoryPassInfoMixin<
           PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
                       LPMUpdater &>> {
 public:
@@ -129,8 +129,6 @@ class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
 
   bool isEmpty() const { return LoopPasses.empty() && LoopNestPasses.empty(); }
 
-  static bool isRequired() { return true; }
-
   size_t getNumLoopPasses() const { return LoopPasses.size(); }
   size_t getNumLoopNestPasses() const { return LoopNestPasses.size(); }
 
@@ -186,7 +184,7 @@ typedef PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
 template <typename AnalysisT>
 struct RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
                            LoopStandardAnalysisResults &, LPMUpdater &>
-    : PassInfoMixin<
+    : MandatoryPassInfoMixin<
           RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
                               LoopStandardAnalysisResults &, LPMUpdater &>> {
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
@@ -396,7 +394,7 @@ std::optional<PreservedAnalyses> LoopPassManager::runSinglePass(
 /// \fn createLoopFunctionToLoopPassAdaptor to see when loop mode and loop-nest
 /// mode are used.
 class FunctionToLoopPassAdaptor
-    : public PassInfoMixin<FunctionToLoopPassAdaptor> {
+    : public MandatoryPassInfoMixin<FunctionToLoopPassAdaptor> {
 public:
   using PassConceptT =
       detail::PassConcept<Loop, LoopAnalysisManager,
@@ -417,8 +415,6 @@ class FunctionToLoopPassAdaptor
   printPipeline(raw_ostream &OS,
                 function_ref<StringRef(StringRef)> MapClassName2PassName);
 
-  static bool isRequired() { return true; }
-
   bool isLoopNestMode() const { return LoopNestMode; }
 
 private:
@@ -486,7 +482,7 @@ createFunctionToLoopPassAdaptor<LoopPassManager>(LoopPassManager &&LPM,
 }
 
 /// Pass for printing a loop's contents as textual IR.
-class PrintLoopPass : public PassInfoMixin<PrintLoopPass> {
+class PrintLoopPass : public OptionalPassInfoMixin<PrintLoopPass> {
   raw_ostream &OS;
   std::string Banner;
 
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPredication.h b/llvm/include/llvm/Transforms/Scalar/LoopPredication.h
index 83f5336034192..0d7e24d42af08 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPredication.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPredication.h
@@ -22,7 +22,7 @@ namespace llvm {
 class LPMUpdater;
 class Loop;
 /// Performs Loop Predication Pass.
-class LoopPredicationPass : public PassInfoMixin<LoopPredicationPass> {
+class LoopPredicationPass : public OptionalPassInfoMixin<LoopPredicationPass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopRotation.h b/llvm/include/llvm/Transforms/Scalar/LoopRotation.h
index 256345b26d57c..58c879e3447f9 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopRotation.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopRotation.h
@@ -21,7 +21,7 @@ class LPMUpdater;
 class Loop;
 
 /// A simple loop rotation transformation.
-class LoopRotatePass : public PassInfoMixin<LoopRotatePass> {
+class LoopRotatePass : public OptionalPassInfoMixin<LoopRotatePass> {
 public:
   LoopRotatePass(bool EnableHeaderDuplication = true,
                  bool PrepareForLTO = false, bool CheckExitCount = false);
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopSimplifyCFG.h b/llvm/include/llvm/Transforms/Scalar/LoopSimplifyCFG.h
index 82c8a4406d00a..c3c1de80ae3e7 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopSimplifyCFG.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopSimplifyCFG.h
@@ -25,7 +25,7 @@ class LPMUpdater;
 class Loop;
 
 /// Performs basic CFG simplifications to assist other loop passes.
-class LoopSimplifyCFGPass : public PassInfoMixin<LoopSimplifyCFGPass> {
+class LoopSimplifyCFGPass : public OptionalPassInfoMixin<LoopSimplifyCFGPass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopSink.h b/llvm/include/llvm/Transforms/Scalar/LoopSink.h
index 26e50590a6257..8b455c79006b6 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopSink.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopSink.h
@@ -30,7 +30,7 @@ class Function;
 /// We do this as a separate pass so that during normal optimization all
 /// invariant operations can be held outside the loop body to simplify
 /// fundamental analyses and transforms of the loop.
-class LoopSinkPass : public PassInfoMixin<LoopSinkPass> {
+class LoopSinkPass : public OptionalPassInfoMixin<LoopSinkPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopStrengthReduce.h b/llvm/include/llvm/Transforms/Scalar/LoopStrengthReduce.h
index 5cf805bc49393..27a565d943334 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopStrengthReduce.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopStrengthReduce.h
@@ -30,7 +30,8 @@ class Loop;
 class LPMUpdater;
 
 /// Performs Loop Strength Reduce Pass.
-class LoopStrengthReducePass : public PassInfoMixin<LoopStrengthReducePass> {
+class LoopStrengthReducePass
+    : public OptionalPassInfoMixin<LoopStrengthReducePass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopTermFold.h b/llvm/include/llvm/Transforms/Scalar/LoopTermFold.h
index 974024c586aa8..044d29f2f7f4b 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopTermFold.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopTermFold.h
@@ -19,7 +19,7 @@ namespace llvm {
 class Loop;
 class LPMUpdater;
 
-class LoopTermFoldPass : public PassInfoMixin<LoopTermFoldPass> {
+class LoopTermFoldPass : public OptionalPassInfoMixin<LoopTermFoldPass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopUnrollAndJamPass.h b/llvm/include/llvm/Transforms/Scalar/LoopUnrollAndJamPass.h
index 54f70d7ed4b39..c59cbe457fc24 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopUnrollAndJamPass.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopUnrollAndJamPass.h
@@ -17,7 +17,8 @@ class LPMUpdater;
 class LoopNest;
 
 /// A simple loop rotation transformation.
-class LoopUnrollAndJamPass : public PassInfoMixin<LoopUnrollAndJamPass> {
+class LoopUnrollAndJamPass
+    : public OptionalPassInfoMixin<LoopUnrollAndJamPass> {
   const int OptLevel;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h b/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
index 8d8c2f254f02f..1c9a4e79013ab 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopUnrollPass.h
@@ -23,7 +23,7 @@ class Loop;
 class LPMUpdater;
 
 /// Loop unroll pass that only does full loop unrolling and peeling.
-class LoopFullUnrollPass : public PassInfoMixin<LoopFullUnrollPass> {
+class LoopFullUnrollPass : public OptionalPassInfoMixin<LoopFullUnrollPass> {
   const int OptLevel;
 
   /// If false, use a cost model to determine whether unrolling of a loop is
@@ -130,7 +130,7 @@ struct LoopUnrollOptions {
 /// Loop unroll pass that will support both full and partial unrolling.
 /// It is a function pass to have access to function and module analyses.
 /// It will also put loops into canonical form (simplified and LCSSA).
-class LoopUnrollPass : public PassInfoMixin<LoopUnrollPass> {
+class LoopUnrollPass : public OptionalPassInfoMixin<LoopUnrollPass> {
   LoopUnrollOptions UnrollOpts;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopVersioningLICM.h b/llvm/include/llvm/Transforms/Scalar/LoopVersioningLICM.h
index 04e0012330da7..a11754df7acda 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopVersioningLICM.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopVersioningLICM.h
@@ -16,7 +16,8 @@ namespace llvm {
 class LPMUpdater;
 class Loop;
 
-class LoopVersioningLICMPass : public PassInfoMixin<LoopVersioningLICMPass> {
+class LoopVersioningLICMPass
+    : public OptionalPassInfoMixin<LoopVersioningLICMPass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &LAR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Scalar/LowerAtomicPass.h b/llvm/include/llvm/Transforms/Scalar/LowerAtomicPass.h
index 60bbf916fced4..e4bab58b297a3 100644
--- a/llvm/include/llvm/Transforms/Scalar/LowerAtomicPass.h
+++ b/llvm/include/llvm/Transforms/Scalar/LowerAtomicPass.h
@@ -19,12 +19,10 @@
 namespace llvm {
 
 /// A pass that lowers atomic intrinsic into non-atomic intrinsics.
-class LowerAtomicPass : public PassInfoMixin<LowerAtomicPass> {
+class LowerAtomicPass : public MandatoryPassInfoMixin<LowerAtomicPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
-  static bool isRequired() { return true; }
 };
-
 }
 
 #endif // LLVM_TRANSFORMS_SCALAR_LOWERATOMICPASS_H
diff --git a/llvm/include/llvm/Transforms/Scalar/LowerConstantIntrinsics.h b/llvm/include/llvm/Transforms/Scalar/LowerConstantIntrinsics.h
index 3d4d1034c0b24..01f23a425fd5c 100644
--- a/llvm/include/llvm/Transforms/Scalar/LowerConstantIntrinsics.h
+++ b/llvm/include/llvm/Transforms/Scalar/LowerConstantIntrinsics.h
@@ -26,8 +26,8 @@ class TargetLibraryInfo;
 bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI,
                              DominatorTree *DT);
 
-struct LowerConstantIntrinsicsPass :
-    PassInfoMixin<LowerConstantIntrinsicsPass> {
+struct LowerConstantIntrinsicsPass
+    : OptionalPassInfoMixin<LowerConstantIntrinsicsPass> {
 public:
   explicit LowerConstantIntrinsicsPass() = default;
 
@@ -41,7 +41,6 @@ struct LowerConstantIntrinsicsPass :
   /// Instruction Combination passes of the optimized pass chain.
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
 };
-
 }
 
 #endif
diff --git a/llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h b/llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
index 7df903f15e4ec..acb8048ba98fe 100644
--- a/llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
+++ b/llvm/include/llvm/Transforms/Scalar/LowerExpectIntrinsic.h
@@ -22,7 +22,8 @@ namespace llvm {
 
 class Function;
 
-struct LowerExpectIntrinsicPass : PassInfoMixin<LowerExpectIntrinsicPass> {
+struct LowerExpectIntrinsicPass
+    : OptionalPassInfoMixin<LowerExpectIntrinsicPass> {
   /// Run the pass over the function.
   ///
   /// This will lower all of the expect intrinsic calls in this function into
@@ -32,7 +33,6 @@ struct LowerExpectIntrinsicPass : PassInfoMixin<LowerExpectIntrinsicPass> {
   /// ignore them.
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
 };
-
 }
 
 #endif
diff --git a/llvm/include/llvm/Transforms/Scalar/LowerGuardIntrinsic.h b/llvm/include/llvm/Transforms/Scalar/LowerGuardIntrinsic.h
index 0c885b957b0fb..605753a2be596 100644
--- a/llvm/include/llvm/Transforms/Scalar/LowerGuardIntrinsic.h
+++ b/llvm/include/llvm/Transforms/Scalar/LowerGuardIntrinsic.h
@@ -18,10 +18,10 @@
 
 namespace llvm {
 
-struct LowerGuardIntrinsicPass : PassInfoMixin<LowerGuardIntrinsicPass> {
+struct LowerGuardIntrinsicPass
+    : OptionalPassInfoMixin<LowerGuardIntrinsicPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
-
 }
 
 #endif // LLVM_TRANSFORMS_SCALAR_LOWERGUARDINTRINSIC_H
diff --git a/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h b/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h
index d44d297dd4ffc..aff39ae6d95e6 100644
--- a/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h
+++ b/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h
@@ -17,7 +17,7 @@
 
 namespace llvm {
 class LowerMatrixIntrinsicsPass
-    : public PassInfoMixin<LowerMatrixIntrinsicsPass> {
+    : public MandatoryPassInfoMixin<LowerMatrixIntrinsicsPass> {
   bool Minimal;
 
 public:
@@ -25,7 +25,6 @@ class LowerMatrixIntrinsicsPass
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
   void printPipeline(raw_ostream &OS,
                      function_ref<StringRef(StringRef)> MapClassName2PassName);
-  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/include/llvm/Transforms/Scalar/LowerWidenableCondition.h b/llvm/include/llvm/Transforms/Scalar/LowerWidenableCondition.h
index 81c6f00e27fdf..82b02a7ea594a 100644
--- a/llvm/include/llvm/Transforms/Scalar/LowerWidenableCondition.h
+++ b/llvm/include/llvm/Transforms/Scalar/LowerWidenableCondition.h
@@ -17,10 +17,10 @@
 
 namespace llvm {
 
-struct LowerWidenableConditionPass : PassInfoMixin<LowerWidenableConditionPass> {
+struct LowerWidenableConditionPass
+    : OptionalPassInfoMixin<LowerWidenableConditionPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
-
 }
 
 #endif // LLVM_TRANSFORMS_SCALAR_LOWERWIDENABLECONDITION_H
diff --git a/llvm/include/llvm/Transforms/Scalar/MakeGuardsExplicit.h b/llvm/include/llvm/Transforms/Scalar/MakeGuardsExplicit.h
index a20b31f3ab5e8..6d4423f7cedd7 100644
--- a/llvm/include/llvm/Transforms/Scalar/MakeGuardsExplicit.h
+++ b/llvm/include/llvm/Transforms/Scalar/MakeGuardsExplicit.h
@@ -37,7 +37,8 @@
 
 namespace llvm {
 
-struct MakeGuardsExplicitPass : public PassInfoMixin<MakeGuardsExplicitPass> {
+struct MakeGuardsExplicitPass
+    : public OptionalPassInfoMixin<MakeGuardsExplicitPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h b/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
index f58a87f4484d0..1affd5a55a35f 100644
--- a/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
+++ b/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
@@ -42,7 +42,7 @@ class TargetLibraryInfo;
 class TypeSize;
 class Value;
 
-class MemCpyOptPass : public PassInfoMixin<MemCpyOptPass> {
+class MemCpyOptPass : public OptionalPassInfoMixin<MemCpyOptPass> {
   TargetLibraryInfo *TLI = nullptr;
   AAResults *AA = nullptr;
   AssumptionCache *AC = nullptr;
diff --git a/llvm/include/llvm/Transforms/Scalar/MergeICmps.h b/llvm/include/llvm/Transforms/Scalar/MergeICmps.h
index 63bdbf8f4d095..641fa12e94fae 100644
--- a/llvm/include/llvm/Transforms/Scalar/MergeICmps.h
+++ b/llvm/include/llvm/Transforms/Scalar/MergeICmps.h
@@ -15,8 +15,7 @@ namespace llvm {
 
 class Function;
 
-struct MergeICmpsPass
-    : PassInfoMixin<MergeICmpsPass> {
+struct MergeICmpsPass : OptionalPassInfoMixin<MergeICmpsPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h b/llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h
index 71e11e59a4712..2d285bf15baf7 100644
--- a/llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h
+++ b/llvm/include/llvm/Transforms/Scalar/MergedLoadStoreMotion.h
@@ -40,7 +40,7 @@ struct MergedLoadStoreMotionOptions {
 };
 
 class MergedLoadStoreMotionPass
-    : public PassInfoMixin<MergedLoadStoreMotionPass> {
+    : public OptionalPassInfoMixin<MergedLoadStoreMotionPass> {
   MergedLoadStoreMotionOptions Options;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Scalar/NaryReassociate.h b/llvm/include/llvm/Transforms/Scalar/NaryReassociate.h
index 417801d470800..9866d0b854a03 100644
--- a/llvm/include/llvm/Transforms/Scalar/NaryReassociate.h
+++ b/llvm/include/llvm/Transforms/Scalar/NaryReassociate.h
@@ -98,7 +98,7 @@ class TargetTransformInfo;
 class Type;
 class Value;
 
-class NaryReassociatePass : public PassInfoMixin<NaryReassociatePass> {
+class NaryReassociatePass : public OptionalPassInfoMixin<NaryReassociatePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
diff --git a/llvm/include/llvm/Transforms/Scalar/NewGVN.h b/llvm/include/llvm/Transforms/Scalar/NewGVN.h
index 1f3680fec79cf..0bd33552cd23c 100644
--- a/llvm/include/llvm/Transforms/Scalar/NewGVN.h
+++ b/llvm/include/llvm/Transforms/Scalar/NewGVN.h
@@ -20,7 +20,7 @@ namespace llvm {
 
 class Function;
 
-class NewGVNPass : public PassInfoMixin<NewGVNPass> {
+class NewGVNPass : public OptionalPassInfoMixin<NewGVNPass> {
 public:
   /// Run the pass over the function.
   PreservedAnalyses run(Function &F, AnalysisManager<Function> &AM);
diff --git a/llvm/include/llvm/Transforms/Scalar/PartiallyInlineLibCalls.h b/llvm/include/llvm/Transforms/Scalar/PartiallyInlineLibCalls.h
index b8a8fcc71e57c..02ed6a1c2f3cc 100644
--- a/llvm/include/llvm/Transforms/Scalar/PartiallyInlineLibCalls.h
+++ b/llvm/include/llvm/Transforms/Scalar/PartiallyInlineLibCalls.h
@@ -20,7 +20,7 @@
 namespace llvm {
 class Function;
 class PartiallyInlineLibCallsPass
-    : public PassInfoMixin<PartiallyInlineLibCallsPass> {
+    : public OptionalPassInfoMixin<PartiallyInlineLibCallsPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/PlaceSafepoints.h b/llvm/include/llvm/Transforms/Scalar/PlaceSafepoints.h
index 60ffe6e58b11b..00c8ed2167767 100644
--- a/llvm/include/llvm/Transforms/Scalar/PlaceSafepoints.h
+++ b/llvm/include/llvm/Transforms/Scalar/PlaceSafepoints.h
@@ -56,7 +56,7 @@ namespace llvm {
 
 class TargetLibraryInfo;
 
-class PlaceSafepointsPass : public PassInfoMixin<PlaceSafepointsPass> {
+class PlaceSafepointsPass : public OptionalPassInfoMixin<PlaceSafepointsPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
diff --git a/llvm/include/llvm/Transforms/Scalar/Reassociate.h b/llvm/include/llvm/Transforms/Scalar/Reassociate.h
index 749f6ee34346d..267139f30fce6 100644
--- a/llvm/include/llvm/Transforms/Scalar/Reassociate.h
+++ b/llvm/include/llvm/Transforms/Scalar/Reassociate.h
@@ -71,7 +71,7 @@ class XorOpnd;
 } // end namespace reassociate
 
 /// Reassociate commutative expressions.
-class ReassociatePass : public PassInfoMixin<ReassociatePass> {
+class ReassociatePass : public OptionalPassInfoMixin<ReassociatePass> {
 public:
   using OrderedSet =
       SetVector<AssertingVH<Instruction>, std::deque<AssertingVH<Instruction>>>;
diff --git a/llvm/include/llvm/Transforms/Scalar/Reg2Mem.h b/llvm/include/llvm/Transforms/Scalar/Reg2Mem.h
index 25f6563d7dcfc..e3d8b5fe1b3c5 100644
--- a/llvm/include/llvm/Transforms/Scalar/Reg2Mem.h
+++ b/llvm/include/llvm/Transforms/Scalar/Reg2Mem.h
@@ -17,7 +17,7 @@
 
 namespace llvm {
 
-class RegToMemPass : public PassInfoMixin<RegToMemPass> {
+class RegToMemPass : public OptionalPassInfoMixin<RegToMemPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/RewriteStatepointsForGC.h b/llvm/include/llvm/Transforms/Scalar/RewriteStatepointsForGC.h
index 29845ce3b62da..560ba61e9fcc1 100644
--- a/llvm/include/llvm/Transforms/Scalar/RewriteStatepointsForGC.h
+++ b/llvm/include/llvm/Transforms/Scalar/RewriteStatepointsForGC.h
@@ -26,7 +26,8 @@ class Module;
 class TargetTransformInfo;
 class TargetLibraryInfo;
 
-struct RewriteStatepointsForGC : public PassInfoMixin<RewriteStatepointsForGC> {
+struct RewriteStatepointsForGC
+    : public OptionalPassInfoMixin<RewriteStatepointsForGC> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 
   bool runOnFunction(Function &F, DominatorTree &, TargetTransformInfo &,
diff --git a/llvm/include/llvm/Transforms/Scalar/SCCP.h b/llvm/include/llvm/Transforms/Scalar/SCCP.h
index d45dca97d12d6..7a0810e0bd64c 100644
--- a/llvm/include/llvm/Transforms/Scalar/SCCP.h
+++ b/llvm/include/llvm/Transforms/Scalar/SCCP.h
@@ -27,7 +27,7 @@ namespace llvm {
 class Function;
 
 /// This pass performs function-level constant propagation and merging.
-class SCCPPass : public PassInfoMixin<SCCPPass> {
+class SCCPPass : public OptionalPassInfoMixin<SCCPPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/SROA.h b/llvm/include/llvm/Transforms/Scalar/SROA.h
index 8bb65bf7225e0..a4ce06acb1208 100644
--- a/llvm/include/llvm/Transforms/Scalar/SROA.h
+++ b/llvm/include/llvm/Transforms/Scalar/SROA.h
@@ -23,7 +23,7 @@ class Function;
 
 enum class SROAOptions : bool { ModifyCFG, PreserveCFG };
 
-class SROAPass : public PassInfoMixin<SROAPass> {
+class SROAPass : public OptionalPassInfoMixin<SROAPass> {
   const SROAOptions PreserveCFG;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h b/llvm/include/llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h
index 5e876fc82ac17..36818e0db54bd 100644
--- a/llvm/include/llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h
+++ b/llvm/include/llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h
@@ -21,7 +21,7 @@
 namespace llvm {
 
 struct ScalarizeMaskedMemIntrinPass
-    : public PassInfoMixin<ScalarizeMaskedMemIntrinPass> {
+    : public OptionalPassInfoMixin<ScalarizeMaskedMemIntrinPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 } // end namespace llvm
diff --git a/llvm/include/llvm/Transforms/Scalar/Scalarizer.h b/llvm/include/llvm/Transforms/Scalar/Scalarizer.h
index 35c9adbe17677..68c350d875ed0 100644
--- a/llvm/include/llvm/Transforms/Scalar/Scalarizer.h
+++ b/llvm/include/llvm/Transforms/Scalar/Scalarizer.h
@@ -48,7 +48,7 @@ struct ScalarizerPassOptions {
   bool ScalarizeLoadStore = false;
 };
 
-class ScalarizerPass : public PassInfoMixin<ScalarizerPass> {
+class ScalarizerPass : public OptionalPassInfoMixin<ScalarizerPass> {
   ScalarizerPassOptions Options;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h b/llvm/include/llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h
index 7b37eb7118a04..ec9e9cb847a35 100644
--- a/llvm/include/llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h
+++ b/llvm/include/llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class SeparateConstOffsetFromGEPPass
-    : public PassInfoMixin<SeparateConstOffsetFromGEPPass> {
+    : public OptionalPassInfoMixin<SeparateConstOffsetFromGEPPass> {
   bool LowerGEP;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h b/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h
index 0cc49e4755257..f38fa2b95b3ca 100644
--- a/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h
+++ b/llvm/include/llvm/Transforms/Scalar/SimpleLoopUnswitch.h
@@ -65,7 +65,8 @@ class raw_ostream;
 /// Because partial unswitching of switches is extremely unlikely to be possible
 /// in practice and significantly complicates the implementation, this pass does
 /// not currently implement that in any mode.
-class SimpleLoopUnswitchPass : public PassInfoMixin<SimpleLoopUnswitchPass> {
+class SimpleLoopUnswitchPass
+    : public OptionalPassInfoMixin<SimpleLoopUnswitchPass> {
   bool NonTrivial;
   bool Trivial;
 
diff --git a/llvm/include/llvm/Transforms/Scalar/SimplifyCFG.h b/llvm/include/llvm/Transforms/Scalar/SimplifyCFG.h
index b2b7f4619da82..c1219107f0939 100644
--- a/llvm/include/llvm/Transforms/Scalar/SimplifyCFG.h
+++ b/llvm/include/llvm/Transforms/Scalar/SimplifyCFG.h
@@ -27,7 +27,7 @@ namespace llvm {
 /// or remove control flow to put the CFG into a canonical form expected by
 /// other passes of the mid-level optimizer. Depending on the specified options,
 /// it may further optimize control-flow to create non-canonical forms.
-class SimplifyCFGPass : public PassInfoMixin<SimplifyCFGPass> {
+class SimplifyCFGPass : public OptionalPassInfoMixin<SimplifyCFGPass> {
   SimplifyCFGOptions Options;
 
 public:
@@ -47,7 +47,6 @@ class SimplifyCFGPass : public PassInfoMixin<SimplifyCFGPass> {
   printPipeline(raw_ostream &OS,
                 function_ref<StringRef(StringRef)> MapClassName2PassName);
 };
-
 }
 
 #endif
diff --git a/llvm/include/llvm/Transforms/Scalar/Sink.h b/llvm/include/llvm/Transforms/Scalar/Sink.h
index 759153f22853d..eca098015d8f6 100644
--- a/llvm/include/llvm/Transforms/Scalar/Sink.h
+++ b/llvm/include/llvm/Transforms/Scalar/Sink.h
@@ -21,7 +21,7 @@ namespace llvm {
 class Function;
 
 /// Move instructions into successor blocks when possible.
-class SinkingPass : public PassInfoMixin<SinkingPass> {
+class SinkingPass : public OptionalPassInfoMixin<SinkingPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h b/llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
index 168e0c3bb9521..1332caefd84f5 100644
--- a/llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
+++ b/llvm/include/llvm/Transforms/Scalar/SpeculativeExecution.h
@@ -69,7 +69,7 @@ class BasicBlock;
 class TargetTransformInfo;
 
 class SpeculativeExecutionPass
-    : public PassInfoMixin<SpeculativeExecutionPass> {
+    : public OptionalPassInfoMixin<SpeculativeExecutionPass> {
 public:
   SpeculativeExecutionPass(bool OnlyIfDivergentTarget = false);
 
diff --git a/llvm/include/llvm/Transforms/Scalar/StraightLineStrengthReduce.h b/llvm/include/llvm/Transforms/Scalar/StraightLineStrengthReduce.h
index 11233cc65efac..9157c673c7192 100644
--- a/llvm/include/llvm/Transforms/Scalar/StraightLineStrengthReduce.h
+++ b/llvm/include/llvm/Transforms/Scalar/StraightLineStrengthReduce.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class StraightLineStrengthReducePass
-    : public PassInfoMixin<StraightLineStrengthReducePass> {
+    : public OptionalPassInfoMixin<StraightLineStrengthReducePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/StructurizeCFG.h b/llvm/include/llvm/Transforms/Scalar/StructurizeCFG.h
index f68067d935458..51f2fcd7aa524 100644
--- a/llvm/include/llvm/Transforms/Scalar/StructurizeCFG.h
+++ b/llvm/include/llvm/Transforms/Scalar/StructurizeCFG.h
@@ -12,7 +12,7 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-struct StructurizeCFGPass : PassInfoMixin<StructurizeCFGPass> {
+struct StructurizeCFGPass : OptionalPassInfoMixin<StructurizeCFGPass> {
 private:
   bool SkipUniformRegions;
 
diff --git a/llvm/include/llvm/Transforms/Scalar/TailRecursionElimination.h b/llvm/include/llvm/Transforms/Scalar/TailRecursionElimination.h
index 22a70cd66865a..f4b02c5214e4a 100644
--- a/llvm/include/llvm/Transforms/Scalar/TailRecursionElimination.h
+++ b/llvm/include/llvm/Transforms/Scalar/TailRecursionElimination.h
@@ -58,7 +58,7 @@ namespace llvm {
 
 class Function;
 
-class TailCallElimPass : public PassInfoMixin<TailCallElimPass> {
+class TailCallElimPass : public OptionalPassInfoMixin<TailCallElimPass> {
   const bool UpdateFunctionEntryCount;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Scalar/WarnMissedTransforms.h b/llvm/include/llvm/Transforms/Scalar/WarnMissedTransforms.h
index 8f8cad0aab6de..b876aa2489743 100644
--- a/llvm/include/llvm/Transforms/Scalar/WarnMissedTransforms.h
+++ b/llvm/include/llvm/Transforms/Scalar/WarnMissedTransforms.h
@@ -18,7 +18,7 @@
 namespace llvm {
 // New pass manager boilerplate.
 class WarnMissedTransformationsPass
-    : public PassInfoMixin<WarnMissedTransformationsPass> {
+    : public OptionalPassInfoMixin<WarnMissedTransformationsPass> {
 public:
   explicit WarnMissedTransformationsPass() = default;
 
diff --git a/llvm/include/llvm/Transforms/Utils/AddDiscriminators.h b/llvm/include/llvm/Transforms/Utils/AddDiscriminators.h
index 0aee2fe95cad3..13f7c0cb671f1 100644
--- a/llvm/include/llvm/Transforms/Utils/AddDiscriminators.h
+++ b/llvm/include/llvm/Transforms/Utils/AddDiscriminators.h
@@ -21,10 +21,10 @@ namespace llvm {
 
 class Function;
 
-class AddDiscriminatorsPass : public PassInfoMixin<AddDiscriminatorsPass> {
+class AddDiscriminatorsPass
+    : public MandatoryPassInfoMixin<AddDiscriminatorsPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/AssumeBundleBuilder.h b/llvm/include/llvm/Transforms/Utils/AssumeBundleBuilder.h
index eb91367dfdce0..2f45a1c5f5b67 100644
--- a/llvm/include/llvm/Transforms/Utils/AssumeBundleBuilder.h
+++ b/llvm/include/llvm/Transforms/Utils/AssumeBundleBuilder.h
@@ -56,13 +56,13 @@ buildAssumeFromKnowledge(ArrayRef<RetainedKnowledge> Knowledge,
 
 /// This pass attempts to minimize the number of assume without loosing any
 /// information.
-struct AssumeSimplifyPass : public PassInfoMixin<AssumeSimplifyPass> {
+struct AssumeSimplifyPass : public OptionalPassInfoMixin<AssumeSimplifyPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 /// This pass will try to build an llvm.assume for every instruction in the
 /// function. Its main purpose is testing.
-struct AssumeBuilderPass : public PassInfoMixin<AssumeBuilderPass> {
+struct AssumeBuilderPass : public OptionalPassInfoMixin<AssumeBuilderPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Utils/BreakCriticalEdges.h b/llvm/include/llvm/Transforms/Utils/BreakCriticalEdges.h
index 6de080ce31281..084716884eb93 100644
--- a/llvm/include/llvm/Transforms/Utils/BreakCriticalEdges.h
+++ b/llvm/include/llvm/Transforms/Utils/BreakCriticalEdges.h
@@ -22,7 +22,8 @@
 namespace llvm {
 
 class Function;
-struct BreakCriticalEdgesPass : public PassInfoMixin<BreakCriticalEdgesPass> {
+struct BreakCriticalEdgesPass
+    : public OptionalPassInfoMixin<BreakCriticalEdgesPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/CanonicalizeAliases.h b/llvm/include/llvm/Transforms/Utils/CanonicalizeAliases.h
index 0bdc1a12d1fb0..52bdad00339fd 100644
--- a/llvm/include/llvm/Transforms/Utils/CanonicalizeAliases.h
+++ b/llvm/include/llvm/Transforms/Utils/CanonicalizeAliases.h
@@ -20,7 +20,8 @@ namespace llvm {
 class Module;
 
 /// Simple pass that canonicalizes aliases.
-class CanonicalizeAliasesPass : public PassInfoMixin<CanonicalizeAliasesPass> {
+class CanonicalizeAliasesPass
+    : public OptionalPassInfoMixin<CanonicalizeAliasesPass> {
 public:
   CanonicalizeAliasesPass() = default;
 
diff --git a/llvm/include/llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h b/llvm/include/llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h
index 924b6cdf7ca0b..71adde3f28ee3 100644
--- a/llvm/include/llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h
+++ b/llvm/include/llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h
@@ -22,7 +22,7 @@ class LPMUpdater;
 
 /// A pass that canonicalizes freeze instructions in a loop.
 class CanonicalizeFreezeInLoopsPass
-    : public PassInfoMixin<CanonicalizeFreezeInLoopsPass> {
+    : public OptionalPassInfoMixin<CanonicalizeFreezeInLoopsPass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Transforms/Utils/CountVisits.h b/llvm/include/llvm/Transforms/Utils/CountVisits.h
index 7000afbc4985b..576ba10eed3ba 100644
--- a/llvm/include/llvm/Transforms/Utils/CountVisits.h
+++ b/llvm/include/llvm/Transforms/Utils/CountVisits.h
@@ -16,7 +16,7 @@ namespace llvm {
 
 class Function;
 
-struct CountVisitsPass : PassInfoMixin<CountVisitsPass> {
+struct CountVisitsPass : OptionalPassInfoMixin<CountVisitsPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
 
 private:
diff --git a/llvm/include/llvm/Transforms/Utils/DXILUpgrade.h b/llvm/include/llvm/Transforms/Utils/DXILUpgrade.h
index 4c74976093f1f..d0152a6217b81 100644
--- a/llvm/include/llvm/Transforms/Utils/DXILUpgrade.h
+++ b/llvm/include/llvm/Transforms/Utils/DXILUpgrade.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 /// Upgrade DXIL-style metadata into their LLVM representations
-class DXILUpgradePass : public PassInfoMixin<DXILUpgradePass> {
+class DXILUpgradePass : public OptionalPassInfoMixin<DXILUpgradePass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/Debugify.h b/llvm/include/llvm/Transforms/Utils/Debugify.h
index 64404efabed1b..9787ad1c8b500 100644
--- a/llvm/include/llvm/Transforms/Utils/Debugify.h
+++ b/llvm/include/llvm/Transforms/Utils/Debugify.h
@@ -106,7 +106,8 @@ LLVM_ABI llvm::FunctionPass *createDebugifyFunctionPass(
     llvm::StringRef NameOfWrappedPass = "",
     DebugInfoPerPass *DebugInfoBeforePass = nullptr);
 
-class NewPMDebugifyPass : public llvm::PassInfoMixin<NewPMDebugifyPass> {
+class NewPMDebugifyPass
+    : public llvm::OptionalPassInfoMixin<NewPMDebugifyPass> {
   llvm::StringRef NameOfWrappedPass;
   DebugInfoPerPass *DebugInfoBeforePass = nullptr;
   enum DebugifyMode Mode = DebugifyMode::NoDebugify;
@@ -166,7 +167,7 @@ LLVM_ABI llvm::FunctionPass *createCheckDebugifyFunctionPass(
     llvm::StringRef OrigDIVerifyBugsReportFilePath = "");
 
 class NewPMCheckDebugifyPass
-    : public llvm::PassInfoMixin<NewPMCheckDebugifyPass> {
+    : public llvm::OptionalPassInfoMixin<NewPMCheckDebugifyPass> {
   llvm::StringRef NameOfWrappedPass;
   llvm::StringRef OrigDIVerifyBugsReportFilePath;
   DebugifyStatsMap *StatsMap;
diff --git a/llvm/include/llvm/Transforms/Utils/DeclareRuntimeLibcalls.h b/llvm/include/llvm/Transforms/Utils/DeclareRuntimeLibcalls.h
index 295e3dec31415..4515dbfbd5df2 100644
--- a/llvm/include/llvm/Transforms/Utils/DeclareRuntimeLibcalls.h
+++ b/llvm/include/llvm/Transforms/Utils/DeclareRuntimeLibcalls.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class DeclareRuntimeLibcallsPass
-    : public PassInfoMixin<DeclareRuntimeLibcallsPass> {
+    : public OptionalPassInfoMixin<DeclareRuntimeLibcallsPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h b/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
index f2b038494a5db..a0d4cdeacb5c8 100644
--- a/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
+++ b/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
@@ -22,7 +22,7 @@ namespace llvm {
 class Function;
 
 struct EntryExitInstrumenterPass
-    : public PassInfoMixin<EntryExitInstrumenterPass> {
+    : public MandatoryPassInfoMixin<EntryExitInstrumenterPass> {
   EntryExitInstrumenterPass(bool PostInlining) : PostInlining(PostInlining) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
@@ -31,8 +31,6 @@ struct EntryExitInstrumenterPass
                      function_ref<StringRef(StringRef)> MapClassName2PassName);
 
   bool PostInlining;
-
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h b/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h
index e1f8065f8011d..49c3e1d940e3f 100644
--- a/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h
+++ b/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h
@@ -56,7 +56,7 @@ template <typename MarkerTy> struct ShouldRunExtraPasses {
 /// simplifications after loop-vectorization, if runtime checks have been added.
 template <typename MarkerTy>
 class ExtraFunctionPassManager
-    : public PassInfoMixin<ExtraFunctionPassManager<MarkerTy>> {
+    : public MandatoryPassInfoMixin<ExtraFunctionPassManager<MarkerTy>> {
   FunctionPassManager InnerFPM;
 
 public:
@@ -71,8 +71,6 @@ class ExtraFunctionPassManager
     PA.abandon<MarkerTy>();
     return PA;
   }
-
-  static bool isRequired() { return true; }
 };
 
 /// A pass manager to run a set of extra loop passes if the MarkerTy analysis is
@@ -80,7 +78,7 @@ class ExtraFunctionPassManager
 /// An example is doing additional runs of SimpleLoopUnswitch.
 template <typename MarkerTy>
 class ExtraLoopPassManager
-    : public PassInfoMixin<ExtraLoopPassManager<MarkerTy>> {
+    : public MandatoryPassInfoMixin<ExtraLoopPassManager<MarkerTy>> {
   LoopPassManager InnerLPM;
 
 public:
@@ -96,8 +94,6 @@ class ExtraLoopPassManager
     PA.abandon<MarkerTy>();
     return PA;
   }
-
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/FixIrreducible.h b/llvm/include/llvm/Transforms/Utils/FixIrreducible.h
index 0c00b7bdbaf9a..8f9d4b24a5b9c 100644
--- a/llvm/include/llvm/Transforms/Utils/FixIrreducible.h
+++ b/llvm/include/llvm/Transforms/Utils/FixIrreducible.h
@@ -12,7 +12,7 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-struct FixIrreduciblePass : PassInfoMixin<FixIrreduciblePass> {
+struct FixIrreduciblePass : OptionalPassInfoMixin<FixIrreduciblePass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/HelloWorld.h b/llvm/include/llvm/Transforms/Utils/HelloWorld.h
index e29dda54586e7..22f8e42d23d35 100644
--- a/llvm/include/llvm/Transforms/Utils/HelloWorld.h
+++ b/llvm/include/llvm/Transforms/Utils/HelloWorld.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class HelloWorldPass : public PassInfoMixin<HelloWorldPass> {
+class HelloWorldPass : public OptionalPassInfoMixin<HelloWorldPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/IRNormalizer.h b/llvm/include/llvm/Transforms/Utils/IRNormalizer.h
index 65f03240f316a..adf4869cd106b 100644
--- a/llvm/include/llvm/Transforms/Utils/IRNormalizer.h
+++ b/llvm/include/llvm/Transforms/Utils/IRNormalizer.h
@@ -20,7 +20,7 @@ struct IRNormalizerOptions {
 };
 
 /// IRNormalizer aims to transform LLVM IR into normal form.
-struct IRNormalizerPass : public PassInfoMixin<IRNormalizerPass> {
+struct IRNormalizerPass : public OptionalPassInfoMixin<IRNormalizerPass> {
 private:
   const IRNormalizerOptions Options;
 
diff --git a/llvm/include/llvm/Transforms/Utils/InjectTLIMappings.h b/llvm/include/llvm/Transforms/Utils/InjectTLIMappings.h
index b6c402402b17a..a13c23994c308 100644
--- a/llvm/include/llvm/Transforms/Utils/InjectTLIMappings.h
+++ b/llvm/include/llvm/Transforms/Utils/InjectTLIMappings.h
@@ -17,7 +17,7 @@
 
 namespace llvm {
 class Function;
-class InjectTLIMappings : public PassInfoMixin<InjectTLIMappings> {
+class InjectTLIMappings : public OptionalPassInfoMixin<InjectTLIMappings> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/InstructionNamer.h b/llvm/include/llvm/Transforms/Utils/InstructionNamer.h
index 4f4cc2666f106..5847ecebd8cf8 100644
--- a/llvm/include/llvm/Transforms/Utils/InstructionNamer.h
+++ b/llvm/include/llvm/Transforms/Utils/InstructionNamer.h
@@ -12,7 +12,7 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-struct InstructionNamerPass : PassInfoMixin<InstructionNamerPass> {
+struct InstructionNamerPass : OptionalPassInfoMixin<InstructionNamerPass> {
   PreservedAnalyses run(Function &, FunctionAnalysisManager &);
 };
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/LCSSA.h b/llvm/include/llvm/Transforms/Utils/LCSSA.h
index 2ea4b193f33cb..6f2e693d23c00 100644
--- a/llvm/include/llvm/Transforms/Utils/LCSSA.h
+++ b/llvm/include/llvm/Transforms/Utils/LCSSA.h
@@ -35,7 +35,7 @@
 namespace llvm {
 
 /// Converts loops into loop-closed SSA form.
-class LCSSAPass : public PassInfoMixin<LCSSAPass> {
+class LCSSAPass : public OptionalPassInfoMixin<LCSSAPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/LibCallsShrinkWrap.h b/llvm/include/llvm/Transforms/Utils/LibCallsShrinkWrap.h
index ff1537ace329e..36ff7047cd326 100644
--- a/llvm/include/llvm/Transforms/Utils/LibCallsShrinkWrap.h
+++ b/llvm/include/llvm/Transforms/Utils/LibCallsShrinkWrap.h
@@ -15,7 +15,8 @@
 
 namespace llvm {
 
-class LibCallsShrinkWrapPass : public PassInfoMixin<LibCallsShrinkWrapPass> {
+class LibCallsShrinkWrapPass
+    : public OptionalPassInfoMixin<LibCallsShrinkWrapPass> {
 public:
   static StringRef name() { return "LibCallsShrinkWrapPass"; }
 
diff --git a/llvm/include/llvm/Transforms/Utils/LoopSimplify.h b/llvm/include/llvm/Transforms/Utils/LoopSimplify.h
index 8f3fa1f2b18ef..722406110b385 100644
--- a/llvm/include/llvm/Transforms/Utils/LoopSimplify.h
+++ b/llvm/include/llvm/Transforms/Utils/LoopSimplify.h
@@ -51,7 +51,7 @@ class MemorySSAUpdater;
 class ScalarEvolution;
 
 /// This pass is responsible for loop canonicalization.
-class LoopSimplifyPass : public PassInfoMixin<LoopSimplifyPass> {
+class LoopSimplifyPass : public OptionalPassInfoMixin<LoopSimplifyPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/LoopVersioning.h b/llvm/include/llvm/Transforms/Utils/LoopVersioning.h
index ea4fe27c90f5c..2e92274deebca 100644
--- a/llvm/include/llvm/Transforms/Utils/LoopVersioning.h
+++ b/llvm/include/llvm/Transforms/Utils/LoopVersioning.h
@@ -152,7 +152,7 @@ class LoopVersioning {
 /// Expose LoopVersioning as a pass.  Currently this is only used for
 /// unit-testing.  It adds all memchecks necessary to remove all may-aliasing
 /// array accesses from the loop.
-class LoopVersioningPass : public PassInfoMixin<LoopVersioningPass> {
+class LoopVersioningPass : public OptionalPassInfoMixin<LoopVersioningPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/LowerGlobalDtors.h b/llvm/include/llvm/Transforms/Utils/LowerGlobalDtors.h
index 993a6f57361cc..b002b2b1aff8e 100644
--- a/llvm/include/llvm/Transforms/Utils/LowerGlobalDtors.h
+++ b/llvm/include/llvm/Transforms/Utils/LowerGlobalDtors.h
@@ -18,7 +18,8 @@
 
 namespace llvm {
 
-class LowerGlobalDtorsPass : public PassInfoMixin<LowerGlobalDtorsPass> {
+class LowerGlobalDtorsPass
+    : public OptionalPassInfoMixin<LowerGlobalDtorsPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/LowerIFunc.h b/llvm/include/llvm/Transforms/Utils/LowerIFunc.h
index 87ddc18d7c063..2f086270576d5 100644
--- a/llvm/include/llvm/Transforms/Utils/LowerIFunc.h
+++ b/llvm/include/llvm/Transforms/Utils/LowerIFunc.h
@@ -16,7 +16,7 @@ namespace llvm {
 /// Pass to replace calls to ifuncs with indirect calls. This could be used to
 /// support ifunc on systems where the program loader does not natively support
 /// it. Constant initializer uses of ifuncs are not handled.
-class LowerIFuncPass : public PassInfoMixin<LowerIFuncPass> {
+class LowerIFuncPass : public OptionalPassInfoMixin<LowerIFuncPass> {
 public:
   LowerIFuncPass() = default;
 
diff --git a/llvm/include/llvm/Transforms/Utils/LowerInvoke.h b/llvm/include/llvm/Transforms/Utils/LowerInvoke.h
index c1198b08d3ded..50751bd3ed3b6 100644
--- a/llvm/include/llvm/Transforms/Utils/LowerInvoke.h
+++ b/llvm/include/llvm/Transforms/Utils/LowerInvoke.h
@@ -19,11 +19,10 @@
 
 namespace llvm {
 
-class LowerInvokePass : public PassInfoMixin<LowerInvokePass> {
+class LowerInvokePass : public OptionalPassInfoMixin<LowerInvokePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
-
 }
 
 #endif // LLVM_TRANSFORMS_UTILS_LOWERINVOKE_H
diff --git a/llvm/include/llvm/Transforms/Utils/LowerSwitch.h b/llvm/include/llvm/Transforms/Utils/LowerSwitch.h
index 97086987ffcbd..9d6b5e9852b5e 100644
--- a/llvm/include/llvm/Transforms/Utils/LowerSwitch.h
+++ b/llvm/include/llvm/Transforms/Utils/LowerSwitch.h
@@ -18,7 +18,7 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-struct LowerSwitchPass : public PassInfoMixin<LowerSwitchPass> {
+struct LowerSwitchPass : public OptionalPassInfoMixin<LowerSwitchPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/Mem2Reg.h b/llvm/include/llvm/Transforms/Utils/Mem2Reg.h
index d0006bf162f25..81b98addef61d 100644
--- a/llvm/include/llvm/Transforms/Utils/Mem2Reg.h
+++ b/llvm/include/llvm/Transforms/Utils/Mem2Reg.h
@@ -21,7 +21,7 @@ namespace llvm {
 
 class Function;
 
-class PromotePass : public PassInfoMixin<PromotePass> {
+class PromotePass : public OptionalPassInfoMixin<PromotePass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/MetaRenamer.h b/llvm/include/llvm/Transforms/Utils/MetaRenamer.h
index fff3dff75837e..c46180dd8e3b4 100644
--- a/llvm/include/llvm/Transforms/Utils/MetaRenamer.h
+++ b/llvm/include/llvm/Transforms/Utils/MetaRenamer.h
@@ -18,7 +18,7 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-struct MetaRenamerPass : PassInfoMixin<MetaRenamerPass> {
+struct MetaRenamerPass : OptionalPassInfoMixin<MetaRenamerPass> {
   PreservedAnalyses run(Module &, ModuleAnalysisManager &);
 };
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/MoveAutoInit.h b/llvm/include/llvm/Transforms/Utils/MoveAutoInit.h
index 980b55f46f114..e3142abaaadab 100644
--- a/llvm/include/llvm/Transforms/Utils/MoveAutoInit.h
+++ b/llvm/include/llvm/Transforms/Utils/MoveAutoInit.h
@@ -20,7 +20,7 @@
 
 namespace llvm {
 
-class MoveAutoInitPass : public PassInfoMixin<MoveAutoInitPass> {
+class MoveAutoInitPass : public OptionalPassInfoMixin<MoveAutoInitPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/NameAnonGlobals.h b/llvm/include/llvm/Transforms/Utils/NameAnonGlobals.h
index b1c181c1211b4..9d2305e354203 100644
--- a/llvm/include/llvm/Transforms/Utils/NameAnonGlobals.h
+++ b/llvm/include/llvm/Transforms/Utils/NameAnonGlobals.h
@@ -19,13 +19,11 @@
 namespace llvm {
 
 /// Simple pass that provides a name to every anonymous globals.
-class NameAnonGlobalPass : public PassInfoMixin<NameAnonGlobalPass> {
+class NameAnonGlobalPass : public MandatoryPassInfoMixin<NameAnonGlobalPass> {
 public:
   NameAnonGlobalPass() = default;
 
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/PredicateInfo.h b/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
index 986a64e913688..b12229a2f8343 100644
--- a/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
+++ b/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
@@ -235,19 +235,18 @@ class PredicateInfo {
 
 /// Printer pass for \c PredicateInfo.
 class PredicateInfoPrinterPass
-    : public PassInfoMixin<PredicateInfoPrinterPass> {
+    : public MandatoryPassInfoMixin<PredicateInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit PredicateInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 /// Verifier pass for \c PredicateInfo.
-struct PredicateInfoVerifierPass : PassInfoMixin<PredicateInfoVerifierPass> {
+struct PredicateInfoVerifierPass
+    : MandatoryPassInfoMixin<PredicateInfoVerifierPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/Transforms/Utils/ProfileVerify.h b/llvm/include/llvm/Transforms/Utils/ProfileVerify.h
index bf953b529b80c..f4a83e059a8d8 100644
--- a/llvm/include/llvm/Transforms/Utils/ProfileVerify.h
+++ b/llvm/include/llvm/Transforms/Utils/ProfileVerify.h
@@ -21,7 +21,7 @@
 namespace llvm {
 /// Inject MD_prof metadata where it's missing. Used for testing that passes
 /// don't accidentally drop this metadata.
-class ProfileInjectorPass : public PassInfoMixin<ProfileInjectorPass> {
+class ProfileInjectorPass : public OptionalPassInfoMixin<ProfileInjectorPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
@@ -29,7 +29,7 @@ class ProfileInjectorPass : public PassInfoMixin<ProfileInjectorPass> {
 /// Checks that MD_prof is present on every instruction that supports it. Used
 /// in conjunction with the ProfileInjectorPass. MD_prof "unknown" is considered
 /// valid (i.e. !{!"unknown"})
-class ProfileVerifierPass : public PassInfoMixin<ProfileVerifierPass> {
+class ProfileVerifierPass : public OptionalPassInfoMixin<ProfileVerifierPass> {
   DenseSet<const Function *> IgnoreList;
   // This pass is mostly a function pass but we want to initialize the
   // IngoreList once, which is why we present it as a module-level pass. We make
diff --git a/llvm/include/llvm/Transforms/Utils/RelLookupTableConverter.h b/llvm/include/llvm/Transforms/Utils/RelLookupTableConverter.h
index 0992a4456c9d0..817b075cd09dd 100644
--- a/llvm/include/llvm/Transforms/Utils/RelLookupTableConverter.h
+++ b/llvm/include/llvm/Transforms/Utils/RelLookupTableConverter.h
@@ -59,7 +59,7 @@ class Module;
 
 // Pass that converts lookup tables to relative lookup tables.
 class RelLookupTableConverterPass
-    : public PassInfoMixin<RelLookupTableConverterPass> {
+    : public OptionalPassInfoMixin<RelLookupTableConverterPass> {
 public:
   RelLookupTableConverterPass() = default;
 
diff --git a/llvm/include/llvm/Transforms/Utils/StripGCRelocates.h b/llvm/include/llvm/Transforms/Utils/StripGCRelocates.h
index 13e6d8ac26a7f..a3895d53f862e 100644
--- a/llvm/include/llvm/Transforms/Utils/StripGCRelocates.h
+++ b/llvm/include/llvm/Transforms/Utils/StripGCRelocates.h
@@ -15,7 +15,7 @@ namespace llvm {
 
 class Function;
 
-class StripGCRelocates : public PassInfoMixin<StripGCRelocates> {
+class StripGCRelocates : public OptionalPassInfoMixin<StripGCRelocates> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h b/llvm/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h
index 20d0aabd29385..38b3e2806a768 100644
--- a/llvm/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h
+++ b/llvm/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h
@@ -16,7 +16,7 @@ namespace llvm {
 class Module;
 
 class StripNonLineTableDebugInfoPass
-    : public PassInfoMixin<StripNonLineTableDebugInfoPass> {
+    : public OptionalPassInfoMixin<StripNonLineTableDebugInfoPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/SymbolRewriter.h b/llvm/include/llvm/Transforms/Utils/SymbolRewriter.h
index 10c5c7c49771b..2d6a0ce6cfcdd 100644
--- a/llvm/include/llvm/Transforms/Utils/SymbolRewriter.h
+++ b/llvm/include/llvm/Transforms/Utils/SymbolRewriter.h
@@ -115,7 +115,7 @@ class RewriteMapParser {
 
 } // end namespace SymbolRewriter
 
-class RewriteSymbolPass : public PassInfoMixin<RewriteSymbolPass> {
+class RewriteSymbolPass : public OptionalPassInfoMixin<RewriteSymbolPass> {
 public:
   RewriteSymbolPass() { loadAndParseMapFiles(); }
 
diff --git a/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
index 296d3b755e2c8..a00eb1b4e8b92 100644
--- a/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
+++ b/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h
@@ -20,7 +20,7 @@
 namespace llvm {
 
 class UnifyFunctionExitNodesPass
-    : public PassInfoMixin<UnifyFunctionExitNodesPass> {
+    : public OptionalPassInfoMixin<UnifyFunctionExitNodesPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/UnifyLoopExits.h b/llvm/include/llvm/Transforms/Utils/UnifyLoopExits.h
index 0b219cd122226..2cc7fab9c0e02 100644
--- a/llvm/include/llvm/Transforms/Utils/UnifyLoopExits.h
+++ b/llvm/include/llvm/Transforms/Utils/UnifyLoopExits.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class UnifyLoopExitsPass : public PassInfoMixin<UnifyLoopExitsPass> {
+class UnifyLoopExitsPass : public OptionalPassInfoMixin<UnifyLoopExitsPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Vectorize/LoadStoreVectorizer.h b/llvm/include/llvm/Transforms/Vectorize/LoadStoreVectorizer.h
index d8f52b3707d4b..45a6c58b8acd3 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoadStoreVectorizer.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoadStoreVectorizer.h
@@ -16,7 +16,8 @@ namespace llvm {
 class Pass;
 class Function;
 
-class LoadStoreVectorizerPass : public PassInfoMixin<LoadStoreVectorizerPass> {
+class LoadStoreVectorizerPass
+    : public OptionalPassInfoMixin<LoadStoreVectorizerPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Vectorize/LoopIdiomVectorize.h b/llvm/include/llvm/Transforms/Vectorize/LoopIdiomVectorize.h
index ef6e0e0687809..5798f89d160d3 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoopIdiomVectorize.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoopIdiomVectorize.h
@@ -15,7 +15,8 @@
 namespace llvm {
 enum class LoopIdiomVectorizeStyle { Masked, Predicated };
 
-class LoopIdiomVectorizePass : public PassInfoMixin<LoopIdiomVectorizePass> {
+class LoopIdiomVectorizePass
+    : public OptionalPassInfoMixin<LoopIdiomVectorizePass> {
   LoopIdiomVectorizeStyle VectorizeStyle = LoopIdiomVectorizeStyle::Masked;
 
   // The VF used in vectorizing the byte compare pattern.
diff --git a/llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h b/llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h
index 6eab92e66745e..18906aa7eeae3 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h
@@ -128,7 +128,7 @@ struct LoopVectorizeResult {
 };
 
 /// The LoopVectorize Pass.
-struct LoopVectorizePass : public PassInfoMixin<LoopVectorizePass> {
+struct LoopVectorizePass : public OptionalPassInfoMixin<LoopVectorizePass> {
 private:
   /// If false, consider all loops for interleaving.
   /// If true, only loops that explicitly request interleaving are considered.
diff --git a/llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h b/llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h
index 877c83291170b..6d668dec0dc35 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h
@@ -55,7 +55,7 @@ class BoUpSLP;
 
 } // end namespace slpvectorizer
 
-struct SLPVectorizerPass : public PassInfoMixin<SLPVectorizerPass> {
+struct SLPVectorizerPass : public OptionalPassInfoMixin<SLPVectorizerPass> {
   using StoreList = SmallVector<StoreInst *, 8>;
   using StoreListMap = MapVector<Value *, StoreList>;
   using GEPList = SmallVector<GetElementPtrInst *, 8>;
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
index fc8765217c0c2..d0ae059cbef7b 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h
@@ -21,7 +21,8 @@ namespace llvm {
 
 class TargetTransformInfo;
 
-class SandboxVectorizerPass : public PassInfoMixin<SandboxVectorizerPass> {
+class SandboxVectorizerPass
+    : public OptionalPassInfoMixin<SandboxVectorizerPass> {
   TargetTransformInfo *TTI = nullptr;
   AAResults *AA = nullptr;
   ScalarEvolution *SE = nullptr;
diff --git a/llvm/include/llvm/Transforms/Vectorize/VectorCombine.h b/llvm/include/llvm/Transforms/Vectorize/VectorCombine.h
index 935f739b7667a..68b8c3c0c13ab 100644
--- a/llvm/include/llvm/Transforms/Vectorize/VectorCombine.h
+++ b/llvm/include/llvm/Transforms/Vectorize/VectorCombine.h
@@ -20,7 +20,7 @@
 namespace llvm {
 
 /// Optimize scalar/vector interactions in IR using target cost models.
-class VectorCombinePass : public PassInfoMixin<VectorCombinePass> {
+class VectorCombinePass : public OptionalPassInfoMixin<VectorCombinePass> {
   /// If true, only perform beneficial early IR transforms. Do not introduce new
   /// vector operations.
   bool TryEarlyFoldsOnly;
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 2751961e684d2..8768a3a215c69 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -403,7 +403,8 @@ namespace {
 
 // Passes for testing crashes.
 // DO NOT USE THIS EXCEPT FOR TESTING!
-class TriggerCrashModulePass : public PassInfoMixin<TriggerCrashModulePass> {
+class TriggerCrashModulePass
+    : public OptionalPassInfoMixin<TriggerCrashModulePass> {
 public:
   PreservedAnalyses run(Module &, ModuleAnalysisManager &) {
     abort();
@@ -413,7 +414,7 @@ class TriggerCrashModulePass : public PassInfoMixin<TriggerCrashModulePass> {
 };
 
 class TriggerCrashFunctionPass
-    : public PassInfoMixin<TriggerCrashFunctionPass> {
+    : public OptionalPassInfoMixin<TriggerCrashFunctionPass> {
 public:
   PreservedAnalyses run(Function &, FunctionAnalysisManager &) {
     abort();
@@ -425,7 +426,7 @@ class TriggerCrashFunctionPass
 // A pass for testing message reporting of -verify-each failures.
 // DO NOT USE THIS EXCEPT FOR TESTING!
 class TriggerVerifierErrorPass
-    : public PassInfoMixin<TriggerVerifierErrorPass> {
+    : public OptionalPassInfoMixin<TriggerVerifierErrorPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &) {
     // Intentionally break the Module by creating an alias without setting the
@@ -459,7 +460,7 @@ class TriggerVerifierErrorPass
 // A pass requires all MachineFunctionProperties.
 // DO NOT USE THIS EXCEPT FOR TESTING!
 class RequireAllMachineFunctionPropertiesPass
-    : public PassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
+    : public OptionalPassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &) {
     MFPropsModifier _(*this, MF);
diff --git a/llvm/lib/Target/AArch64/AArch64.h b/llvm/lib/Target/AArch64/AArch64.h
index 81f766080c82a..132c21b643960 100644
--- a/llvm/lib/Target/AArch64/AArch64.h
+++ b/llvm/lib/Target/AArch64/AArch64.h
@@ -75,7 +75,7 @@ createAArch64InstructionSelector(const AArch64TargetMachine &,
                                  const AArch64Subtarget &,
                                  const AArch64RegisterBankInfo &);
 class AArch64O0PreLegalizerCombinerPass
-    : public PassInfoMixin<AArch64O0PreLegalizerCombinerPass> {
+    : public OptionalPassInfoMixin<AArch64O0PreLegalizerCombinerPass> {
   std::unique_ptr<AArch64O0PreLegalizerCombinerImplRuleConfig> RuleConfig;
 
 public:
@@ -88,7 +88,7 @@ class AArch64O0PreLegalizerCombinerPass
 };
 
 class AArch64PreLegalizerCombinerPass
-    : public PassInfoMixin<AArch64PreLegalizerCombinerPass> {
+    : public OptionalPassInfoMixin<AArch64PreLegalizerCombinerPass> {
   std::unique_ptr<AArch64PreLegalizerCombinerImplRuleConfig> RuleConfig;
 
 public:
@@ -152,93 +152,98 @@ void initializeSVEIntrinsicOptsPass(PassRegistry &);
 void initializeAArch64Arm64ECCallLoweringPass(PassRegistry &);
 
 class AArch64A57FPLoadBalancingPass
-    : public PassInfoMixin<AArch64A57FPLoadBalancingPass> {
+    : public OptionalPassInfoMixin<AArch64A57FPLoadBalancingPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
-class AArch64LoadStoreOptPass : public PassInfoMixin<AArch64LoadStoreOptPass> {
+class AArch64LoadStoreOptPass
+    : public OptionalPassInfoMixin<AArch64LoadStoreOptPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
-class AArch64A53Fix835769Pass : public PassInfoMixin<AArch64A53Fix835769Pass> {
+class AArch64A53Fix835769Pass
+    : public OptionalPassInfoMixin<AArch64A53Fix835769Pass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class AArch64BranchTargetsPass
-    : public PassInfoMixin<AArch64BranchTargetsPass> {
+    : public OptionalPassInfoMixin<AArch64BranchTargetsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class AArch64AdvSIMDScalarPass
-    : public PassInfoMixin<AArch64AdvSIMDScalarPass> {
+    : public OptionalPassInfoMixin<AArch64AdvSIMDScalarPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
-class AArch64CollectLOHPass : public PassInfoMixin<AArch64CollectLOHPass> {
+class AArch64CollectLOHPass
+    : public OptionalPassInfoMixin<AArch64CollectLOHPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class AArch64CompressJumpTablesPass
-    : public PassInfoMixin<AArch64CompressJumpTablesPass> {
+    : public OptionalPassInfoMixin<AArch64CompressJumpTablesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class AArch64DeadRegisterDefinitionsPass
-    : public PassInfoMixin<AArch64DeadRegisterDefinitionsPass> {
+    : public OptionalPassInfoMixin<AArch64DeadRegisterDefinitionsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
-class AArch64ExpandPseudoPass : public PassInfoMixin<AArch64ExpandPseudoPass> {
+class AArch64ExpandPseudoPass
+    : public OptionalPassInfoMixin<AArch64ExpandPseudoPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class AArch64MIPeepholeOptPass
-    : public PassInfoMixin<AArch64MIPeepholeOptPass> {
+    : public OptionalPassInfoMixin<AArch64MIPeepholeOptPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class AArch64ConditionOptimizerPass
-    : public PassInfoMixin<AArch64ConditionOptimizerPass> {
+    : public OptionalPassInfoMixin<AArch64ConditionOptimizerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
-class AArch64PointerAuthPass : public PassInfoMixin<AArch64PointerAuthPass> {
+class AArch64PointerAuthPass
+    : public OptionalPassInfoMixin<AArch64PointerAuthPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class AArch64PostCoalescerPass
-    : public PassInfoMixin<AArch64PostCoalescerPass> {
+    : public OptionalPassInfoMixin<AArch64PostCoalescerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class AArch64RedundantCopyEliminationPass
-    : public PassInfoMixin<AArch64RedundantCopyEliminationPass> {
+    : public OptionalPassInfoMixin<AArch64RedundantCopyEliminationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 878f374110159..f736a93bc4ba9 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -70,13 +70,14 @@ FunctionPass *createGCNPreRAOptimizationsLegacyPass();
 FunctionPass *createAMDGPUPreloadKernArgPrologLegacyPass();
 ModulePass *createAMDGPUPreloadKernelArgumentsLegacyPass(const TargetMachine *);
 
-struct AMDGPUSimplifyLibCallsPass : PassInfoMixin<AMDGPUSimplifyLibCallsPass> {
+struct AMDGPUSimplifyLibCallsPass
+    : OptionalPassInfoMixin<AMDGPUSimplifyLibCallsPass> {
   AMDGPUSimplifyLibCallsPass() = default;
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 struct AMDGPUImageIntrinsicOptimizerPass
-    : PassInfoMixin<AMDGPUImageIntrinsicOptimizerPass> {
+    : OptionalPassInfoMixin<AMDGPUImageIntrinsicOptimizerPass> {
   AMDGPUImageIntrinsicOptimizerPass(TargetMachine &TM) : TM(TM) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
@@ -84,11 +85,12 @@ struct AMDGPUImageIntrinsicOptimizerPass
   TargetMachine &TM;
 };
 
-struct AMDGPUUseNativeCallsPass : PassInfoMixin<AMDGPUUseNativeCallsPass> {
+struct AMDGPUUseNativeCallsPass
+    : OptionalPassInfoMixin<AMDGPUUseNativeCallsPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-class SILowerI1CopiesPass : public PassInfoMixin<SILowerI1CopiesPass> {
+class SILowerI1CopiesPass : public OptionalPassInfoMixin<SILowerI1CopiesPass> {
 public:
   SILowerI1CopiesPass() = default;
   PreservedAnalyses run(MachineFunction &MF,
@@ -121,7 +123,7 @@ void initializeAMDGPUPromoteKernelArgumentsPass(PassRegistry &);
 extern char &AMDGPUPromoteKernelArgumentsID;
 
 struct AMDGPUPromoteKernelArgumentsPass
-    : PassInfoMixin<AMDGPUPromoteKernelArgumentsPass> {
+    : OptionalPassInfoMixin<AMDGPUPromoteKernelArgumentsPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
@@ -130,14 +132,15 @@ void initializeAMDGPULowerKernelAttributesPass(PassRegistry &);
 extern char &AMDGPULowerKernelAttributesID;
 
 struct AMDGPULowerKernelAttributesPass
-    : PassInfoMixin<AMDGPULowerKernelAttributesPass> {
+    : OptionalPassInfoMixin<AMDGPULowerKernelAttributesPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 void initializeAMDGPULowerModuleLDSLegacyPass(PassRegistry &);
 extern char &AMDGPULowerModuleLDSLegacyPassID;
 
-struct AMDGPULowerModuleLDSPass : PassInfoMixin<AMDGPULowerModuleLDSPass> {
+struct AMDGPULowerModuleLDSPass
+    : OptionalPassInfoMixin<AMDGPULowerModuleLDSPass> {
   const AMDGPUTargetMachine &TM;
   AMDGPULowerModuleLDSPass(const AMDGPUTargetMachine &TM_) : TM(TM_) {}
 
@@ -148,7 +151,7 @@ void initializeAMDGPULowerBufferFatPointersPass(PassRegistry &);
 extern char &AMDGPULowerBufferFatPointersID;
 
 struct AMDGPULowerBufferFatPointersPass
-    : PassInfoMixin<AMDGPULowerBufferFatPointersPass> {
+    : OptionalPassInfoMixin<AMDGPULowerBufferFatPointersPass> {
   AMDGPULowerBufferFatPointersPass(const TargetMachine &TM) : TM(TM) {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 
@@ -158,7 +161,8 @@ struct AMDGPULowerBufferFatPointersPass
 
 void initializeAMDGPULowerIntrinsicsLegacyPass(PassRegistry &);
 
-struct AMDGPULowerIntrinsicsPass : PassInfoMixin<AMDGPULowerIntrinsicsPass> {
+struct AMDGPULowerIntrinsicsPass
+    : OptionalPassInfoMixin<AMDGPULowerIntrinsicsPass> {
   AMDGPULowerIntrinsicsPass(const AMDGPUTargetMachine &TM) : TM(TM) {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 
@@ -255,7 +259,8 @@ FunctionPass *createAMDGPUPromoteAlloca();
 void initializeAMDGPUPromoteAllocaPass(PassRegistry&);
 extern char &AMDGPUPromoteAllocaID;
 
-struct AMDGPUPromoteAllocaPass : PassInfoMixin<AMDGPUPromoteAllocaPass> {
+struct AMDGPUPromoteAllocaPass
+    : OptionalPassInfoMixin<AMDGPUPromoteAllocaPass> {
   AMDGPUPromoteAllocaPass(TargetMachine &TM) : TM(TM) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
@@ -264,7 +269,7 @@ struct AMDGPUPromoteAllocaPass : PassInfoMixin<AMDGPUPromoteAllocaPass> {
 };
 
 struct AMDGPUPromoteAllocaToVectorPass
-    : PassInfoMixin<AMDGPUPromoteAllocaToVectorPass> {
+    : OptionalPassInfoMixin<AMDGPUPromoteAllocaToVectorPass> {
   AMDGPUPromoteAllocaToVectorPass(TargetMachine &TM) : TM(TM) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
@@ -272,7 +277,8 @@ struct AMDGPUPromoteAllocaToVectorPass
   TargetMachine &TM;
 };
 
-struct AMDGPUAtomicOptimizerPass : PassInfoMixin<AMDGPUAtomicOptimizerPass> {
+struct AMDGPUAtomicOptimizerPass
+    : OptionalPassInfoMixin<AMDGPUAtomicOptimizerPass> {
   AMDGPUAtomicOptimizerPass(TargetMachine &TM, ScanOptions ScanImpl)
       : TM(TM), ScanImpl(ScanImpl) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
@@ -283,7 +289,7 @@ struct AMDGPUAtomicOptimizerPass : PassInfoMixin<AMDGPUAtomicOptimizerPass> {
 };
 
 struct AMDGPUInsertDelayAluPass
-    : public PassInfoMixin<AMDGPUInsertDelayAluPass> {
+    : public OptionalPassInfoMixin<AMDGPUInsertDelayAluPass> {
   PreservedAnalyses run(MachineFunction &F,
                         MachineFunctionAnalysisManager &MFAM);
 };
@@ -292,7 +298,7 @@ Pass *createAMDGPUStructurizeCFGPass();
 FunctionPass *createAMDGPUISelDag(TargetMachine &TM, CodeGenOptLevel OptLevel);
 ModulePass *createAMDGPUAlwaysInlinePass(bool GlobalOpt = true);
 
-struct AMDGPUAlwaysInlinePass : PassInfoMixin<AMDGPUAlwaysInlinePass> {
+struct AMDGPUAlwaysInlinePass : OptionalPassInfoMixin<AMDGPUAlwaysInlinePass> {
   AMDGPUAlwaysInlinePass(bool GlobalOpt = true) : GlobalOpt(GlobalOpt) {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 
@@ -304,7 +310,8 @@ void initializeAMDGPULowerExecSyncLegacyPass(PassRegistry &);
 extern char &AMDGPULowerExecSyncLegacyPassID;
 ModulePass *createAMDGPULowerExecSyncLegacyPass();
 
-struct AMDGPULowerExecSyncPass : PassInfoMixin<AMDGPULowerExecSyncPass> {
+struct AMDGPULowerExecSyncPass
+    : OptionalPassInfoMixin<AMDGPULowerExecSyncPass> {
   AMDGPULowerExecSyncPass() {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
@@ -314,14 +321,14 @@ extern char &AMDGPUSwLowerLDSLegacyPassID;
 ModulePass *
 createAMDGPUSwLowerLDSLegacyPass(const AMDGPUTargetMachine *TM = nullptr);
 
-struct AMDGPUSwLowerLDSPass : PassInfoMixin<AMDGPUSwLowerLDSPass> {
+struct AMDGPUSwLowerLDSPass : OptionalPassInfoMixin<AMDGPUSwLowerLDSPass> {
   const AMDGPUTargetMachine &TM;
   AMDGPUSwLowerLDSPass(const AMDGPUTargetMachine &TM_) : TM(TM_) {}
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
 class AMDGPUCodeGenPreparePass
-    : public PassInfoMixin<AMDGPUCodeGenPreparePass> {
+    : public OptionalPassInfoMixin<AMDGPUCodeGenPreparePass> {
 private:
   TargetMachine &TM;
 
@@ -331,7 +338,7 @@ class AMDGPUCodeGenPreparePass
 };
 
 class AMDGPULateCodeGenPreparePass
-    : public PassInfoMixin<AMDGPULateCodeGenPreparePass> {
+    : public OptionalPassInfoMixin<AMDGPULateCodeGenPreparePass> {
 private:
   const GCNTargetMachine &TM;
 
@@ -341,7 +348,7 @@ class AMDGPULateCodeGenPreparePass
 };
 
 class AMDGPULowerKernelArgumentsPass
-    : public PassInfoMixin<AMDGPULowerKernelArgumentsPass> {
+    : public OptionalPassInfoMixin<AMDGPULowerKernelArgumentsPass> {
 private:
   TargetMachine &TM;
 
@@ -354,7 +361,8 @@ struct AMDGPUAttributorOptions {
   bool IsClosedWorld = false;
 };
 
-class AMDGPUAttributorPass : public PassInfoMixin<AMDGPUAttributorPass> {
+class AMDGPUAttributorPass
+    : public OptionalPassInfoMixin<AMDGPUAttributorPass> {
 private:
   TargetMachine &TM;
 
@@ -370,7 +378,7 @@ class AMDGPUAttributorPass : public PassInfoMixin<AMDGPUAttributorPass> {
 };
 
 class AMDGPUAttributorCGSCCPass
-    : public PassInfoMixin<AMDGPUAttributorCGSCCPass> {
+    : public OptionalPassInfoMixin<AMDGPUAttributorCGSCCPass> {
 private:
   GCNTargetMachine &TM;
 
@@ -381,7 +389,7 @@ class AMDGPUAttributorCGSCCPass
 };
 
 class AMDGPUPreloadKernelArgumentsPass
-    : public PassInfoMixin<AMDGPUPreloadKernelArgumentsPass> {
+    : public OptionalPassInfoMixin<AMDGPUPreloadKernelArgumentsPass> {
   const TargetMachine &TM;
 
 public:
@@ -391,68 +399,68 @@ class AMDGPUPreloadKernelArgumentsPass
 };
 
 class AMDGPUAnnotateUniformValuesPass
-    : public PassInfoMixin<AMDGPUAnnotateUniformValuesPass> {
+    : public OptionalPassInfoMixin<AMDGPUAnnotateUniformValuesPass> {
 public:
   AMDGPUAnnotateUniformValuesPass() = default;
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-class SIModeRegisterPass : public PassInfoMixin<SIModeRegisterPass> {
+class SIModeRegisterPass : public OptionalPassInfoMixin<SIModeRegisterPass> {
 public:
   SIModeRegisterPass() = default;
   PreservedAnalyses run(MachineFunction &F, MachineFunctionAnalysisManager &AM);
 };
 
-class SIMemoryLegalizerPass : public PassInfoMixin<SIMemoryLegalizerPass> {
+class SIMemoryLegalizerPass
+    : public MandatoryPassInfoMixin<SIMemoryLegalizerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
-class GCNCreateVOPDPass : public PassInfoMixin<GCNCreateVOPDPass> {
+class GCNCreateVOPDPass : public OptionalPassInfoMixin<GCNCreateVOPDPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &AM);
 };
 
 class AMDGPUMarkLastScratchLoadPass
-    : public PassInfoMixin<AMDGPUMarkLastScratchLoadPass> {
+    : public OptionalPassInfoMixin<AMDGPUMarkLastScratchLoadPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &AM);
 };
 
-class SIInsertWaitcntsPass : public PassInfoMixin<SIInsertWaitcntsPass> {
+class SIInsertWaitcntsPass
+    : public MandatoryPassInfoMixin<SIInsertWaitcntsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
-class SIInsertHardClausesPass : public PassInfoMixin<SIInsertHardClausesPass> {
+class SIInsertHardClausesPass
+    : public OptionalPassInfoMixin<SIInsertHardClausesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class SILateBranchLoweringPass
-    : public PassInfoMixin<SILateBranchLoweringPass> {
+    : public MandatoryPassInfoMixin<SILateBranchLoweringPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
-class SIPreEmitPeepholePass : public PassInfoMixin<SIPreEmitPeepholePass> {
+class SIPreEmitPeepholePass
+    : public MandatoryPassInfoMixin<SIPreEmitPeepholePass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 class AMDGPUSetWavePriorityPass
-    : public PassInfoMixin<AMDGPUSetWavePriorityPass> {
+    : public OptionalPassInfoMixin<AMDGPUSetWavePriorityPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -468,7 +476,7 @@ void initializeAMDGPUResourceUsageAnalysisWrapperPassPass(PassRegistry &);
 extern char &AMDGPUResourceUsageAnalysisID;
 
 struct AMDGPUPrintfRuntimeBindingPass
-    : PassInfoMixin<AMDGPUPrintfRuntimeBindingPass> {
+    : OptionalPassInfoMixin<AMDGPUPrintfRuntimeBindingPass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
@@ -495,14 +503,14 @@ void initializeAMDGPURewriteUndefForPHILegacyPass(PassRegistry &);
 extern char &AMDGPURewriteUndefForPHILegacyPassID;
 
 class AMDGPURewriteUndefForPHIPass
-    : public PassInfoMixin<AMDGPURewriteUndefForPHIPass> {
+    : public OptionalPassInfoMixin<AMDGPURewriteUndefForPHIPass> {
 public:
   AMDGPURewriteUndefForPHIPass() = default;
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 class SIAnnotateControlFlowPass
-    : public PassInfoMixin<SIAnnotateControlFlowPass> {
+    : public OptionalPassInfoMixin<SIAnnotateControlFlowPass> {
 private:
   const AMDGPUTargetMachine &TM;
 
@@ -572,7 +580,7 @@ void initializeAMDGPUWaitSGPRHazardsLegacyPass(PassRegistry &);
 extern char &AMDGPUWaitSGPRHazardsLegacyID;
 
 class AMDGPURewriteAGPRCopyMFMAPass
-    : public PassInfoMixin<AMDGPURewriteAGPRCopyMFMAPass> {
+    : public OptionalPassInfoMixin<AMDGPURewriteAGPRCopyMFMAPass> {
 public:
   AMDGPURewriteAGPRCopyMFMAPass() = default;
   PreservedAnalyses run(MachineFunction &MF,
@@ -587,7 +595,7 @@ extern char &AMDGPUUniformIntrinsicCombineLegacyPassID;
 FunctionPass *createAMDGPUUniformIntrinsicCombineLegacyPass();
 
 struct AMDGPUUniformIntrinsicCombinePass
-    : public PassInfoMixin<AMDGPUUniformIntrinsicCombinePass> {
+    : public OptionalPassInfoMixin<AMDGPUUniformIntrinsicCombinePass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.h b/llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.h
index 1c1cd299b6f56..7707e16fd0557 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCtorDtorLowering.h
@@ -16,7 +16,7 @@ class Module;
 
 /// Lower llvm.global_ctors and llvm.global_dtors to special kernels.
 class AMDGPUCtorDtorLoweringPass
-    : public PassInfoMixin<AMDGPUCtorDtorLoweringPass> {
+    : public OptionalPassInfoMixin<AMDGPUCtorDtorLoweringPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUExportKernelRuntimeHandles.h b/llvm/lib/Target/AMDGPU/AMDGPUExportKernelRuntimeHandles.h
index 6e7ebc977668b..3aecf4f0133ac 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUExportKernelRuntimeHandles.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUExportKernelRuntimeHandles.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class AMDGPUExportKernelRuntimeHandlesPass
-    : public PassInfoMixin<AMDGPUExportKernelRuntimeHandlesPass> {
+    : public OptionalPassInfoMixin<AMDGPUExportKernelRuntimeHandlesPass> {
 public:
   AMDGPUExportKernelRuntimeHandlesPass() = default;
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerVGPREncoding.h b/llvm/lib/Target/AMDGPU/AMDGPULowerVGPREncoding.h
index c8c2051c9fddd..9a692f0979c11 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerVGPREncoding.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerVGPREncoding.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class AMDGPULowerVGPREncodingPass
-    : public PassInfoMixin<AMDGPULowerVGPREncodingPass> {
+    : public OptionalPassInfoMixin<AMDGPULowerVGPREncodingPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.h b/llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.h
index a3be0f51c2c2f..b7880c4639a97 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.h
@@ -62,7 +62,7 @@ class AMDGPUPerfHintAnalysis {
 };
 
 struct AMDGPUPerfHintAnalysisPass
-    : public PassInfoMixin<AMDGPUPerfHintAnalysisPass> {
+    : public OptionalPassInfoMixin<AMDGPUPerfHintAnalysisPass> {
   const GCNTargetMachine &TM;
   std::unique_ptr<AMDGPUPerfHintAnalysis> Impl;
 
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPreloadKernArgProlog.h b/llvm/lib/Target/AMDGPU/AMDGPUPreloadKernArgProlog.h
index 1216132923ade..b8c345cc3359b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPreloadKernArgProlog.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPreloadKernArgProlog.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class AMDGPUPreloadKernArgPrologPass
-    : public PassInfoMixin<AMDGPUPreloadKernArgPrologPass> {
+    : public OptionalPassInfoMixin<AMDGPUPreloadKernArgPrologPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &AM);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPrepareAGPRAlloc.h b/llvm/lib/Target/AMDGPU/AMDGPUPrepareAGPRAlloc.h
index dc598c98f241b..57b69ed36b65c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPrepareAGPRAlloc.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPrepareAGPRAlloc.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class AMDGPUPrepareAGPRAllocPass
-    : public PassInfoMixin<AMDGPUPrepareAGPRAllocPass> {
+    : public OptionalPassInfoMixin<AMDGPUPrepareAGPRAllocPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.h b/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.h
index e4c858588ece8..20d04c633af64 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.h
@@ -14,7 +14,7 @@
 
 namespace llvm {
 class AMDGPURemoveIncompatibleFunctionsPass
-    : public PassInfoMixin<AMDGPURemoveIncompatibleFunctionsPass> {
+    : public OptionalPassInfoMixin<AMDGPURemoveIncompatibleFunctionsPass> {
   const TargetMachine *TM;
 
 public:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h b/llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h
index 7c58590347f3e..e92b1b5a3a7c4 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h
@@ -13,11 +13,10 @@
 
 namespace llvm {
 class AMDGPUReserveWWMRegsPass
-    : public PassInfoMixin<AMDGPUReserveWWMRegsPass> {
+    : public MandatoryPassInfoMixin<AMDGPUReserveWWMRegsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.h b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.h
index d814dedd6f0c4..f56f4f33def4c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.h
@@ -19,7 +19,8 @@ namespace llvm {
 
 /// Splits the module M into N linkable partitions. The function ModuleCallback
 /// is called N times passing each individual partition as the MPart argument.
-class AMDGPUSplitModulePass : public PassInfoMixin<AMDGPUSplitModulePass> {
+class AMDGPUSplitModulePass
+    : public OptionalPassInfoMixin<AMDGPUSplitModulePass> {
 public:
   using ModuleCreationCallback =
       function_ref<void(std::unique_ptr<Module> MPart)>;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.h b/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.h
index 2fd98a2ee1a93..3eab914207183 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.h
@@ -26,7 +26,7 @@
 
 namespace llvm {
 class AMDGPUUnifyDivergentExitNodesPass
-    : public PassInfoMixin<AMDGPUUnifyDivergentExitNodesPass> {
+    : public OptionalPassInfoMixin<AMDGPUUnifyDivergentExitNodesPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUWaitSGPRHazards.h b/llvm/lib/Target/AMDGPU/AMDGPUWaitSGPRHazards.h
index 58e9bca4c3ede..12ea858c54dd8 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUWaitSGPRHazards.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUWaitSGPRHazards.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class AMDGPUWaitSGPRHazardsPass
-    : public PassInfoMixin<AMDGPUWaitSGPRHazardsPass> {
+    : public OptionalPassInfoMixin<AMDGPUWaitSGPRHazardsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/GCNDPPCombine.h b/llvm/lib/Target/AMDGPU/GCNDPPCombine.h
index cc8979b858b93..f1d4c245c2e6e 100644
--- a/llvm/lib/Target/AMDGPU/GCNDPPCombine.h
+++ b/llvm/lib/Target/AMDGPU/GCNDPPCombine.h
@@ -12,7 +12,7 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class GCNDPPCombinePass : public PassInfoMixin<GCNDPPCombinePass> {
+class GCNDPPCombinePass : public OptionalPassInfoMixin<GCNDPPCombinePass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MAM);
diff --git a/llvm/lib/Target/AMDGPU/GCNNSAReassign.h b/llvm/lib/Target/AMDGPU/GCNNSAReassign.h
index 97a72e7ddbb24..d466dd1522f07 100644
--- a/llvm/lib/Target/AMDGPU/GCNNSAReassign.h
+++ b/llvm/lib/Target/AMDGPU/GCNNSAReassign.h
@@ -12,7 +12,7 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class GCNNSAReassignPass : public PassInfoMixin<GCNNSAReassignPass> {
+class GCNNSAReassignPass : public OptionalPassInfoMixin<GCNNSAReassignPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/GCNPreRALongBranchReg.h b/llvm/lib/Target/AMDGPU/GCNPreRALongBranchReg.h
index 4cd7dea83a061..6bf8b0c3d0da8 100644
--- a/llvm/lib/Target/AMDGPU/GCNPreRALongBranchReg.h
+++ b/llvm/lib/Target/AMDGPU/GCNPreRALongBranchReg.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class GCNPreRALongBranchRegPass
-    : public PassInfoMixin<GCNPreRALongBranchRegPass> {
+    : public OptionalPassInfoMixin<GCNPreRALongBranchRegPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/GCNPreRAOptimizations.h b/llvm/lib/Target/AMDGPU/GCNPreRAOptimizations.h
index 295152b64b4c6..6cfc389cf31b8 100644
--- a/llvm/lib/Target/AMDGPU/GCNPreRAOptimizations.h
+++ b/llvm/lib/Target/AMDGPU/GCNPreRAOptimizations.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class GCNPreRAOptimizationsPass
-    : public PassInfoMixin<GCNPreRAOptimizationsPass> {
+    : public OptionalPassInfoMixin<GCNPreRAOptimizationsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h b/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h
index b2c3190b5c6ba..bd8327c51cc60 100644
--- a/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h
+++ b/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class GCNRewritePartialRegUsesPass
-    : public PassInfoMixin<GCNRewritePartialRegUsesPass> {
+    : public OptionalPassInfoMixin<GCNRewritePartialRegUsesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h
index d7551a45887b9..73e079466a02e 100644
--- a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h
+++ b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class SIFixSGPRCopiesPass : public PassInfoMixin<SIFixSGPRCopiesPass> {
+class SIFixSGPRCopiesPass : public OptionalPassInfoMixin<SIFixSGPRCopiesPass> {
 public:
   SIFixSGPRCopiesPass() = default;
   PreservedAnalyses run(MachineFunction &MF,
diff --git a/llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h b/llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h
index 7b098b71597ff..2e61f9773f6f5 100644
--- a/llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h
+++ b/llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h
@@ -12,7 +12,7 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class SIFixVGPRCopiesPass : public PassInfoMixin<SIFixVGPRCopiesPass> {
+class SIFixVGPRCopiesPass : public OptionalPassInfoMixin<SIFixVGPRCopiesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.h b/llvm/lib/Target/AMDGPU/SIFoldOperands.h
index 2477707538c8f..5e56dfe0253bd 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.h
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.h
@@ -12,7 +12,7 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class SIFoldOperandsPass : public PassInfoMixin<SIFoldOperandsPass> {
+class SIFoldOperandsPass : public OptionalPassInfoMixin<SIFoldOperandsPass> {
 public:
   SIFoldOperandsPass() = default;
   PreservedAnalyses run(MachineFunction &MF,
diff --git a/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.h b/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.h
index c50a46f9ac2fb..7709ba1e57b63 100644
--- a/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.h
+++ b/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.h
@@ -12,7 +12,8 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class SIFormMemoryClausesPass : public PassInfoMixin<SIFormMemoryClausesPass> {
+class SIFormMemoryClausesPass
+    : public OptionalPassInfoMixin<SIFormMemoryClausesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.h b/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.h
index 317dd8c208b1c..eab57ab30de79 100644
--- a/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.h
+++ b/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class SILoadStoreOptimizerPass
-    : public PassInfoMixin<SILoadStoreOptimizerPass> {
+    : public OptionalPassInfoMixin<SILoadStoreOptimizerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SILowerControlFlow.h b/llvm/lib/Target/AMDGPU/SILowerControlFlow.h
index 23803c679c246..8b0df82d06720 100644
--- a/llvm/lib/Target/AMDGPU/SILowerControlFlow.h
+++ b/llvm/lib/Target/AMDGPU/SILowerControlFlow.h
@@ -12,7 +12,8 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class SILowerControlFlowPass : public PassInfoMixin<SILowerControlFlowPass> {
+class SILowerControlFlowPass
+    : public OptionalPassInfoMixin<SILowerControlFlowPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h
index 64ba3029f1c55..60b4907bc2031 100644
--- a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h
+++ b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h
@@ -12,7 +12,8 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class SILowerSGPRSpillsPass : public PassInfoMixin<SILowerSGPRSpillsPass> {
+class SILowerSGPRSpillsPass
+    : public OptionalPassInfoMixin<SILowerSGPRSpillsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SILowerWWMCopies.h b/llvm/lib/Target/AMDGPU/SILowerWWMCopies.h
index cfc8100901760..8cd1554c360de 100644
--- a/llvm/lib/Target/AMDGPU/SILowerWWMCopies.h
+++ b/llvm/lib/Target/AMDGPU/SILowerWWMCopies.h
@@ -12,7 +12,8 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class SILowerWWMCopiesPass : public PassInfoMixin<SILowerWWMCopiesPass> {
+class SILowerWWMCopiesPass
+    : public OptionalPassInfoMixin<SILowerWWMCopiesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.h b/llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.h
index f170a4733279b..9d2131bf81d70 100644
--- a/llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.h
+++ b/llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class SIOptimizeExecMaskingPass
-    : public PassInfoMixin<SIOptimizeExecMaskingPass> {
+    : public OptionalPassInfoMixin<SIOptimizeExecMaskingPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.h b/llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.h
index cf9c6ce5f0083..0e7946e0cd513 100644
--- a/llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.h
+++ b/llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class SIOptimizeExecMaskingPreRAPass
-    : public PassInfoMixin<SIOptimizeExecMaskingPreRAPass> {
+    : public OptionalPassInfoMixin<SIOptimizeExecMaskingPreRAPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.h b/llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.h
index c771df379cb37..f18014bb8c2f6 100644
--- a/llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.h
+++ b/llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class SIOptimizeVGPRLiveRangePass
-    : public PassInfoMixin<SIOptimizeVGPRLiveRangePass> {
+    : public OptionalPassInfoMixin<SIOptimizeVGPRLiveRangePass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SIPeepholeSDWA.h b/llvm/lib/Target/AMDGPU/SIPeepholeSDWA.h
index 217867220f7d8..768a75589ff34 100644
--- a/llvm/lib/Target/AMDGPU/SIPeepholeSDWA.h
+++ b/llvm/lib/Target/AMDGPU/SIPeepholeSDWA.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class SIPeepholeSDWAPass : public PassInfoMixin<SIPeepholeSDWAPass> {
+class SIPeepholeSDWAPass : public OptionalPassInfoMixin<SIPeepholeSDWAPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SIPostRABundler.h b/llvm/lib/Target/AMDGPU/SIPostRABundler.h
index 2038bbe1617f4..3cae043a1dc2d 100644
--- a/llvm/lib/Target/AMDGPU/SIPostRABundler.h
+++ b/llvm/lib/Target/AMDGPU/SIPostRABundler.h
@@ -12,7 +12,7 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class SIPostRABundlerPass : public PassInfoMixin<SIPostRABundlerPass> {
+class SIPostRABundlerPass : public OptionalPassInfoMixin<SIPostRABundlerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h b/llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h
index 9964817649168..1bfc49acd420a 100644
--- a/llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h
+++ b/llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class SIPreAllocateWWMRegsPass
-    : public PassInfoMixin<SIPreAllocateWWMRegsPass> {
+    : public OptionalPassInfoMixin<SIPreAllocateWWMRegsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/SIShrinkInstructions.h b/llvm/lib/Target/AMDGPU/SIShrinkInstructions.h
index 7fc99ea65d285..30ff83206d67c 100644
--- a/llvm/lib/Target/AMDGPU/SIShrinkInstructions.h
+++ b/llvm/lib/Target/AMDGPU/SIShrinkInstructions.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class SIShrinkInstructionsPass
-    : public PassInfoMixin<SIShrinkInstructionsPass> {
+    : public OptionalPassInfoMixin<SIShrinkInstructionsPass> {
 public:
   SIShrinkInstructionsPass() = default;
   PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
diff --git a/llvm/lib/Target/AMDGPU/SIWholeQuadMode.h b/llvm/lib/Target/AMDGPU/SIWholeQuadMode.h
index 87350b810bba7..f1c86811e5736 100644
--- a/llvm/lib/Target/AMDGPU/SIWholeQuadMode.h
+++ b/llvm/lib/Target/AMDGPU/SIWholeQuadMode.h
@@ -12,7 +12,7 @@
 #include "llvm/CodeGen/MachinePassManager.h"
 
 namespace llvm {
-class SIWholeQuadModePass : public PassInfoMixin<SIWholeQuadModePass> {
+class SIWholeQuadModePass : public OptionalPassInfoMixin<SIWholeQuadModePass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/ARM/ARM.h b/llvm/lib/Target/ARM/ARM.h
index 9681329f8b29b..08caef8419d12 100644
--- a/llvm/lib/Target/ARM/ARM.h
+++ b/llvm/lib/Target/ARM/ARM.h
@@ -83,13 +83,13 @@ void initializeThumb2ITBlockPass(PassRegistry &);
 void initializeThumb2SizeReducePass(PassRegistry &);
 
 class ARMPreAllocLoadStoreOptPass
-    : public PassInfoMixin<ARMPreAllocLoadStoreOptPass> {
+    : public OptionalPassInfoMixin<ARMPreAllocLoadStoreOptPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
-class ARMLoadStoreOptPass : public PassInfoMixin<ARMLoadStoreOptPass> {
+class ARMLoadStoreOptPass : public OptionalPassInfoMixin<ARMLoadStoreOptPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/BPF/BPF.h b/llvm/lib/Target/BPF/BPF.h
index 7faae8b725b43..d561e0a2cb66b 100644
--- a/llvm/lib/Target/BPF/BPF.h
+++ b/llvm/lib/Target/BPF/BPF.h
@@ -45,53 +45,44 @@ void initializeBPFMIPreEmitPeepholePass(PassRegistry &);
 void initializeBPFMISimplifyPatchablePass(PassRegistry &);
 
 class BPFAbstractMemberAccessPass
-    : public PassInfoMixin<BPFAbstractMemberAccessPass> {
+    : public MandatoryPassInfoMixin<BPFAbstractMemberAccessPass> {
   BPFTargetMachine *TM;
 
 public:
   BPFAbstractMemberAccessPass(BPFTargetMachine *TM) : TM(TM) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
-class BPFPreserveDITypePass : public PassInfoMixin<BPFPreserveDITypePass> {
+class BPFPreserveDITypePass
+    : public MandatoryPassInfoMixin<BPFPreserveDITypePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
-class BPFIRPeepholePass : public PassInfoMixin<BPFIRPeepholePass> {
+class BPFIRPeepholePass : public MandatoryPassInfoMixin<BPFIRPeepholePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
 class BPFASpaceCastSimplifyPass
-    : public PassInfoMixin<BPFASpaceCastSimplifyPass> {
+    : public MandatoryPassInfoMixin<BPFASpaceCastSimplifyPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
-
-  static bool isRequired() { return true; }
 };
 
-class BPFAdjustOptPass : public PassInfoMixin<BPFAdjustOptPass> {
+class BPFAdjustOptPass : public OptionalPassInfoMixin<BPFAdjustOptPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
 class BPFPreserveStaticOffsetPass
-    : public PassInfoMixin<BPFPreserveStaticOffsetPass> {
+    : public MandatoryPassInfoMixin<BPFPreserveStaticOffsetPass> {
   bool AllowPartial;
 
 public:
   BPFPreserveStaticOffsetPass(bool AllowPartial) : AllowPartial(AllowPartial) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
-  static bool isRequired() { return true; }
-
   static std::pair<GetElementPtrInst *, LoadInst *>
   reconstructLoad(CallInst *Call);
 
diff --git a/llvm/lib/Target/DirectX/DXILCBufferAccess.h b/llvm/lib/Target/DirectX/DXILCBufferAccess.h
index 6c1cde164004e..40615915e0242 100644
--- a/llvm/lib/Target/DirectX/DXILCBufferAccess.h
+++ b/llvm/lib/Target/DirectX/DXILCBufferAccess.h
@@ -18,7 +18,7 @@
 
 namespace llvm {
 
-class DXILCBufferAccess : public PassInfoMixin<DXILCBufferAccess> {
+class DXILCBufferAccess : public OptionalPassInfoMixin<DXILCBufferAccess> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/DirectX/DXILDataScalarization.h b/llvm/lib/Target/DirectX/DXILDataScalarization.h
index e8cd495729431..ee4eb0a529fde 100644
--- a/llvm/lib/Target/DirectX/DXILDataScalarization.h
+++ b/llvm/lib/Target/DirectX/DXILDataScalarization.h
@@ -15,7 +15,8 @@
 namespace llvm {
 
 /// A pass that transforms Vectors to Arrays
-class DXILDataScalarization : public PassInfoMixin<DXILDataScalarization> {
+class DXILDataScalarization
+    : public OptionalPassInfoMixin<DXILDataScalarization> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/lib/Target/DirectX/DXILFinalizeLinkage.h b/llvm/lib/Target/DirectX/DXILFinalizeLinkage.h
index aab1bc3f7a28e..71e78d54d6793 100644
--- a/llvm/lib/Target/DirectX/DXILFinalizeLinkage.h
+++ b/llvm/lib/Target/DirectX/DXILFinalizeLinkage.h
@@ -21,10 +21,9 @@
 
 namespace llvm {
 
-class DXILFinalizeLinkage : public PassInfoMixin<DXILFinalizeLinkage> {
+class DXILFinalizeLinkage : public MandatoryPassInfoMixin<DXILFinalizeLinkage> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
-  static bool isRequired() { return true; }
 };
 
 class DXILFinalizeLinkageLegacy : public ModulePass {
diff --git a/llvm/lib/Target/DirectX/DXILFlattenArrays.h b/llvm/lib/Target/DirectX/DXILFlattenArrays.h
index aae68496af620..517888d660e33 100644
--- a/llvm/lib/Target/DirectX/DXILFlattenArrays.h
+++ b/llvm/lib/Target/DirectX/DXILFlattenArrays.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 /// A pass that transforms multidimensional arrays into one-dimensional arrays.
-class DXILFlattenArrays : public PassInfoMixin<DXILFlattenArrays> {
+class DXILFlattenArrays : public OptionalPassInfoMixin<DXILFlattenArrays> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/lib/Target/DirectX/DXILForwardHandleAccesses.h b/llvm/lib/Target/DirectX/DXILForwardHandleAccesses.h
index 76940287a50ad..fa40e60d48fed 100644
--- a/llvm/lib/Target/DirectX/DXILForwardHandleAccesses.h
+++ b/llvm/lib/Target/DirectX/DXILForwardHandleAccesses.h
@@ -18,7 +18,7 @@
 namespace llvm {
 
 class DXILForwardHandleAccesses
-    : public PassInfoMixin<DXILForwardHandleAccesses> {
+    : public OptionalPassInfoMixin<DXILForwardHandleAccesses> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.h b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.h
index 43fc4d7735e1f..87624ce0c2ca1 100644
--- a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.h
+++ b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.h
@@ -14,7 +14,8 @@
 namespace llvm {
 
 /// A pass that transforms DXIL Intrinsics that don't have DXIL opCodes
-class DXILIntrinsicExpansion : public PassInfoMixin<DXILIntrinsicExpansion> {
+class DXILIntrinsicExpansion
+    : public OptionalPassInfoMixin<DXILIntrinsicExpansion> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/lib/Target/DirectX/DXILLegalizePass.h b/llvm/lib/Target/DirectX/DXILLegalizePass.h
index 9d6d1cd19081d..77f4905a248ef 100644
--- a/llvm/lib/Target/DirectX/DXILLegalizePass.h
+++ b/llvm/lib/Target/DirectX/DXILLegalizePass.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class DXILLegalizePass : public PassInfoMixin<DXILLegalizePass> {
+class DXILLegalizePass : public OptionalPassInfoMixin<DXILLegalizePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
diff --git a/llvm/lib/Target/DirectX/DXILMemIntrinsics.h b/llvm/lib/Target/DirectX/DXILMemIntrinsics.h
index 46f105026d909..738840505e670 100644
--- a/llvm/lib/Target/DirectX/DXILMemIntrinsics.h
+++ b/llvm/lib/Target/DirectX/DXILMemIntrinsics.h
@@ -15,7 +15,7 @@
 namespace llvm {
 
 /// Transform all llvm memory intrinsics to explicit loads and stores.
-class DXILMemIntrinsics : public PassInfoMixin<DXILMemIntrinsics> {
+class DXILMemIntrinsics : public OptionalPassInfoMixin<DXILMemIntrinsics> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.h b/llvm/lib/Target/DirectX/DXILOpLowering.h
index fe357da7bb905..87f1fc3f0e7d6 100644
--- a/llvm/lib/Target/DirectX/DXILOpLowering.h
+++ b/llvm/lib/Target/DirectX/DXILOpLowering.h
@@ -17,7 +17,7 @@
 
 namespace llvm {
 
-class DXILOpLowering : public PassInfoMixin<DXILOpLowering> {
+class DXILOpLowering : public OptionalPassInfoMixin<DXILOpLowering> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Target/DirectX/DXILPostOptimizationValidation.h b/llvm/lib/Target/DirectX/DXILPostOptimizationValidation.h
index cb5e624514272..db421065e819f 100644
--- a/llvm/lib/Target/DirectX/DXILPostOptimizationValidation.h
+++ b/llvm/lib/Target/DirectX/DXILPostOptimizationValidation.h
@@ -19,7 +19,7 @@
 namespace llvm {
 
 class DXILPostOptimizationValidation
-    : public PassInfoMixin<DXILPostOptimizationValidation> {
+    : public OptionalPassInfoMixin<DXILPostOptimizationValidation> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Target/DirectX/DXILPrettyPrinter.h b/llvm/lib/Target/DirectX/DXILPrettyPrinter.h
index 84e17ac0f2ec6..925ef726801a5 100644
--- a/llvm/lib/Target/DirectX/DXILPrettyPrinter.h
+++ b/llvm/lib/Target/DirectX/DXILPrettyPrinter.h
@@ -19,7 +19,8 @@
 namespace llvm {
 
 /// A pass that prints resources in a format suitable for textual DXIL.
-class DXILPrettyPrinterPass : public PassInfoMixin<DXILPrettyPrinterPass> {
+class DXILPrettyPrinterPass
+    : public OptionalPassInfoMixin<DXILPrettyPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/lib/Target/DirectX/DXILResourceAccess.h b/llvm/lib/Target/DirectX/DXILResourceAccess.h
index 9e17b57c62578..56d7760c9621e 100644
--- a/llvm/lib/Target/DirectX/DXILResourceAccess.h
+++ b/llvm/lib/Target/DirectX/DXILResourceAccess.h
@@ -18,7 +18,7 @@
 
 namespace llvm {
 
-class DXILResourceAccess : public PassInfoMixin<DXILResourceAccess> {
+class DXILResourceAccess : public OptionalPassInfoMixin<DXILResourceAccess> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/DirectX/DXILResourceImplicitBinding.h b/llvm/lib/Target/DirectX/DXILResourceImplicitBinding.h
index 86ca9ec6842a0..dabeeb6937f09 100644
--- a/llvm/lib/Target/DirectX/DXILResourceImplicitBinding.h
+++ b/llvm/lib/Target/DirectX/DXILResourceImplicitBinding.h
@@ -19,7 +19,7 @@
 namespace llvm {
 
 class DXILResourceImplicitBinding
-    : public PassInfoMixin<DXILResourceImplicitBinding> {
+    : public OptionalPassInfoMixin<DXILResourceImplicitBinding> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.h b/llvm/lib/Target/DirectX/DXILRootSignature.h
index ec82aa93dd07c..1bc9e7ccbddf3 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.h
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.h
@@ -83,7 +83,7 @@ class RootSignatureAnalysisWrapper : public ModulePass {
 
 /// Printer pass for RootSignatureAnalysis results.
 class RootSignatureAnalysisPrinter
-    : public PassInfoMixin<RootSignatureAnalysisPrinter> {
+    : public OptionalPassInfoMixin<RootSignatureAnalysisPrinter> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/lib/Target/DirectX/DXILShaderFlags.h b/llvm/lib/Target/DirectX/DXILShaderFlags.h
index a0820572e5fed..f74eb7482d2bf 100644
--- a/llvm/lib/Target/DirectX/DXILShaderFlags.h
+++ b/llvm/lib/Target/DirectX/DXILShaderFlags.h
@@ -121,7 +121,7 @@ class ShaderFlagsAnalysis : public AnalysisInfoMixin<ShaderFlagsAnalysis> {
 
 /// Printer pass for ShaderFlagsAnalysis results.
 class ShaderFlagsAnalysisPrinter
-    : public PassInfoMixin<ShaderFlagsAnalysisPrinter> {
+    : public OptionalPassInfoMixin<ShaderFlagsAnalysisPrinter> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.h b/llvm/lib/Target/DirectX/DXILTranslateMetadata.h
index cfb8aaa8f98b5..83c4182add7ff 100644
--- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.h
+++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.h
@@ -16,7 +16,8 @@ namespace llvm {
 
 /// A pass that transforms LLVM Metadata in the module to it's DXIL equivalent,
 /// then emits all recognized DXIL Metadata
-class DXILTranslateMetadata : public PassInfoMixin<DXILTranslateMetadata> {
+class DXILTranslateMetadata
+    : public OptionalPassInfoMixin<DXILTranslateMetadata> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.h b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.h
index 28ec83b05dac2..ef4aef9a6ce43 100644
--- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.h
+++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.h
@@ -15,7 +15,7 @@
 namespace llvm {
 
 struct HexagonLoopIdiomRecognitionPass
-    : PassInfoMixin<HexagonLoopIdiomRecognitionPass> {
+    : OptionalPassInfoMixin<HexagonLoopIdiomRecognitionPass> {
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
 };
diff --git a/llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.h b/llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.h
index 7daa0f2a91b7e..12f3fb7f49871 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.h
+++ b/llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.h
@@ -126,7 +126,7 @@ class Loop;
 
 /// Hexagon Vector Loop Carried Reuse Pass
 struct HexagonVectorLoopCarriedReusePass
-    : public PassInfoMixin<HexagonVectorLoopCarriedReusePass> {
+    : public OptionalPassInfoMixin<HexagonVectorLoopCarriedReusePass> {
   HexagonVectorLoopCarriedReusePass() = default;
 
   /// Run pass over the Loop.
diff --git a/llvm/lib/Target/NVPTX/NVPTX.h b/llvm/lib/Target/NVPTX/NVPTX.h
index 09a94034894eb..bfd200b3093aa 100644
--- a/llvm/lib/Target/NVPTX/NVPTX.h
+++ b/llvm/lib/Target/NVPTX/NVPTX.h
@@ -84,15 +84,15 @@ void initializeNVPTXTagInvariantLoadLegacyPassPass(PassRegistry &);
 void initializeNVPTXIRPeepholePass(PassRegistry &);
 void initializeNVPTXPrologEpilogPassPass(PassRegistry &);
 
-struct NVVMIntrRangePass : PassInfoMixin<NVVMIntrRangePass> {
+struct NVVMIntrRangePass : OptionalPassInfoMixin<NVVMIntrRangePass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-struct NVPTXIRPeepholePass : PassInfoMixin<NVPTXIRPeepholePass> {
+struct NVPTXIRPeepholePass : OptionalPassInfoMixin<NVPTXIRPeepholePass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-struct NVVMReflectPass : PassInfoMixin<NVVMReflectPass> {
+struct NVVMReflectPass : OptionalPassInfoMixin<NVVMReflectPass> {
   NVVMReflectPass() : SmVersion(0) {}
   NVVMReflectPass(unsigned SmVersion) : SmVersion(SmVersion) {}
   PreservedAnalyses run(Module &F, ModuleAnalysisManager &AM);
@@ -101,20 +101,20 @@ struct NVVMReflectPass : PassInfoMixin<NVVMReflectPass> {
   unsigned SmVersion;
 };
 
-struct GenericToNVVMPass : PassInfoMixin<GenericToNVVMPass> {
+struct GenericToNVVMPass : OptionalPassInfoMixin<GenericToNVVMPass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
-struct NVPTXCopyByValArgsPass : PassInfoMixin<NVPTXCopyByValArgsPass> {
+struct NVPTXCopyByValArgsPass : OptionalPassInfoMixin<NVPTXCopyByValArgsPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 struct NVPTXSetByValParamAlignPass
-    : PassInfoMixin<NVPTXSetByValParamAlignPass> {
+    : OptionalPassInfoMixin<NVPTXSetByValParamAlignPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-struct NVPTXLowerArgsPass : PassInfoMixin<NVPTXLowerArgsPass> {
+struct NVPTXLowerArgsPass : OptionalPassInfoMixin<NVPTXLowerArgsPass> {
 private:
   TargetMachine &TM;
 
@@ -124,11 +124,12 @@ struct NVPTXLowerArgsPass : PassInfoMixin<NVPTXLowerArgsPass> {
 };
 
 struct NVPTXMarkKernelPtrsGlobalPass
-    : PassInfoMixin<NVPTXMarkKernelPtrsGlobalPass> {
+    : OptionalPassInfoMixin<NVPTXMarkKernelPtrsGlobalPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-struct NVPTXTagInvariantLoadsPass : PassInfoMixin<NVPTXTagInvariantLoadsPass> {
+struct NVPTXTagInvariantLoadsPass
+    : OptionalPassInfoMixin<NVPTXTagInvariantLoadsPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h b/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h
index df58ddd3e78fc..29be3434721b8 100644
--- a/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h
+++ b/llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.h
@@ -17,7 +17,7 @@ class PassRegistry;
 
 /// Lower llvm.global_ctors and llvm.global_dtors to special kernels.
 class NVPTXCtorDtorLoweringPass
-    : public PassInfoMixin<NVPTXCtorDtorLoweringPass> {
+    : public OptionalPassInfoMixin<NVPTXCtorDtorLoweringPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/RISCV/RISCV.h b/llvm/lib/Target/RISCV/RISCV.h
index 048db205e2289..929a8d8f17b4f 100644
--- a/llvm/lib/Target/RISCV/RISCV.h
+++ b/llvm/lib/Target/RISCV/RISCV.h
@@ -26,7 +26,8 @@ class RISCVRegisterBankInfo;
 class RISCVSubtarget;
 class RISCVTargetMachine;
 
-class RISCVCodeGenPreparePass : public PassInfoMixin<RISCVCodeGenPreparePass> {
+class RISCVCodeGenPreparePass
+    : public OptionalPassInfoMixin<RISCVCodeGenPreparePass> {
 private:
   const RISCVTargetMachine *TM;
 
diff --git a/llvm/lib/Target/SPIRV/SPIRVCBufferAccess.h b/llvm/lib/Target/SPIRV/SPIRVCBufferAccess.h
index 7ac0cc153c5fb..6ac0a9c6eed6f 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCBufferAccess.h
+++ b/llvm/lib/Target/SPIRV/SPIRVCBufferAccess.h
@@ -12,7 +12,7 @@
 
 namespace llvm {
 
-class SPIRVCBufferAccess : public PassInfoMixin<SPIRVCBufferAccess> {
+class SPIRVCBufferAccess : public OptionalPassInfoMixin<SPIRVCBufferAccess> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/SPIRV/SPIRVCtorDtorLowering.h b/llvm/lib/Target/SPIRV/SPIRVCtorDtorLowering.h
index daeb6da7356cc..55e10c9aca962 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCtorDtorLowering.h
+++ b/llvm/lib/Target/SPIRV/SPIRVCtorDtorLowering.h
@@ -17,7 +17,7 @@ class PassRegistry;
 
 /// Lower llvm.global_ctors and llvm.global_dtors to special kernels.
 class SPIRVCtorDtorLoweringPass
-    : public PassInfoMixin<SPIRVCtorDtorLoweringPass> {
+    : public OptionalPassInfoMixin<SPIRVCtorDtorLoweringPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.h b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.h
index ad7c95c649f00..1e75bec07d097 100644
--- a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.h
+++ b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.h
@@ -15,7 +15,8 @@ namespace llvm {
 
 class SPIRVTargetMachine;
 
-class SPIRVEmitIntrinsicsPass : public PassInfoMixin<SPIRVEmitIntrinsicsPass> {
+class SPIRVEmitIntrinsicsPass
+    : public OptionalPassInfoMixin<SPIRVEmitIntrinsicsPass> {
   const SPIRVTargetMachine &TM;
 
 public:
diff --git a/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.h b/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.h
index decb7f5f9f1b3..a84cd83974941 100644
--- a/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.h
+++ b/llvm/lib/Target/SPIRV/SPIRVLegalizeZeroSizeArrays.h
@@ -16,7 +16,7 @@ namespace llvm {
 class SPIRVTargetMachine;
 
 class SPIRVLegalizeZeroSizeArrays
-    : public PassInfoMixin<SPIRVLegalizeZeroSizeArrays> {
+    : public OptionalPassInfoMixin<SPIRVLegalizeZeroSizeArrays> {
   const SPIRVTargetMachine &TM;
 
 public:
diff --git a/llvm/lib/Target/SPIRV/SPIRVPushConstantAccess.h b/llvm/lib/Target/SPIRV/SPIRVPushConstantAccess.h
index 8e897b99ae34b..ea5330f431817 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPushConstantAccess.h
+++ b/llvm/lib/Target/SPIRV/SPIRVPushConstantAccess.h
@@ -14,7 +14,8 @@
 
 namespace llvm {
 
-class SPIRVPushConstantAccess : public PassInfoMixin<SPIRVPushConstantAccess> {
+class SPIRVPushConstantAccess
+    : public OptionalPassInfoMixin<SPIRVPushConstantAccess> {
   const SPIRVTargetMachine &TM;
 
 public:
diff --git a/llvm/lib/Target/SPIRV/SPIRVStructurizerWrapper.h b/llvm/lib/Target/SPIRV/SPIRVStructurizerWrapper.h
index b7b3e18b1b19c..eec39ced6a2ff 100644
--- a/llvm/lib/Target/SPIRV/SPIRVStructurizerWrapper.h
+++ b/llvm/lib/Target/SPIRV/SPIRVStructurizerWrapper.h
@@ -19,7 +19,7 @@
 namespace llvm {
 
 class SPIRVStructurizerWrapper
-    : public PassInfoMixin<SPIRVStructurizerWrapper> {
+    : public OptionalPassInfoMixin<SPIRVStructurizerWrapper> {
 public:
   PreservedAnalyses run(Function &M, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h
index 5ff33a48b63ae..448037f6934d4 100644
--- a/llvm/lib/Target/X86/X86.h
+++ b/llvm/lib/Target/X86/X86.h
@@ -36,7 +36,8 @@ class X86TargetMachine;
 FunctionPass *createX86ISelDag(X86TargetMachine &TM, CodeGenOptLevel OptLevel);
 
 /// This pass initializes a global base register for PIC on x86-32.
-class X86GlobalBaseRegPass : public PassInfoMixin<X86GlobalBaseRegPass> {
+class X86GlobalBaseRegPass
+    : public OptionalPassInfoMixin<X86GlobalBaseRegPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -48,7 +49,7 @@ FunctionPass *createX86GlobalBaseRegLegacyPass();
 /// the TLS base address for the module is only fetched once per execution path
 /// through the function.
 class X86CleanupLocalDynamicTLSPass
-    : public PassInfoMixin<X86CleanupLocalDynamicTLSPass> {
+    : public OptionalPassInfoMixin<X86CleanupLocalDynamicTLSPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -59,7 +60,7 @@ FunctionPass *createCleanupLocalDynamicTLSLegacyPass();
 /// This function returns a pass which converts floating-point register
 /// references and pseudo instructions into floating-point stack references and
 /// physical instructions.
-class X86FPStackifierPass : public PassInfoMixin<X86FPStackifierPass> {
+class X86FPStackifierPass : public OptionalPassInfoMixin<X86FPStackifierPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -74,7 +75,7 @@ FunctionPass *createX86IssueVZeroUpperPass();
 /// This pass inserts ENDBR instructions before indirect jump/call
 /// destinations as part of CET IBT mechanism.
 class X86IndirectBranchTrackingPass
-    : public PassInfoMixin<X86IndirectBranchTrackingPass> {
+    : public OptionalPassInfoMixin<X86IndirectBranchTrackingPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -89,7 +90,7 @@ FunctionPass *createX86PadShortFunctions();
 /// Return a pass that selectively replaces certain instructions (like add,
 /// sub, inc, dec, some shifts, and some multiplies) by equivalent LEA
 /// instructions, in order to eliminate execution delays in some processors.
-class X86FixupLEAsPass : public PassInfoMixin<X86FixupLEAsPass> {
+class X86FixupLEAsPass : public OptionalPassInfoMixin<X86FixupLEAsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -99,7 +100,8 @@ FunctionPass *createX86FixupLEAsLegacyPass();
 
 /// Return a pass that replaces equivalent slower instructions with faster
 /// ones.
-class X86FixupInstTuningPass : public PassInfoMixin<X86FixupInstTuningPass> {
+class X86FixupInstTuningPass
+    : public OptionalPassInfoMixin<X86FixupInstTuningPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -109,7 +111,7 @@ FunctionPass *createX86FixupInstTuningLegacyPass();
 
 /// Return a pass that reduces the size of vector constant pool loads.
 class X86FixupVectorConstantsPass
-    : public PassInfoMixin<X86FixupInstTuningPass> {
+    : public OptionalPassInfoMixin<X86FixupInstTuningPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -119,7 +121,7 @@ FunctionPass *createX86FixupVectorConstantsLegacyPass();
 
 /// Return a pass that removes redundant LEA instructions and redundant address
 /// recalculations.
-class X86OptimizeLEAsPass : public PassInfoMixin<X86OptimizeLEAsPass> {
+class X86OptimizeLEAsPass : public OptionalPassInfoMixin<X86OptimizeLEAsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -128,7 +130,7 @@ class X86OptimizeLEAsPass : public PassInfoMixin<X86OptimizeLEAsPass> {
 FunctionPass *createX86OptimizeLEAsLegacyPass();
 
 /// Return a pass that transforms setcc + movzx pairs into xor + setcc.
-class X86FixupSetCCPass : public PassInfoMixin<X86FixupSetCCPass> {
+class X86FixupSetCCPass : public OptionalPassInfoMixin<X86FixupSetCCPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -139,7 +141,7 @@ FunctionPass *createX86FixupSetCCLegacyPass();
 /// Return a pass that avoids creating store forward block issues in the
 /// hardware.
 class X86AvoidStoreForwardingBlocksPass
-    : public PassInfoMixin<X86AvoidStoreForwardingBlocksPass> {
+    : public OptionalPassInfoMixin<X86AvoidStoreForwardingBlocksPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -149,7 +151,7 @@ FunctionPass *createX86AvoidStoreForwardingBlocksLegacyPass();
 
 /// Return a pass that lowers EFLAGS copy pseudo instructions.
 class X86FlagsCopyLoweringPass
-    : public PassInfoMixin<X86FlagsCopyLoweringPass> {
+    : public OptionalPassInfoMixin<X86FlagsCopyLoweringPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -159,7 +161,7 @@ FunctionPass *createX86FlagsCopyLoweringLegacyPass();
 
 /// Return a pass that expands DynAlloca pseudo-instructions.
 class X86DynAllocaExpanderPass
-    : public PassInfoMixin<X86DynAllocaExpanderPass> {
+    : public OptionalPassInfoMixin<X86DynAllocaExpanderPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -168,7 +170,7 @@ class X86DynAllocaExpanderPass
 FunctionPass *createX86DynAllocaExpanderLegacyPass();
 
 /// Return a pass that config the tile registers.
-class X86TileConfigPass : public PassInfoMixin<X86TileConfigPass> {
+class X86TileConfigPass : public OptionalPassInfoMixin<X86TileConfigPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -178,7 +180,7 @@ FunctionPass *createX86TileConfigLegacyPass();
 
 /// Return a pass that preconfig the tile registers before fast reg allocation.
 class X86FastPreTileConfigPass
-    : public PassInfoMixin<X86FastPreTileConfigPass> {
+    : public OptionalPassInfoMixin<X86FastPreTileConfigPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -187,7 +189,8 @@ class X86FastPreTileConfigPass
 FunctionPass *createX86FastPreTileConfigLegacyPass();
 
 /// Return a pass that config the tile registers after fast reg allocation.
-class X86FastTileConfigPass : public PassInfoMixin<X86FastTileConfigPass> {
+class X86FastTileConfigPass
+    : public OptionalPassInfoMixin<X86FastTileConfigPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -196,7 +199,8 @@ class X86FastTileConfigPass : public PassInfoMixin<X86FastTileConfigPass> {
 FunctionPass *createX86FastTileConfigLegacyPass();
 
 /// Return a pass that insert pseudo tile config instruction.
-class X86PreTileConfigPass : public PassInfoMixin<X86PreTileConfigPass> {
+class X86PreTileConfigPass
+    : public OptionalPassInfoMixin<X86PreTileConfigPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -205,7 +209,8 @@ class X86PreTileConfigPass : public PassInfoMixin<X86PreTileConfigPass> {
 FunctionPass *createX86PreTileConfigLegacyPass();
 
 /// Return a pass that lower the tile copy instruction.
-class X86LowerTileCopyPass : public PassInfoMixin<X86LowerTileCopyPass> {
+class X86LowerTileCopyPass
+    : public OptionalPassInfoMixin<X86LowerTileCopyPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -218,11 +223,10 @@ FunctionPass *createX86LowerTileCopyLegacyPass();
 /// ensures that the open interval of function start and end PCs contains all
 /// return addresses for the benefit of the Windows x64 unwinder.
 class X86AvoidTrailingCallPass
-    : public PassInfoMixin<X86AvoidTrailingCallPass> {
+    : public MandatoryPassInfoMixin<X86AvoidTrailingCallPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 FunctionPass *createX86AvoidTrailingCallLegacyPass();
@@ -230,7 +234,7 @@ FunctionPass *createX86AvoidTrailingCallLegacyPass();
 /// Return a pass that optimizes the code-size of x86 call sequences. This is
 /// done by replacing esp-relative movs with pushes.
 class X86CallFrameOptimizationPass
-    : public PassInfoMixin<X86CallFrameOptimizationPass> {
+    : public OptionalPassInfoMixin<X86CallFrameOptimizationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -241,7 +245,7 @@ FunctionPass *createX86CallFrameOptimizationLegacyPass();
 /// Return an IR pass that inserts EH registration stack objects and explicit
 /// EH state updates. This pass must run after EH preparation, which does
 /// Windows-specific but architecture-neutral preparation.
-class X86WinEHStatePass : public PassInfoMixin<X86WinEHStatePass> {
+class X86WinEHStatePass : public OptionalPassInfoMixin<X86WinEHStatePass> {
 public:
   X86WinEHStatePass() = default;
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
@@ -253,7 +257,7 @@ FunctionPass *createX86WinEHStateLegacyPass();
 /// instructions into a sequence of actual instructions. This pass
 /// must run after prologue/epilogue insertion and before lowering
 /// the MachineInstr to MC.
-class X86ExpandPseudoPass : public PassInfoMixin<X86ExpandPseudoPass> {
+class X86ExpandPseudoPass : public OptionalPassInfoMixin<X86ExpandPseudoPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -262,7 +266,8 @@ class X86ExpandPseudoPass : public PassInfoMixin<X86ExpandPseudoPass> {
 FunctionPass *createX86ExpandPseudoLegacyPass();
 
 /// This pass converts X86 cmov instructions into branch when profitable.
-class X86CmovConversionPass : public PassInfoMixin<X86CmovConversionPass> {
+class X86CmovConversionPass
+    : public OptionalPassInfoMixin<X86CmovConversionPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -274,7 +279,7 @@ FunctionPass *createX86CmovConversionLegacyPass();
 /// certain byte and word instructions by equivalent 32 bit instructions,
 /// in order to eliminate partial register usage, false dependences on
 /// the upper portions of registers, and to save code size.
-class X86FixupBWInstsPass : public PassInfoMixin<X86FixupBWInstsPass> {
+class X86FixupBWInstsPass : public OptionalPassInfoMixin<X86FixupBWInstsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -285,7 +290,7 @@ FunctionPass *createX86FixupBWInstsLegacyPass();
 /// Return a Machine IR pass that reassigns instruction chains from one domain
 /// to another, when profitable.
 class X86DomainReassignmentPass
-    : public PassInfoMixin<X86DomainReassignmentPass> {
+    : public OptionalPassInfoMixin<X86DomainReassignmentPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -295,7 +300,7 @@ FunctionPass *createX86DomainReassignmentLegacyPass();
 
 /// This pass compress instructions from EVEX space to legacy/VEX/EVEX space when
 /// possible in order to reduce code size or facilitate HW decoding.
-class X86CompressEVEXPass : public PassInfoMixin<X86CompressEVEXPass> {
+class X86CompressEVEXPass : public OptionalPassInfoMixin<X86CompressEVEXPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -307,7 +312,7 @@ FunctionPass *createX86CompressEVEXLegacyPass();
 FunctionPass *createX86IndirectThunksPass();
 
 /// This pass replaces ret instructions with jmp's to __x86_return thunk.
-class X86ReturnThunksPass : public PassInfoMixin<X86ReturnThunksPass> {
+class X86ReturnThunksPass : public OptionalPassInfoMixin<X86ReturnThunksPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -317,7 +322,8 @@ FunctionPass *createX86ReturnThunksLegacyPass();
 
 /// This pass insert wait instruction after X87 instructions which could raise
 /// fp exceptions when strict-fp enabled.
-class X86InsertX87WaitPass : public PassInfoMixin<X86InsertX87WaitPass> {
+class X86InsertX87WaitPass
+    : public OptionalPassInfoMixin<X86InsertX87WaitPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
 };
@@ -327,7 +333,8 @@ FunctionPass *createX86InsertX87WaitLegacyPass();
 /// This pass optimizes arithmetic based on knowledge that is only used by
 /// a reduction sequence and is therefore safe to reassociate in interesting
 /// ways.
-class X86PartialReductionPass : public PassInfoMixin<X86PartialReductionPass> {
+class X86PartialReductionPass
+    : public OptionalPassInfoMixin<X86PartialReductionPass> {
 private:
   const X86TargetMachine *TM;
 
@@ -339,7 +346,8 @@ class X86PartialReductionPass : public PassInfoMixin<X86PartialReductionPass> {
 FunctionPass *createX86PartialReductionLegacyPass();
 
 /// // Analyzes and emits pseudos to support Win x64 Unwind V2.
-class X86WinEHUnwindV2Pass : public PassInfoMixin<X86WinEHUnwindV2Pass> {
+class X86WinEHUnwindV2Pass
+    : public OptionalPassInfoMixin<X86WinEHUnwindV2Pass> {
 public:
   X86WinEHUnwindV2Pass() = default;
   PreservedAnalyses run(MachineFunction &MF,
@@ -350,21 +358,20 @@ FunctionPass *createX86WinEHUnwindV2LegacyPass();
 
 /// The pass transforms load/store <256 x i32> to AMX load/store intrinsics
 /// or split the data to two <128 x i32>.
-class X86LowerAMXTypePass : public PassInfoMixin<X86LowerAMXTypePass> {
+class X86LowerAMXTypePass : public MandatoryPassInfoMixin<X86LowerAMXTypePass> {
 private:
   const TargetMachine *TM;
 
 public:
   X86LowerAMXTypePass(const TargetMachine *TM) : TM(TM) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
-  static bool isRequired() { return true; }
 };
 
 FunctionPass *createX86LowerAMXTypeLegacyPass();
 
 // Suppresses APX features for relocations for supporting older linkers.
 class X86SuppressAPXForRelocationPass
-    : public PassInfoMixin<X86SuppressAPXForRelocationPass> {
+    : public OptionalPassInfoMixin<X86SuppressAPXForRelocationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -375,14 +382,13 @@ FunctionPass *createX86SuppressAPXForRelocationLegacyPass();
 /// The pass transforms amx intrinsics to scalar operation if the function has
 /// optnone attribute or it is O0.
 class X86LowerAMXIntrinsicsPass
-    : public PassInfoMixin<X86LowerAMXIntrinsicsPass> {
+    : public MandatoryPassInfoMixin<X86LowerAMXIntrinsicsPass> {
 private:
   const TargetMachine *TM;
 
 public:
   X86LowerAMXIntrinsicsPass(const TargetMachine *TM) : TM(TM) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
-  static bool isRequired() { return true; }
 };
 
 FunctionPass *createX86LowerAMXIntrinsicsLegacyPass();
@@ -392,7 +398,7 @@ InstructionSelector *createX86InstructionSelector(const X86TargetMachine &TM,
                                                   const X86RegisterBankInfo &);
 
 class X86PostLegalizerCombinerPass
-    : public PassInfoMixin<X86PostLegalizerCombinerPass> {
+    : public OptionalPassInfoMixin<X86PostLegalizerCombinerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -402,7 +408,7 @@ FunctionPass *createX86PostLegalizerCombinerLegacy();
 FunctionPass *createX86PreLegalizerCombiner();
 
 class X86LoadValueInjectionLoadHardeningPass
-    : public PassInfoMixin<X86LoadValueInjectionLoadHardeningPass> {
+    : public OptionalPassInfoMixin<X86LoadValueInjectionLoadHardeningPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -411,7 +417,7 @@ class X86LoadValueInjectionLoadHardeningPass
 FunctionPass *createX86LoadValueInjectionLoadHardeningLegacyPass();
 
 class X86LoadValueInjectionRetHardeningPass
-    : public PassInfoMixin<X86LoadValueInjectionRetHardeningPass> {
+    : public OptionalPassInfoMixin<X86LoadValueInjectionRetHardeningPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -420,7 +426,8 @@ class X86LoadValueInjectionRetHardeningPass
 FunctionPass *createX86LoadValueInjectionRetHardeningLegacyPass();
 
 class X86SpeculativeExecutionSideEffectSuppressionPass
-    : public PassInfoMixin<X86SpeculativeExecutionSideEffectSuppressionPass> {
+    : public OptionalPassInfoMixin<
+          X86SpeculativeExecutionSideEffectSuppressionPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -429,7 +436,7 @@ class X86SpeculativeExecutionSideEffectSuppressionPass
 FunctionPass *createX86SpeculativeExecutionSideEffectSuppressionLegacyPass();
 
 class X86SpeculativeLoadHardeningPass
-    : public PassInfoMixin<X86SpeculativeLoadHardeningPass> {
+    : public OptionalPassInfoMixin<X86SpeculativeLoadHardeningPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -438,7 +445,7 @@ class X86SpeculativeLoadHardeningPass
 FunctionPass *createX86SpeculativeLoadHardeningLegacyPass();
 
 class X86ArgumentStackSlotPass
-    : public PassInfoMixin<X86ArgumentStackSlotPass> {
+    : public OptionalPassInfoMixin<X86ArgumentStackSlotPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.h b/llvm/lib/Target/X86/X86AsmPrinter.h
index 2717aff36a65c..a9228e2f45f3b 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.h
+++ b/llvm/lib/Target/X86/X86AsmPrinter.h
@@ -205,20 +205,21 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
   std::function<StaticDataProfileInfo *(Module &)> GetSDPI;
 };
 
-class X86AsmPrinterBeginPass : public PassInfoMixin<X86AsmPrinterBeginPass> {
+class X86AsmPrinterBeginPass
+    : public OptionalPassInfoMixin<X86AsmPrinterBeginPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
 
-class X86AsmPrinterPass : public PassInfoMixin<X86AsmPrinterPass> {
+class X86AsmPrinterPass : public MandatoryPassInfoMixin<X86AsmPrinterPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
   // AsmPrinter needs to run regardless of optimization level.
-  static bool isRequired() { return true; }
 };
 
-class X86AsmPrinterEndPass : public PassInfoMixin<X86AsmPrinterEndPass> {
+class X86AsmPrinterEndPass
+    : public OptionalPassInfoMixin<X86AsmPrinterEndPass> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/lib/Transforms/Utils/ProfileVerify.cpp b/llvm/lib/Transforms/Utils/ProfileVerify.cpp
index 63f83749e9636..e4863efc619be 100644
--- a/llvm/lib/Transforms/Utils/ProfileVerify.cpp
+++ b/llvm/lib/Transforms/Utils/ProfileVerify.cpp
@@ -221,7 +221,7 @@ PreservedAnalyses ProfileVerifierPass::run(Module &M,
   // expose the function-level run as public through a wrapper, so we can use
   // pass manager mechanisms dealing with declarations and with composing the
   // returned PreservedAnalyses values.
-  struct Wrapper : PassInfoMixin<Wrapper> {
+  struct Wrapper : OptionalPassInfoMixin<Wrapper> {
     ProfileVerifierPass &PVP;
     PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM) {
       return PVP.run(F, FAM);
diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
index bf5afe8e79354..a0c9b9320752a 100644
--- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -149,7 +149,7 @@ class TestImmutableFunctionAnalysis
 
 AnalysisKey TestImmutableFunctionAnalysis::Key;
 
-struct LambdaModulePass : public PassInfoMixin<LambdaModulePass> {
+struct LambdaModulePass : public OptionalPassInfoMixin<LambdaModulePass> {
   template <typename T>
   LambdaModulePass(T &&Arg) : Func(std::forward<T>(Arg)) {}
 
@@ -160,7 +160,7 @@ struct LambdaModulePass : public PassInfoMixin<LambdaModulePass> {
   std::function<PreservedAnalyses(Module &, ModuleAnalysisManager &)> Func;
 };
 
-struct LambdaSCCPass : public PassInfoMixin<LambdaSCCPass> {
+struct LambdaSCCPass : public OptionalPassInfoMixin<LambdaSCCPass> {
   template <typename T> LambdaSCCPass(T &&Arg) : Func(std::forward<T>(Arg)) {}
 
   PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
@@ -173,7 +173,7 @@ struct LambdaSCCPass : public PassInfoMixin<LambdaSCCPass> {
       Func;
 };
 
-struct LambdaFunctionPass : public PassInfoMixin<LambdaFunctionPass> {
+struct LambdaFunctionPass : public OptionalPassInfoMixin<LambdaFunctionPass> {
   template <typename T>
   LambdaFunctionPass(T &&Arg) : Func(std::forward<T>(Arg)) {}
 
@@ -1320,7 +1320,8 @@ TEST_F(CGSCCPassManagerTest, TestAnalysisInvalidationCGSCCUpdate) {
 // is not defined.
 #ifndef NDEBUG
 
-struct LambdaSCCPassNoPreserve : public PassInfoMixin<LambdaSCCPassNoPreserve> {
+struct LambdaSCCPassNoPreserve
+    : public OptionalPassInfoMixin<LambdaSCCPassNoPreserve> {
   template <typename T>
   LambdaSCCPassNoPreserve(T &&Arg) : Func(std::forward<T>(Arg)) {}
 
diff --git a/llvm/unittests/Analysis/LastRunTrackingAnalysisTest.cpp b/llvm/unittests/Analysis/LastRunTrackingAnalysisTest.cpp
index 13ca0bc161a0f..7ce66b3a7d064 100644
--- a/llvm/unittests/Analysis/LastRunTrackingAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/LastRunTrackingAnalysisTest.cpp
@@ -47,7 +47,7 @@ struct PassOption final {
   }
 };
 
-class ModuleNoopPass : public PassInfoMixin<ModuleNoopPass> {
+class ModuleNoopPass : public OptionalPassInfoMixin<ModuleNoopPass> {
   uint32_t &ExecutedBitMap;
   uint32_t RunID;
   void *PassID;
diff --git a/llvm/unittests/CodeGen/PassManagerTest.cpp b/llvm/unittests/CodeGen/PassManagerTest.cpp
index ce0211e1f83c1..dc83effd3c1e1 100644
--- a/llvm/unittests/CodeGen/PassManagerTest.cpp
+++ b/llvm/unittests/CodeGen/PassManagerTest.cpp
@@ -75,7 +75,8 @@ class TestMachineFunctionAnalysis
 
 AnalysisKey TestMachineFunctionAnalysis::Key;
 
-struct TestMachineFunctionPass : public PassInfoMixin<TestMachineFunctionPass> {
+struct TestMachineFunctionPass
+    : public OptionalPassInfoMixin<TestMachineFunctionPass> {
   TestMachineFunctionPass(int &Count, std::vector<int> &Counts)
       : Count(Count), Counts(Counts) {}
 
@@ -101,7 +102,8 @@ struct TestMachineFunctionPass : public PassInfoMixin<TestMachineFunctionPass> {
   std::vector<int> &Counts;
 };
 
-struct TestMachineModulePass : public PassInfoMixin<TestMachineModulePass> {
+struct TestMachineModulePass
+    : public OptionalPassInfoMixin<TestMachineModulePass> {
   TestMachineModulePass(int &Count, std::vector<int> &Counts)
       : Count(Count), Counts(Counts) {}
 
@@ -125,7 +127,7 @@ struct TestMachineModulePass : public PassInfoMixin<TestMachineModulePass> {
   std::vector<int> &Counts;
 };
 
-struct ReportWarningPass : public PassInfoMixin<ReportWarningPass> {
+struct ReportWarningPass : public OptionalPassInfoMixin<ReportWarningPass> {
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM) {
     auto &Ctx = MF.getContext();
diff --git a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
index 9aad6e3ca9125..586267f929b7e 100644
--- a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -121,7 +121,7 @@ template <typename DerivedT, typename IRUnitT,
           typename... ExtraArgTs>
 class MockPassHandleBase {
 public:
-  class Pass : public PassInfoMixin<Pass> {
+  class Pass : public OptionalPassInfoMixin<Pass> {
     friend MockPassHandleBase;
 
     DerivedT *Handle;
diff --git a/llvm/unittests/IR/PassManagerTest.cpp b/llvm/unittests/IR/PassManagerTest.cpp
index a6487169224c2..fd4e3c97cb48a 100644
--- a/llvm/unittests/IR/PassManagerTest.cpp
+++ b/llvm/unittests/IR/PassManagerTest.cpp
@@ -93,7 +93,7 @@ class TestModuleAnalysis : public AnalysisInfoMixin<TestModuleAnalysis> {
 
 AnalysisKey TestModuleAnalysis::Key;
 
-struct TestModulePass : PassInfoMixin<TestModulePass> {
+struct TestModulePass : OptionalPassInfoMixin<TestModulePass> {
   TestModulePass(int &RunCount) : RunCount(RunCount) {}
 
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &) {
@@ -104,13 +104,14 @@ struct TestModulePass : PassInfoMixin<TestModulePass> {
   int &RunCount;
 };
 
-struct TestPreservingModulePass : PassInfoMixin<TestPreservingModulePass> {
+struct TestPreservingModulePass
+    : OptionalPassInfoMixin<TestPreservingModulePass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &) {
     return PreservedAnalyses::all();
   }
 };
 
-struct TestFunctionPass : PassInfoMixin<TestFunctionPass> {
+struct TestFunctionPass : OptionalPassInfoMixin<TestFunctionPass> {
   TestFunctionPass(int &RunCount, int &AnalyzedInstrCount,
                    int &AnalyzedFunctionCount, ModuleAnalysisManager &MAM,
                    bool OnlyUseCachedResults = false)
@@ -154,7 +155,7 @@ struct TestFunctionPass : PassInfoMixin<TestFunctionPass> {
 // A test function pass that invalidates all function analyses for a function
 // with a specific name.
 struct TestInvalidationFunctionPass
-    : PassInfoMixin<TestInvalidationFunctionPass> {
+    : OptionalPassInfoMixin<TestInvalidationFunctionPass> {
   TestInvalidationFunctionPass(StringRef FunctionName) : Name(FunctionName) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) {
@@ -567,7 +568,7 @@ class CustomizedAnalysis : public AnalysisInfoMixin<CustomizedAnalysis> {
 
 AnalysisKey CustomizedAnalysis::Key;
 
-struct CustomizedPass : PassInfoMixin<CustomizedPass> {
+struct CustomizedPass : OptionalPassInfoMixin<CustomizedPass> {
   std::function<void(CustomizedAnalysis::Result &, int &)> Callback;
 
   template <typename CallbackT>
@@ -691,7 +692,7 @@ struct TestDoublyIndirectFunctionAnalysis
 
 AnalysisKey TestDoublyIndirectFunctionAnalysis::Key;
 
-struct LambdaPass : public PassInfoMixin<LambdaPass> {
+struct LambdaPass : public OptionalPassInfoMixin<LambdaPass> {
   using FuncT = std::function<PreservedAnalyses(Function &, FunctionAnalysisManager &)>;
 
   LambdaPass(FuncT Func) : Func(std::move(Func)) {}
@@ -843,7 +844,7 @@ TEST_F(PassManagerTest, FunctionPassCFGChecker) {
 // FunctionPass that manually invalidates analyses and always returns
 // PreservedAnalyses::all().
 struct TestSimplifyCFGInvalidatingAnalysisPass
-    : PassInfoMixin<TestSimplifyCFGInvalidatingAnalysisPass> {
+    : OptionalPassInfoMixin<TestSimplifyCFGInvalidatingAnalysisPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM) {
     // Run SimplifyCFG and if it changes CFG then invalidate the CFG analysis.
     // This allows to return PreserveAnalysis::all().
@@ -891,7 +892,8 @@ TEST_F(PassManagerTest, FunctionPassCFGCheckerInvalidateAnalysis) {
 
 // Wrap a FunctionPassManager running SimplifyCFG pass with another
 // FunctionPassManager.
-struct TestSimplifyCFGWrapperPass : PassInfoMixin<TestSimplifyCFGWrapperPass> {
+struct TestSimplifyCFGWrapperPass
+    : OptionalPassInfoMixin<TestSimplifyCFGWrapperPass> {
   TestSimplifyCFGWrapperPass(FunctionPassManager &InnerPM) : InnerPM(InnerPM) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM) {
@@ -962,7 +964,7 @@ TEST_F(PassManagerTest, FunctionPassCFGCheckerWrapped) {
 
 #ifdef EXPENSIVE_CHECKS
 
-struct WrongFunctionPass : PassInfoMixin<WrongFunctionPass> {
+struct WrongFunctionPass : OptionalPassInfoMixin<WrongFunctionPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM) {
     F.getEntryBlock().begin()->eraseFromParent();
     return PreservedAnalyses::all();
@@ -994,7 +996,7 @@ TEST_F(PassManagerTest, FunctionPassMissedFunctionAnalysisInvalidation) {
   EXPECT_DEATH(FPM.run(*F, FAM), "Function @foo changed by WrongFunctionPass without invalidating analyses");
 }
 
-struct WrongModulePass : PassInfoMixin<WrongModulePass> {
+struct WrongModulePass : OptionalPassInfoMixin<WrongModulePass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM) {
     for (Function &F : M)
       F.getEntryBlock().begin()->eraseFromParent();
@@ -1032,7 +1034,7 @@ TEST_F(PassManagerTest, ModulePassMissedFunctionAnalysisInvalidation) {
       "Function @foo changed by WrongModulePass without invalidating analyses");
 }
 
-struct WrongModulePass2 : PassInfoMixin<WrongModulePass2> {
+struct WrongModulePass2 : OptionalPassInfoMixin<WrongModulePass2> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM) {
     for (Function &F : M)
       F.getEntryBlock().begin()->eraseFromParent();
diff --git a/llvm/unittests/IR/TimePassesTest.cpp b/llvm/unittests/IR/TimePassesTest.cpp
index 85986132103ca..87330280c216a 100644
--- a/llvm/unittests/IR/TimePassesTest.cpp
+++ b/llvm/unittests/IR/TimePassesTest.cpp
@@ -115,8 +115,8 @@ TEST(TimePassesTest, LegacyCustomOut) {
   TimePassesIsEnabled = false;
 }
 
-class MyPass1 : public PassInfoMixin<MyPass1> {};
-class MyPass2 : public PassInfoMixin<MyPass2> {};
+class MyPass1 : public OptionalPassInfoMixin<MyPass1> {};
+class MyPass2 : public OptionalPassInfoMixin<MyPass2> {};
 
 TEST(TimePassesTest, CustomOut) {
   PassInstrumentationCallbacks PIC;
diff --git a/llvm/unittests/Passes/Plugins/DoublerPlugin/DoublerPlugin.cpp b/llvm/unittests/Passes/Plugins/DoublerPlugin/DoublerPlugin.cpp
index 23e66cf7192f8..4b53f9d1e1493 100644
--- a/llvm/unittests/Passes/Plugins/DoublerPlugin/DoublerPlugin.cpp
+++ b/llvm/unittests/Passes/Plugins/DoublerPlugin/DoublerPlugin.cpp
@@ -13,7 +13,7 @@
 
 using namespace llvm;
 
-struct DoublerModulePass : public PassInfoMixin<DoublerModulePass> {
+struct DoublerModulePass : public OptionalPassInfoMixin<DoublerModulePass> {
 
   // Double the value of the initializer
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM) {
diff --git a/llvm/unittests/Passes/Plugins/TestPlugin/TestPlugin.cpp b/llvm/unittests/Passes/Plugins/TestPlugin/TestPlugin.cpp
index 5a0bcdb10fb3c..1fc237cedae66 100644
--- a/llvm/unittests/Passes/Plugins/TestPlugin/TestPlugin.cpp
+++ b/llvm/unittests/Passes/Plugins/TestPlugin/TestPlugin.cpp
@@ -13,7 +13,7 @@
 
 using namespace llvm;
 
-struct TestModulePass : public PassInfoMixin<TestModulePass> {
+struct TestModulePass : public OptionalPassInfoMixin<TestModulePass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM) {
     return PreservedAnalyses::all();
   }
diff --git a/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp b/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
index 6e3e71e5abb45..8fd42accc3c40 100644
--- a/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ b/llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -153,7 +153,7 @@ template <typename DerivedT, typename IRUnitT,
           typename... ExtraArgTs>
 class MockPassHandleBase {
 public:
-  class Pass : public PassInfoMixin<Pass> {
+  class Pass : public OptionalPassInfoMixin<Pass> {
     friend MockPassHandleBase;
 
     DerivedT *Handle;
diff --git a/llvm/unittests/Transforms/Utils/MemTransferLowering.cpp b/llvm/unittests/Transforms/Utils/MemTransferLowering.cpp
index 752029e54f394..54208a1714bd0 100644
--- a/llvm/unittests/Transforms/Utils/MemTransferLowering.cpp
+++ b/llvm/unittests/Transforms/Utils/MemTransferLowering.cpp
@@ -30,7 +30,7 @@
 using namespace llvm;
 
 namespace {
-struct ForwardingPass : public PassInfoMixin<ForwardingPass> {
+struct ForwardingPass : public OptionalPassInfoMixin<ForwardingPass> {
   template <typename T> ForwardingPass(T &&Arg) : Func(std::forward<T>(Arg)) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM) {
diff --git a/polly/include/polly/Pass/PollyFunctionPass.h b/polly/include/polly/Pass/PollyFunctionPass.h
index dd0d4e77d7a80..8d1341d0ea3aa 100644
--- a/polly/include/polly/Pass/PollyFunctionPass.h
+++ b/polly/include/polly/Pass/PollyFunctionPass.h
@@ -16,7 +16,8 @@
 
 namespace polly {
 
-class PollyFunctionPass : public llvm::PassInfoMixin<PollyFunctionPass> {
+class PollyFunctionPass
+    : public llvm::OptionalPassInfoMixin<PollyFunctionPass> {
 public:
   PollyFunctionPass() {}
   PollyFunctionPass(PollyPassOptions Opts) : Opts(std::move(Opts)) {}
diff --git a/polly/include/polly/Pass/PollyModulePass.h b/polly/include/polly/Pass/PollyModulePass.h
index 2214bbf3d143e..683f50811521f 100644
--- a/polly/include/polly/Pass/PollyModulePass.h
+++ b/polly/include/polly/Pass/PollyModulePass.h
@@ -14,7 +14,7 @@
 
 namespace polly {
 
-class PollyModulePass : public llvm::PassInfoMixin<PollyModulePass> {
+class PollyModulePass : public llvm::OptionalPassInfoMixin<PollyModulePass> {
 public:
   PollyModulePass() {}
   PollyModulePass(PollyPassOptions Opts) : Opts(std::move(Opts)) {}
diff --git a/polly/include/polly/ScopDetection.h b/polly/include/polly/ScopDetection.h
index ee9b026a296f1..68f21c3c63d2d 100644
--- a/polly/include/polly/ScopDetection.h
+++ b/polly/include/polly/ScopDetection.h
@@ -69,9 +69,10 @@ using llvm::Function;
 using llvm::FunctionAnalysisManager;
 using llvm::IntrinsicInst;
 using llvm::LoopInfo;
+using llvm::MandatoryPassInfoMixin;
 using llvm::Module;
 using llvm::OptimizationRemarkEmitter;
-using llvm::PassInfoMixin;
+using llvm::OptionalPassInfoMixin;
 using llvm::PreservedAnalyses;
 using llvm::RegionInfo;
 using llvm::ScalarEvolution;
@@ -626,7 +627,8 @@ struct ScopAnalysis : AnalysisInfoMixin<ScopAnalysis> {
   Result run(Function &F, FunctionAnalysisManager &FAM);
 };
 
-struct ScopAnalysisPrinterPass final : PassInfoMixin<ScopAnalysisPrinterPass> {
+struct ScopAnalysisPrinterPass final
+    : MandatoryPassInfoMixin<ScopAnalysisPrinterPass> {
   ScopAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 602cc30417fe6..0a07ccc91be41 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -47,9 +47,10 @@ using llvm::isa;
 using llvm::iterator_range;
 using llvm::LoadInst;
 using llvm::make_range;
+using llvm::MandatoryPassInfoMixin;
 using llvm::MapVector;
 using llvm::MemIntrinsic;
-using llvm::PassInfoMixin;
+using llvm::OptionalPassInfoMixin;
 using llvm::PHINode;
 using llvm::RegionNode;
 using llvm::SetVector;
diff --git a/polly/include/polly/ScopInliner.h b/polly/include/polly/ScopInliner.h
index ae3437701182b..f5cf97833e6a5 100644
--- a/polly/include/polly/ScopInliner.h
+++ b/polly/include/polly/ScopInliner.h
@@ -21,7 +21,7 @@ class FileSystem;
 } // namespace llvm
 
 namespace polly {
-class ScopInlinerPass : public llvm::PassInfoMixin<ScopInlinerPass> {
+class ScopInlinerPass : public llvm::OptionalPassInfoMixin<ScopInlinerPass> {
   llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
 
 public:
diff --git a/polly/include/polly/Support/DumpFunctionPass.h b/polly/include/polly/Support/DumpFunctionPass.h
index af04912ed4fe2..d765a8e002e4e 100644
--- a/polly/include/polly/Support/DumpFunctionPass.h
+++ b/polly/include/polly/Support/DumpFunctionPass.h
@@ -19,7 +19,7 @@
 namespace polly {
 
 /// A pass that isolates a function into a new Module and writes it into a file.
-struct DumpFunctionPass final : llvm::PassInfoMixin<DumpFunctionPass> {
+struct DumpFunctionPass final : llvm::MandatoryPassInfoMixin<DumpFunctionPass> {
   std::string Suffix;
 
   DumpFunctionPass(std::string Suffix) : Suffix(std::move(Suffix)) {}
diff --git a/polly/include/polly/Support/DumpModulePass.h b/polly/include/polly/Support/DumpModulePass.h
index 6d393a174b19b..85b0913c29840 100644
--- a/polly/include/polly/Support/DumpModulePass.h
+++ b/polly/include/polly/Support/DumpModulePass.h
@@ -26,7 +26,7 @@ namespace polly {
 /// The intent of IsSuffix is to avoid the file being overwritten when
 /// processing multiple modules and/or with multiple dump passes in the
 /// pipeline.
-struct DumpModulePass final : llvm::PassInfoMixin<DumpModulePass> {
+struct DumpModulePass final : llvm::MandatoryPassInfoMixin<DumpModulePass> {
   std::string Filename;
   bool IsSuffix;
 

>From 2595715c7922ba806bfa9fef0059b78d316489be Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Mon, 4 May 2026 20:35:15 +0000
Subject: [PATCH 2/4] port new passes

---
 clang/lib/CodeGen/LinkInModulesPass.h                  |  3 +--
 llvm/include/llvm/CodeGen/KCFI.h                       |  3 +--
 llvm/include/llvm/CodeGen/MachineBlockHashInfo.h       |  3 +--
 llvm/include/llvm/CodeGen/MachineStripDebug.h          |  2 +-
 .../llvm/Transforms/Utils/StripConvergenceIntrinsics.h |  2 +-
 llvm/lib/Target/AArch64/AArch64.h                      | 10 +++++-----
 llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h         |  3 +--
 llvm/lib/Target/SPIRV/SPIRVLegalizeImplicitBinding.h   |  2 +-
 llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.h       |  2 +-
 llvm/lib/Target/SPIRV/SPIRVMergeRegionExitTargets.h    |  2 +-
 llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h          |  2 +-
 llvm/lib/Target/SPIRV/SPIRVPrepareGlobals.h            |  2 +-
 llvm/lib/Target/SPIRV/SPIRVRegularizer.h               |  2 +-
 llvm/lib/Target/X86/X86.h                              |  2 +-
 14 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/clang/lib/CodeGen/LinkInModulesPass.h b/clang/lib/CodeGen/LinkInModulesPass.h
index 3edbfd076e150..1429ecd89e407 100644
--- a/clang/lib/CodeGen/LinkInModulesPass.h
+++ b/clang/lib/CodeGen/LinkInModulesPass.h
@@ -26,14 +26,13 @@ class Pass;
 /// Create and return a pass that links in Moduels from a provided
 /// BackendConsumer to a given primary Module. Note that this pass is designed
 /// for use with the legacy pass manager.
-class LinkInModulesPass : public PassInfoMixin<LinkInModulesPass> {
+class LinkInModulesPass : public MandatoryPassInfoMixin<LinkInModulesPass> {
   clang::BackendConsumer *BC;
 
 public:
   LinkInModulesPass(clang::BackendConsumer *BC);
 
   PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/KCFI.h b/llvm/include/llvm/CodeGen/KCFI.h
index 0c11e7b8efe27..9981fdb22e1e7 100644
--- a/llvm/include/llvm/CodeGen/KCFI.h
+++ b/llvm/include/llvm/CodeGen/KCFI.h
@@ -19,11 +19,10 @@
 
 namespace llvm {
 
-class MachineKCFIPass : public PassInfoMixin<MachineKCFIPass> {
+class MachineKCFIPass : public MandatoryPassInfoMixin<MachineKCFIPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
index 1d8e276f414ea..dd24afd8cd444 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
@@ -118,14 +118,13 @@ class MachineBlockHashInfoAnalysis
 
 /// Printer pass for the \c MachineBlockHashInfoAnalysis results.
 class MachineBlockHashInfoPrinterPass
-    : public PassInfoMixin<MachineBlockHashInfoPrinterPass> {
+    : public MandatoryPassInfoMixin<MachineBlockHashInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit MachineBlockHashInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 /// Legacy MachineFunctionPass for MachineBlockHashInfo.
diff --git a/llvm/include/llvm/CodeGen/MachineStripDebug.h b/llvm/include/llvm/CodeGen/MachineStripDebug.h
index ab93aefdef7f4..c6873967d49a8 100644
--- a/llvm/include/llvm/CodeGen/MachineStripDebug.h
+++ b/llvm/include/llvm/CodeGen/MachineStripDebug.h
@@ -22,7 +22,7 @@
 namespace llvm {
 
 class StripDebugMachineModulePass
-    : public PassInfoMixin<StripDebugMachineModulePass> {
+    : public OptionalPassInfoMixin<StripDebugMachineModulePass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/StripConvergenceIntrinsics.h b/llvm/include/llvm/Transforms/Utils/StripConvergenceIntrinsics.h
index 96a24641e34d2..69f10bc8c8dbb 100644
--- a/llvm/include/llvm/Transforms/Utils/StripConvergenceIntrinsics.h
+++ b/llvm/include/llvm/Transforms/Utils/StripConvergenceIntrinsics.h
@@ -19,7 +19,7 @@
 namespace llvm {
 
 class StripConvergenceIntrinsicsPass
-    : public PassInfoMixin<StripConvergenceIntrinsicsPass> {
+    : public OptionalPassInfoMixin<StripConvergenceIntrinsicsPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
 };
diff --git a/llvm/lib/Target/AArch64/AArch64.h b/llvm/lib/Target/AArch64/AArch64.h
index deb8f83bf8761..cb64d2d2b968a 100644
--- a/llvm/lib/Target/AArch64/AArch64.h
+++ b/llvm/lib/Target/AArch64/AArch64.h
@@ -105,14 +105,14 @@ class AArch64PreLegalizerCombinerPass
 };
 
 class AArch64PostSelectOptimizePass
-    : public PassInfoMixin<AArch64PostSelectOptimizePass> {
+    : public OptionalPassInfoMixin<AArch64PostSelectOptimizePass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class AArch64PostLegalizerLoweringPass
-    : public PassInfoMixin<AArch64PostLegalizerLoweringPass> {
+    : public OptionalPassInfoMixin<AArch64PostLegalizerLoweringPass> {
   std::unique_ptr<AArch64PostLegalizerLoweringImplRuleConfig> RuleConfig;
 
 public:
@@ -181,7 +181,7 @@ void initializeSVEIntrinsicOptsPass(PassRegistry &);
 void initializeAArch64Arm64ECCallLoweringPass(PassRegistry &);
 
 class AArch64StackTaggingPreRAPass
-    : public PassInfoMixin<AArch64StackTaggingPreRAPass> {
+    : public OptionalPassInfoMixin<AArch64StackTaggingPreRAPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -216,7 +216,7 @@ class AArch64BranchTargetsPass
 };
 
 class AArch64RedundantCondBranchPass
-    : public PassInfoMixin<AArch64RedundantCondBranchPass> {
+    : public OptionalPassInfoMixin<AArch64RedundantCondBranchPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -303,7 +303,7 @@ class AArch64RedundantCopyEliminationPass
 };
 
 class AArch64ConditionalComparesPass
-    : public PassInfoMixin<AArch64ConditionalComparesPass> {
+    : public OptionalPassInfoMixin<AArch64ConditionalComparesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h b/llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h
index 90cbb08c93f47..8bf3c12c0e226 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h
@@ -364,14 +364,13 @@ class AMDGPUNextUseAnalysisPrinterLegacyPass : public MachineFunctionPass {
 };
 
 class AMDGPUNextUseAnalysisPrinterPass
-    : public PassInfoMixin<AMDGPUNextUseAnalysisPrinterPass> {
+    : public MandatoryPassInfoMixin<AMDGPUNextUseAnalysisPrinterPass> {
   raw_ostream &OS;
 
 public:
   explicit AMDGPUNextUseAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
-  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/lib/Target/SPIRV/SPIRVLegalizeImplicitBinding.h b/llvm/lib/Target/SPIRV/SPIRVLegalizeImplicitBinding.h
index 9c43690bae6d8..874a790054b1f 100644
--- a/llvm/lib/Target/SPIRV/SPIRVLegalizeImplicitBinding.h
+++ b/llvm/lib/Target/SPIRV/SPIRVLegalizeImplicitBinding.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class SPIRVLegalizeImplicitBinding
-    : public PassInfoMixin<SPIRVLegalizeImplicitBinding> {
+    : public OptionalPassInfoMixin<SPIRVLegalizeImplicitBinding> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.h b/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.h
index 438415cb3bc8f..cad6fb3760a81 100644
--- a/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.h
+++ b/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.h
@@ -16,7 +16,7 @@ namespace llvm {
 class SPIRVTargetMachine;
 
 class SPIRVLegalizePointerCast
-    : public PassInfoMixin<SPIRVLegalizePointerCast> {
+    : public OptionalPassInfoMixin<SPIRVLegalizePointerCast> {
   const SPIRVTargetMachine &TM;
 
 public:
diff --git a/llvm/lib/Target/SPIRV/SPIRVMergeRegionExitTargets.h b/llvm/lib/Target/SPIRV/SPIRVMergeRegionExitTargets.h
index c8a710cf82a6b..abff1a349522d 100644
--- a/llvm/lib/Target/SPIRV/SPIRVMergeRegionExitTargets.h
+++ b/llvm/lib/Target/SPIRV/SPIRVMergeRegionExitTargets.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class SPIRVMergeRegionExitTargets
-    : public PassInfoMixin<SPIRVMergeRegionExitTargets> {
+    : public OptionalPassInfoMixin<SPIRVMergeRegionExitTargets> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h b/llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h
index 5743ca0c75ee8..5056a2476de4b 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h
+++ b/llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h
@@ -15,7 +15,7 @@ namespace llvm {
 
 class SPIRVTargetMachine;
 
-class SPIRVPrepareFunctions : public PassInfoMixin<SPIRVPrepareFunctions> {
+class SPIRVPrepareFunctions : public OptionalPassInfoMixin<SPIRVPrepareFunctions> {
   const SPIRVTargetMachine &TM;
 
 public:
diff --git a/llvm/lib/Target/SPIRV/SPIRVPrepareGlobals.h b/llvm/lib/Target/SPIRV/SPIRVPrepareGlobals.h
index bad85163691b5..429a4c53b243a 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPrepareGlobals.h
+++ b/llvm/lib/Target/SPIRV/SPIRVPrepareGlobals.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class SPIRVPrepareGlobals : public PassInfoMixin<SPIRVPrepareGlobals> {
+class SPIRVPrepareGlobals : public OptionalPassInfoMixin<SPIRVPrepareGlobals> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/SPIRV/SPIRVRegularizer.h b/llvm/lib/Target/SPIRV/SPIRVRegularizer.h
index 6daa1d51a8344..9b86c2d4622ab 100644
--- a/llvm/lib/Target/SPIRV/SPIRVRegularizer.h
+++ b/llvm/lib/Target/SPIRV/SPIRVRegularizer.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class SPIRVRegularizer : public PassInfoMixin<SPIRVRegularizer> {
+class SPIRVRegularizer : public OptionalPassInfoMixin<SPIRVRegularizer> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h
index e6096ad7e6157..4e76809a15d71 100644
--- a/llvm/lib/Target/X86/X86.h
+++ b/llvm/lib/Target/X86/X86.h
@@ -70,7 +70,7 @@ FunctionPass *createX86FPStackifierLegacyPass();
 
 /// This pass inserts AVX vzeroupper instructions before each call to avoid
 /// transition penalty between functions encoded with AVX and SSE.
-class X86InsertVZeroUpperPass : public PassInfoMixin<X86InsertVZeroUpperPass> {
+class X86InsertVZeroUpperPass : public OptionalPassInfoMixin<X86InsertVZeroUpperPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);

>From 9ec6625bd36e9d5578f22bbdecaa6201625b3d55 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Mon, 4 May 2026 20:38:56 +0000
Subject: [PATCH 3/4] Mandatory -> Required

---
 .../LLVMPrintFunctionNames.cpp                     |  3 +--
 clang/lib/CodeGen/LinkInModulesPass.h              |  2 +-
 llvm/docs/WritingAnLLVMNewPMPass.rst               | 10 +++++-----
 llvm/include/llvm/Analysis/AliasSetTracker.h       |  2 +-
 llvm/include/llvm/Analysis/AssumptionCache.h       |  2 +-
 llvm/include/llvm/Analysis/BlockFrequencyInfo.h    |  2 +-
 llvm/include/llvm/Analysis/BranchProbabilityInfo.h |  2 +-
 llvm/include/llvm/Analysis/CFGPrinter.h            |  8 ++++----
 llvm/include/llvm/Analysis/CFGSCCPrinter.h         |  2 +-
 llvm/include/llvm/Analysis/CGSCCPassManager.h      |  6 +++---
 llvm/include/llvm/Analysis/CallGraph.h             |  4 ++--
 llvm/include/llvm/Analysis/CallPrinter.h           |  4 ++--
 llvm/include/llvm/Analysis/CostModel.h             |  2 +-
 llvm/include/llvm/Analysis/CtxProfAnalysis.h       |  2 +-
 llvm/include/llvm/Analysis/CycleAnalysis.h         |  4 ++--
 llvm/include/llvm/Analysis/DDG.h                   |  2 +-
 llvm/include/llvm/Analysis/DDGPrinter.h            |  2 +-
 llvm/include/llvm/Analysis/DXILMetadataAnalysis.h  |  2 +-
 llvm/include/llvm/Analysis/DXILResource.h          |  2 +-
 llvm/include/llvm/Analysis/Delinearization.h       |  2 +-
 llvm/include/llvm/Analysis/DemandedBits.h          |  2 +-
 llvm/include/llvm/Analysis/DependenceAnalysis.h    |  2 +-
 llvm/include/llvm/Analysis/DominanceFrontier.h     |  2 +-
 .../llvm/Analysis/FunctionPropertiesAnalysis.h     |  4 ++--
 llvm/include/llvm/Analysis/IR2Vec.h                |  4 ++--
 .../include/llvm/Analysis/IRSimilarityIdentifier.h |  2 +-
 llvm/include/llvm/Analysis/InlineAdvisor.h         |  2 +-
 llvm/include/llvm/Analysis/InlineCost.h            |  2 +-
 llvm/include/llvm/Analysis/InstCount.h             |  2 +-
 llvm/include/llvm/Analysis/KernelInfo.h            |  2 +-
 llvm/include/llvm/Analysis/LazyCallGraph.h         |  4 ++--
 llvm/include/llvm/Analysis/LazyValueInfo.h         |  2 +-
 llvm/include/llvm/Analysis/LoopCacheAnalysis.h     |  2 +-
 llvm/include/llvm/Analysis/LoopInfo.h              |  4 ++--
 llvm/include/llvm/Analysis/LoopNestAnalysis.h      |  2 +-
 llvm/include/llvm/Analysis/MemDerefPrinter.h       |  2 +-
 llvm/include/llvm/Analysis/MemorySSA.h             |  6 +++---
 .../include/llvm/Analysis/ModuleDebugInfoPrinter.h |  2 +-
 llvm/include/llvm/Analysis/MustExecute.h           |  4 ++--
 llvm/include/llvm/Analysis/PhiValues.h             |  2 +-
 llvm/include/llvm/Analysis/PostDominators.h        |  2 +-
 llvm/include/llvm/Analysis/ProfileSummaryInfo.h    |  2 +-
 llvm/include/llvm/Analysis/RegionInfo.h            |  4 ++--
 llvm/include/llvm/Analysis/ScalarEvolution.h       |  4 ++--
 llvm/include/llvm/Analysis/StackLifetime.h         |  2 +-
 llvm/include/llvm/Analysis/StackSafetyAnalysis.h   |  4 ++--
 llvm/include/llvm/Analysis/StructuralHash.h        |  2 +-
 llvm/include/llvm/Analysis/UniformityAnalysis.h    |  2 +-
 llvm/include/llvm/Bitcode/BitcodeWriterPass.h      |  2 +-
 llvm/include/llvm/CodeGen/BranchRelaxation.h       |  2 +-
 llvm/include/llvm/CodeGen/DetectDeadLanes.h        |  2 +-
 llvm/include/llvm/CodeGen/ExpandIRInsts.h          |  2 +-
 llvm/include/llvm/CodeGen/ExpandPostRAPseudos.h    |  2 +-
 llvm/include/llvm/CodeGen/FEntryInserter.h         |  2 +-
 llvm/include/llvm/CodeGen/FinalizeISel.h           |  2 +-
 llvm/include/llvm/CodeGen/InitUndef.h              |  2 +-
 llvm/include/llvm/CodeGen/KCFI.h                   |  2 +-
 llvm/include/llvm/CodeGen/LiveIntervals.h          |  2 +-
 llvm/include/llvm/CodeGen/LiveVariables.h          |  2 +-
 .../llvm/CodeGen/LocalStackSlotAllocation.h        |  2 +-
 llvm/include/llvm/CodeGen/MIRPrinter.h             |  4 ++--
 .../llvm/CodeGen/MachineBlockFrequencyInfo.h       |  2 +-
 llvm/include/llvm/CodeGen/MachineBlockHashInfo.h   |  2 +-
 llvm/include/llvm/CodeGen/MachineBlockPlacement.h  |  4 ++--
 llvm/include/llvm/CodeGen/MachineCycleAnalysis.h   |  2 +-
 llvm/include/llvm/CodeGen/MachineDominators.h      |  2 +-
 llvm/include/llvm/CodeGen/MachineLoopInfo.h        |  2 +-
 llvm/include/llvm/CodeGen/MachinePassManager.h     |  2 +-
 llvm/include/llvm/CodeGen/MachinePostDominators.h  |  2 +-
 llvm/include/llvm/CodeGen/MachineTraceMetrics.h    |  2 +-
 .../llvm/CodeGen/MachineUniformityAnalysis.h       |  2 +-
 llvm/include/llvm/CodeGen/MachineVerifier.h        |  2 +-
 llvm/include/llvm/CodeGen/PEI.h                    |  2 +-
 llvm/include/llvm/CodeGen/PHIElimination.h         |  2 +-
 llvm/include/llvm/CodeGen/PatchableFunction.h      |  2 +-
 llvm/include/llvm/CodeGen/PostRAHazardRecognizer.h |  2 +-
 llvm/include/llvm/CodeGen/ReachingDefAnalysis.h    |  2 +-
 llvm/include/llvm/CodeGen/RegAllocFast.h           |  2 +-
 llvm/include/llvm/CodeGen/RegAllocGreedyPass.h     |  2 +-
 llvm/include/llvm/CodeGen/RegisterUsageInfo.h      |  2 +-
 .../include/llvm/CodeGen/SanitizerBinaryMetadata.h |  2 +-
 llvm/include/llvm/CodeGen/SelectionDAGISel.h       |  2 +-
 llvm/include/llvm/CodeGen/SlotIndexes.h            |  2 +-
 .../llvm/CodeGen/StackFrameLayoutAnalysisPass.h    |  2 +-
 llvm/include/llvm/CodeGen/VirtRegMap.h             |  4 ++--
 llvm/include/llvm/CodeGen/XRayInstrumentation.h    |  2 +-
 llvm/include/llvm/IR/Dominators.h                  |  4 ++--
 llvm/include/llvm/IR/PassManager.h                 | 14 +++++++-------
 llvm/include/llvm/IR/PassManagerInternal.h         |  2 +-
 llvm/include/llvm/IR/SafepointIRVerifier.h         |  2 +-
 llvm/include/llvm/IR/Verifier.h                    |  2 +-
 llvm/include/llvm/IRPrinter/IRPrintingPasses.h     |  4 ++--
 .../llvm/Transforms/Coroutines/CoroCleanup.h       |  2 +-
 .../Transforms/Coroutines/CoroConditionalWrapper.h |  2 +-
 .../include/llvm/Transforms/Coroutines/CoroEarly.h |  2 +-
 .../include/llvm/Transforms/Coroutines/CoroElide.h |  2 +-
 .../include/llvm/Transforms/Coroutines/CoroSplit.h |  2 +-
 llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h |  6 +++---
 llvm/include/llvm/Transforms/IPO/AlwaysInliner.h   |  2 +-
 .../include/llvm/Transforms/IPO/EmbedBitcodePass.h |  2 +-
 llvm/include/llvm/Transforms/IPO/FatLTOCleanup.h   |  2 +-
 llvm/include/llvm/Transforms/IPO/LowerTypeTests.h  |  4 ++--
 .../llvm/Transforms/IPO/ThinLTOBitcodeWriter.h     |  2 +-
 .../Transforms/Instrumentation/AddressSanitizer.h  |  2 +-
 .../llvm/Transforms/Instrumentation/AllocToken.h   |  2 +-
 .../Transforms/Instrumentation/BoundsChecking.h    |  2 +-
 .../Transforms/Instrumentation/DataFlowSanitizer.h |  2 +-
 .../Instrumentation/HWAddressSanitizer.h           |  2 +-
 .../include/llvm/Transforms/Instrumentation/KCFI.h |  2 +-
 .../Instrumentation/LowerAllowCheckPass.h          |  2 +-
 .../Instrumentation/MemProfInstrumentation.h       |  4 ++--
 .../Transforms/Instrumentation/MemorySanitizer.h   |  3 +--
 .../Instrumentation/NumericalStabilitySanitizer.h  |  2 +-
 .../Transforms/Instrumentation/RealtimeSanitizer.h |  2 +-
 .../Instrumentation/SanitizerBinaryMetadata.h      |  2 +-
 .../Transforms/Instrumentation/SanitizerCoverage.h |  2 +-
 .../Transforms/Instrumentation/ThreadSanitizer.h   |  5 ++---
 .../Transforms/Instrumentation/TypeSanitizer.h     |  2 +-
 .../llvm/Transforms/Scalar/AnnotationRemarks.h     |  2 +-
 .../llvm/Transforms/Scalar/IVUsersPrinter.h        |  2 +-
 .../Transforms/Scalar/LoopAccessAnalysisPrinter.h  |  2 +-
 .../llvm/Transforms/Scalar/LoopPassManager.h       |  6 +++---
 .../llvm/Transforms/Scalar/LowerAtomicPass.h       |  2 +-
 .../llvm/Transforms/Scalar/LowerMatrixIntrinsics.h |  2 +-
 .../llvm/Transforms/Utils/AddDiscriminators.h      |  2 +-
 .../llvm/Transforms/Utils/EntryExitInstrumenter.h  |  2 +-
 .../llvm/Transforms/Utils/ExtraPassManager.h       |  4 ++--
 .../llvm/Transforms/Utils/NameAnonGlobals.h        |  2 +-
 llvm/include/llvm/Transforms/Utils/PredicateInfo.h |  4 ++--
 llvm/lib/Target/AMDGPU/AMDGPU.h                    |  8 ++++----
 llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h     |  2 +-
 llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h      |  2 +-
 llvm/lib/Target/BPF/BPF.h                          | 10 +++++-----
 llvm/lib/Target/DirectX/DXILFinalizeLinkage.h      |  2 +-
 llvm/lib/Target/X86/X86.h                          |  6 +++---
 llvm/lib/Target/X86/X86AsmPrinter.h                |  2 +-
 polly/include/polly/ScopDetection.h                |  4 ++--
 polly/include/polly/ScopInfo.h                     |  2 +-
 polly/include/polly/Support/DumpFunctionPass.h     |  2 +-
 polly/include/polly/Support/DumpModulePass.h       |  2 +-
 140 files changed, 192 insertions(+), 195 deletions(-)

diff --git a/clang/examples/LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp b/clang/examples/LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp
index 79a315d5a4ee2..fa9f698365e43 100644
--- a/clang/examples/LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp
+++ b/clang/examples/LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp
@@ -27,7 +27,7 @@ using namespace clang;
 
 namespace {
 
-class PrintPass final : public llvm::AnalysisInfoMixin<PrintPass> {
+class PrintPass final : public llvm::RequiredPassInfoMixin<PrintPass> {
   friend struct llvm::AnalysisInfoMixin<PrintPass>;
 
 public:
@@ -38,7 +38,6 @@ class PrintPass final : public llvm::AnalysisInfoMixin<PrintPass> {
       llvm::outs() << "[PrintPass] Found function: " << F.getName() << "\n";
     return llvm::PreservedAnalyses::all();
   }
-  static bool isRequired() { return true; }
 };
 
 void PrintCallback(llvm::PassBuilder &PB) {
diff --git a/clang/lib/CodeGen/LinkInModulesPass.h b/clang/lib/CodeGen/LinkInModulesPass.h
index 1429ecd89e407..f7c735d399181 100644
--- a/clang/lib/CodeGen/LinkInModulesPass.h
+++ b/clang/lib/CodeGen/LinkInModulesPass.h
@@ -26,7 +26,7 @@ class Pass;
 /// Create and return a pass that links in Moduels from a provided
 /// BackendConsumer to a given primary Module. Note that this pass is designed
 /// for use with the legacy pass manager.
-class LinkInModulesPass : public MandatoryPassInfoMixin<LinkInModulesPass> {
+class LinkInModulesPass : public RequiredPassInfoMixin<LinkInModulesPass> {
   clang::BackendConsumer *BC;
 
 public:
diff --git a/llvm/docs/WritingAnLLVMNewPMPass.rst b/llvm/docs/WritingAnLLVMNewPMPass.rst
index b3f5c2ecf98cc..dd094e393d7a3 100644
--- a/llvm/docs/WritingAnLLVMNewPMPass.rst
+++ b/llvm/docs/WritingAnLLVMNewPMPass.rst
@@ -26,7 +26,7 @@ defined via inheritance, passes under the new pass manager rely on
 concept-based polymorphism, meaning there is no explicit interface (see
 comments in ``PassManager.h`` for more details). All LLVM passes inherit from
 the CRTP mix-in ``OptionalPassInfoMixin<PassT>`` or
-``MandatoryPassInfoMixin<PassT>``. The pass should have a ``run()``
+``RequiredPassInfoMixin<PassT>``. The pass should have a ``run()``
 method which returns a ``PreservedAnalyses`` and takes in some unit of IR
 along with an analysis manager. For example, a function pass would have a
 ``PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);`` method.
@@ -94,9 +94,9 @@ contain the following boilerplate:
 
 This creates the class for the pass with a declaration of the ``run()``
 method which actually runs the pass. Inheriting from
-``OptionalPassInfoMixin<PassT>`` or ``MandatoryPassInfoMixin<PassT>`` sets up
+``OptionalPassInfoMixin<PassT>`` or ``RequiredPassInfoMixin<PassT>`` sets up
 some more boilerplate so that we don't have to write it ourselves.
-``MandatoryPassInfoMixin`` should be used for passes that cannot be skipped
+``RequiredPassInfoMixin`` should be used for passes that cannot be skipped
 (e.g. ``AlwaysInlinerPass``), while ``OptionalPassInfoMixin`` should be used
 for passes that can be skipped (e.g. optimization passes).
 
@@ -215,11 +215,11 @@ FAQs
 Required passes
 ---------------
 
-A pass that inherits from ``MandatoryPassInfoMixin<PassT>`` is a required pass. For example:
+A pass that inherits from ``RequiredPassInfoMixin<PassT>`` is a required pass. For example:
 
 .. code-block:: c++
 
-  class HelloWorldPass : public MandatoryPassInfoMixin<HelloWorldPass> {
+  class HelloWorldPass : public RequiredPassInfoMixin<HelloWorldPass> {
   public:
     PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
   };
diff --git a/llvm/include/llvm/Analysis/AliasSetTracker.h b/llvm/include/llvm/Analysis/AliasSetTracker.h
index 1e3b5006c2088..2f3418217e1b4 100644
--- a/llvm/include/llvm/Analysis/AliasSetTracker.h
+++ b/llvm/include/llvm/Analysis/AliasSetTracker.h
@@ -271,7 +271,7 @@ inline raw_ostream& operator<<(raw_ostream &OS, const AliasSetTracker &AST) {
 }
 
 class AliasSetsPrinterPass
-    : public MandatoryPassInfoMixin<AliasSetsPrinterPass> {
+    : public RequiredPassInfoMixin<AliasSetsPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/AssumptionCache.h b/llvm/include/llvm/Analysis/AssumptionCache.h
index 404ed715522eb..7141cb88f0c9b 100644
--- a/llvm/include/llvm/Analysis/AssumptionCache.h
+++ b/llvm/include/llvm/Analysis/AssumptionCache.h
@@ -190,7 +190,7 @@ class AssumptionAnalysis : public AnalysisInfoMixin<AssumptionAnalysis> {
 
 /// Printer pass for the \c AssumptionAnalysis results.
 class AssumptionPrinterPass
-    : public MandatoryPassInfoMixin<AssumptionPrinterPass> {
+    : public RequiredPassInfoMixin<AssumptionPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h
index a8a54bd0f9c5c..450810d360680 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h
@@ -132,7 +132,7 @@ class BlockFrequencyAnalysis
 
 /// Printer pass for the \c BlockFrequencyInfo results.
 class BlockFrequencyPrinterPass
-    : public MandatoryPassInfoMixin<BlockFrequencyPrinterPass> {
+    : public RequiredPassInfoMixin<BlockFrequencyPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
index 81bcecbc4e46f..e9e254c6c4af6 100644
--- a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
+++ b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
@@ -213,7 +213,7 @@ class BranchProbabilityAnalysis
 
 /// Printer pass for the \c BranchProbabilityAnalysis results.
 class BranchProbabilityPrinterPass
-    : public MandatoryPassInfoMixin<BranchProbabilityPrinterPass> {
+    : public RequiredPassInfoMixin<BranchProbabilityPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/CFGPrinter.h b/llvm/include/llvm/Analysis/CFGPrinter.h
index f31754e7764ab..2417327066eb3 100644
--- a/llvm/include/llvm/Analysis/CFGPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGPrinter.h
@@ -38,22 +38,22 @@ namespace llvm {
 class ModuleSlotTracker;
 
 template <class GraphType> struct GraphTraits;
-class CFGViewerPass : public MandatoryPassInfoMixin<CFGViewerPass> {
+class CFGViewerPass : public RequiredPassInfoMixin<CFGViewerPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-class CFGOnlyViewerPass : public MandatoryPassInfoMixin<CFGOnlyViewerPass> {
+class CFGOnlyViewerPass : public RequiredPassInfoMixin<CFGOnlyViewerPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-class CFGPrinterPass : public MandatoryPassInfoMixin<CFGPrinterPass> {
+class CFGPrinterPass : public RequiredPassInfoMixin<CFGPrinterPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-class CFGOnlyPrinterPass : public MandatoryPassInfoMixin<CFGOnlyPrinterPass> {
+class CFGOnlyPrinterPass : public RequiredPassInfoMixin<CFGOnlyPrinterPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Analysis/CFGSCCPrinter.h b/llvm/include/llvm/Analysis/CFGSCCPrinter.h
index 09232af70c372..116e2294af781 100644
--- a/llvm/include/llvm/Analysis/CFGSCCPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGSCCPrinter.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class CFGSCCPrinterPass : public MandatoryPassInfoMixin<CFGSCCPrinterPass> {
+class CFGSCCPrinterPass : public RequiredPassInfoMixin<CFGSCCPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/CGSCCPassManager.h b/llvm/include/llvm/Analysis/CGSCCPassManager.h
index 8965e992047f5..e85c1ef9a90d2 100644
--- a/llvm/include/llvm/Analysis/CGSCCPassManager.h
+++ b/llvm/include/llvm/Analysis/CGSCCPassManager.h
@@ -148,7 +148,7 @@ using CGSCCPassManager =
 template <typename AnalysisT>
 struct RequireAnalysisPass<AnalysisT, LazyCallGraph::SCC, CGSCCAnalysisManager,
                            LazyCallGraph &, CGSCCUpdateResult &>
-    : MandatoryPassInfoMixin<RequireAnalysisPass<
+    : RequiredPassInfoMixin<RequireAnalysisPass<
           AnalysisT, LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &,
           CGSCCUpdateResult &>> {
   PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
@@ -313,7 +313,7 @@ struct CGSCCUpdateResult {
 /// pass over the module to enable a \c FunctionAnalysisManager to be used
 /// within this run safely.
 class ModuleToPostOrderCGSCCPassAdaptor
-    : public MandatoryPassInfoMixin<ModuleToPostOrderCGSCCPassAdaptor> {
+    : public RequiredPassInfoMixin<ModuleToPostOrderCGSCCPassAdaptor> {
 public:
   using PassConceptT =
       detail::PassConcept<LazyCallGraph::SCC, CGSCCAnalysisManager,
@@ -443,7 +443,7 @@ LLVM_ABI LazyCallGraph::SCC &updateCGAndAnalysisManagerForCGSCCPass(
 /// pass over the SCC to enable a \c FunctionAnalysisManager to be used
 /// within this run safely.
 class CGSCCToFunctionPassAdaptor
-    : public MandatoryPassInfoMixin<CGSCCToFunctionPassAdaptor> {
+    : public RequiredPassInfoMixin<CGSCCToFunctionPassAdaptor> {
 public:
   using PassConceptT = detail::PassConcept<Function, FunctionAnalysisManager>;
 
diff --git a/llvm/include/llvm/Analysis/CallGraph.h b/llvm/include/llvm/Analysis/CallGraph.h
index 627765368b3b2..b92909a9e23b5 100644
--- a/llvm/include/llvm/Analysis/CallGraph.h
+++ b/llvm/include/llvm/Analysis/CallGraph.h
@@ -300,7 +300,7 @@ class CallGraphAnalysis : public AnalysisInfoMixin<CallGraphAnalysis> {
 
 /// Printer pass for the \c CallGraphAnalysis results.
 class CallGraphPrinterPass
-    : public MandatoryPassInfoMixin<CallGraphPrinterPass> {
+    : public RequiredPassInfoMixin<CallGraphPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -311,7 +311,7 @@ class CallGraphPrinterPass
 
 /// Printer pass for the summarized \c CallGraphAnalysis results.
 class CallGraphSCCsPrinterPass
-    : public MandatoryPassInfoMixin<CallGraphSCCsPrinterPass> {
+    : public RequiredPassInfoMixin<CallGraphSCCsPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/CallPrinter.h b/llvm/include/llvm/Analysis/CallPrinter.h
index d374995e886e0..c93d1e10d4d34 100644
--- a/llvm/include/llvm/Analysis/CallPrinter.h
+++ b/llvm/include/llvm/Analysis/CallPrinter.h
@@ -23,13 +23,13 @@ class ModulePass;
 
 /// Pass for printing the call graph to a dot file
 class CallGraphDOTPrinterPass
-    : public MandatoryPassInfoMixin<CallGraphDOTPrinterPass> {
+    : public RequiredPassInfoMixin<CallGraphDOTPrinterPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
 /// Pass for viewing the call graph
-class CallGraphViewerPass : public MandatoryPassInfoMixin<CallGraphViewerPass> {
+class CallGraphViewerPass : public RequiredPassInfoMixin<CallGraphViewerPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Analysis/CostModel.h b/llvm/include/llvm/Analysis/CostModel.h
index 9a095bedb8d60..10c575bff2493 100644
--- a/llvm/include/llvm/Analysis/CostModel.h
+++ b/llvm/include/llvm/Analysis/CostModel.h
@@ -14,7 +14,7 @@
 namespace llvm {
 /// Printer pass for cost modeling results.
 class CostModelPrinterPass
-    : public MandatoryPassInfoMixin<CostModelPrinterPass> {
+    : public RequiredPassInfoMixin<CostModelPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/CtxProfAnalysis.h b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
index d116cab6448cd..8260b95026ad2 100644
--- a/llvm/include/llvm/Analysis/CtxProfAnalysis.h
+++ b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
@@ -147,7 +147,7 @@ class CtxProfAnalysis : public AnalysisInfoMixin<CtxProfAnalysis> {
 };
 
 class CtxProfAnalysisPrinterPass
-    : public MandatoryPassInfoMixin<CtxProfAnalysisPrinterPass> {
+    : public RequiredPassInfoMixin<CtxProfAnalysisPrinterPass> {
 public:
   enum class PrintMode { Everything, YAML };
   LLVM_ABI explicit CtxProfAnalysisPrinterPass(raw_ostream &OS);
diff --git a/llvm/include/llvm/Analysis/CycleAnalysis.h b/llvm/include/llvm/Analysis/CycleAnalysis.h
index 2efc409c6360d..10103123c528d 100644
--- a/llvm/include/llvm/Analysis/CycleAnalysis.h
+++ b/llvm/include/llvm/Analysis/CycleAnalysis.h
@@ -63,7 +63,7 @@ class CycleAnalysis : public AnalysisInfoMixin<CycleAnalysis> {
 };
 
 class CycleInfoPrinterPass
-    : public MandatoryPassInfoMixin<CycleInfoPrinterPass> {
+    : public RequiredPassInfoMixin<CycleInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -72,7 +72,7 @@ class CycleInfoPrinterPass
 };
 
 struct CycleInfoVerifierPass
-    : public MandatoryPassInfoMixin<CycleInfoVerifierPass> {
+    : public RequiredPassInfoMixin<CycleInfoVerifierPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Analysis/DDG.h b/llvm/include/llvm/Analysis/DDG.h
index 656e48e6dd9c7..20c98d4e62833 100644
--- a/llvm/include/llvm/Analysis/DDG.h
+++ b/llvm/include/llvm/Analysis/DDG.h
@@ -422,7 +422,7 @@ class DDGAnalysis : public AnalysisInfoMixin<DDGAnalysis> {
 
 /// Textual printer pass for the DDG of a loop.
 class DDGAnalysisPrinterPass
-    : public MandatoryPassInfoMixin<DDGAnalysisPrinterPass> {
+    : public RequiredPassInfoMixin<DDGAnalysisPrinterPass> {
 public:
   explicit DDGAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
   LLVM_ABI PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
diff --git a/llvm/include/llvm/Analysis/DDGPrinter.h b/llvm/include/llvm/Analysis/DDGPrinter.h
index 23b2a6aaaa5c7..55c2e6d972c5a 100644
--- a/llvm/include/llvm/Analysis/DDGPrinter.h
+++ b/llvm/include/llvm/Analysis/DDGPrinter.h
@@ -25,7 +25,7 @@ class Loop;
 //===--------------------------------------------------------------------===//
 // Implementation of DDG DOT Printer for a loop.
 //===--------------------------------------------------------------------===//
-class DDGDotPrinterPass : public MandatoryPassInfoMixin<DDGDotPrinterPass> {
+class DDGDotPrinterPass : public RequiredPassInfoMixin<DDGDotPrinterPass> {
 public:
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
diff --git a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
index 01f1316e6cde5..3e1cb05eddc41 100644
--- a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
+++ b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
@@ -59,7 +59,7 @@ class DXILMetadataAnalysis : public AnalysisInfoMixin<DXILMetadataAnalysis> {
 
 /// Printer pass for the \c DXILMetadataAnalysis results.
 class DXILMetadataAnalysisPrinterPass
-    : public MandatoryPassInfoMixin<DXILMetadataAnalysisPrinterPass> {
+    : public RequiredPassInfoMixin<DXILMetadataAnalysisPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index 1553400e5a7b1..0a637d1a4bcc3 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -623,7 +623,7 @@ class DXILResourceAnalysis : public AnalysisInfoMixin<DXILResourceAnalysis> {
 
 /// Printer pass for the \c DXILResourceAnalysis results.
 class DXILResourcePrinterPass
-    : public MandatoryPassInfoMixin<DXILResourcePrinterPass> {
+    : public RequiredPassInfoMixin<DXILResourcePrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/Delinearization.h b/llvm/include/llvm/Analysis/Delinearization.h
index f83fba4b21723..85c311d448fea 100644
--- a/llvm/include/llvm/Analysis/Delinearization.h
+++ b/llvm/include/llvm/Analysis/Delinearization.h
@@ -161,7 +161,7 @@ bool getIndexExpressionsFromGEP(ScalarEvolution &SE,
                                 SmallVectorImpl<const SCEV *> &Sizes);
 
 struct DelinearizationPrinterPass
-    : public MandatoryPassInfoMixin<DelinearizationPrinterPass> {
+    : public RequiredPassInfoMixin<DelinearizationPrinterPass> {
   explicit DelinearizationPrinterPass(raw_ostream &OS);
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
diff --git a/llvm/include/llvm/Analysis/DemandedBits.h b/llvm/include/llvm/Analysis/DemandedBits.h
index d4629a0019b6b..21e5514559130 100644
--- a/llvm/include/llvm/Analysis/DemandedBits.h
+++ b/llvm/include/llvm/Analysis/DemandedBits.h
@@ -117,7 +117,7 @@ class DemandedBitsAnalysis : public AnalysisInfoMixin<DemandedBitsAnalysis> {
 
 /// Printer pass for DemandedBits
 class DemandedBitsPrinterPass
-    : public MandatoryPassInfoMixin<DemandedBitsPrinterPass> {
+    : public RequiredPassInfoMixin<DemandedBitsPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/DependenceAnalysis.h b/llvm/include/llvm/Analysis/DependenceAnalysis.h
index 8c11728f14f1f..4a58b3dac8882 100644
--- a/llvm/include/llvm/Analysis/DependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/DependenceAnalysis.h
@@ -727,7 +727,7 @@ class DependenceAnalysis : public AnalysisInfoMixin<DependenceAnalysis> {
 
 /// Printer pass to dump DA results.
 struct DependenceAnalysisPrinterPass
-    : public MandatoryPassInfoMixin<DependenceAnalysisPrinterPass> {
+    : public RequiredPassInfoMixin<DependenceAnalysisPrinterPass> {
   DependenceAnalysisPrinterPass(raw_ostream &OS, bool NormalizeResults = false)
       : OS(OS), NormalizeResults(NormalizeResults) {}
 
diff --git a/llvm/include/llvm/Analysis/DominanceFrontier.h b/llvm/include/llvm/Analysis/DominanceFrontier.h
index 43ee353cb5e23..7cf91c5e6cfcb 100644
--- a/llvm/include/llvm/Analysis/DominanceFrontier.h
+++ b/llvm/include/llvm/Analysis/DominanceFrontier.h
@@ -146,7 +146,7 @@ class DominanceFrontierAnalysis
 
 /// Printer pass for the \c DominanceFrontier.
 class DominanceFrontierPrinterPass
-    : public MandatoryPassInfoMixin<DominanceFrontierPrinterPass> {
+    : public RequiredPassInfoMixin<DominanceFrontierPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index 0b2e567b306b0..ff0c51cf945eb 100644
--- a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -173,7 +173,7 @@ class FunctionPropertiesAnalysis
 
 /// Printer pass for the FunctionPropertiesAnalysis results.
 class FunctionPropertiesPrinterPass
-    : public MandatoryPassInfoMixin<FunctionPropertiesPrinterPass> {
+    : public RequiredPassInfoMixin<FunctionPropertiesPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -184,7 +184,7 @@ class FunctionPropertiesPrinterPass
 
 /// Statistics pass for the FunctionPropertiesAnalysis results.
 class FunctionPropertiesStatisticsPass
-    : public MandatoryPassInfoMixin<FunctionPropertiesStatisticsPass> {
+    : public RequiredPassInfoMixin<FunctionPropertiesStatisticsPass> {
 public:
   explicit FunctionPropertiesStatisticsPass() {}
 
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h
index adf98c8db77ee..d95dd9359bd2e 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -652,7 +652,7 @@ class IR2VecVocabAnalysis : public AnalysisInfoMixin<IR2VecVocabAnalysis> {
 
 /// This pass prints the IR2Vec embeddings for instructions, basic blocks, and
 /// functions.
-class IR2VecPrinterPass : public MandatoryPassInfoMixin<IR2VecPrinterPass> {
+class IR2VecPrinterPass : public RequiredPassInfoMixin<IR2VecPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -662,7 +662,7 @@ class IR2VecPrinterPass : public MandatoryPassInfoMixin<IR2VecPrinterPass> {
 
 /// This pass prints the embeddings in the vocabulary
 class IR2VecVocabPrinterPass
-    : public MandatoryPassInfoMixin<IR2VecVocabPrinterPass> {
+    : public RequiredPassInfoMixin<IR2VecVocabPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index dd38951ff4170..4e0f23f9cc8fb 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -1195,7 +1195,7 @@ class IRSimilarityAnalysis : public AnalysisInfoMixin<IRSimilarityAnalysis> {
 
 /// Printer pass that uses \c IRSimilarityAnalysis.
 class IRSimilarityAnalysisPrinterPass
-    : public MandatoryPassInfoMixin<IRSimilarityAnalysisPrinterPass> {
+    : public RequiredPassInfoMixin<IRSimilarityAnalysisPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h b/llvm/include/llvm/Analysis/InlineAdvisor.h
index 3e5f4f7f21664..0b48da60431f1 100644
--- a/llvm/include/llvm/Analysis/InlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/InlineAdvisor.h
@@ -339,7 +339,7 @@ class InlineAdvisorAnalysis : public AnalysisInfoMixin<InlineAdvisorAnalysis> {
 
 /// Printer pass for the InlineAdvisorAnalysis results.
 class InlineAdvisorAnalysisPrinterPass
-    : public MandatoryPassInfoMixin<InlineAdvisorAnalysisPrinterPass> {
+    : public RequiredPassInfoMixin<InlineAdvisorAnalysisPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/InlineCost.h b/llvm/include/llvm/Analysis/InlineCost.h
index 78d4fa39b6fbe..9b7c2b6ca96a1 100644
--- a/llvm/include/llvm/Analysis/InlineCost.h
+++ b/llvm/include/llvm/Analysis/InlineCost.h
@@ -351,7 +351,7 @@ LLVM_ABI InlineResult isInlineViable(Function &Callee);
 // debugging and analysis. The main purpose of the pass is to see and test
 // inliner's decisions when creating new optimizations to InlineCost.
 struct InlineCostAnnotationPrinterPass
-    : MandatoryPassInfoMixin<InlineCostAnnotationPrinterPass> {
+    : RequiredPassInfoMixin<InlineCostAnnotationPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/InstCount.h b/llvm/include/llvm/Analysis/InstCount.h
index 3aff8055823ca..2ca9a4154f7a9 100644
--- a/llvm/include/llvm/Analysis/InstCount.h
+++ b/llvm/include/llvm/Analysis/InstCount.h
@@ -19,7 +19,7 @@ namespace llvm {
 
 class Function;
 
-class InstCountPass : public MandatoryPassInfoMixin<InstCountPass> {
+class InstCountPass : public RequiredPassInfoMixin<InstCountPass> {
 public:
   explicit InstCountPass() {}
 
diff --git a/llvm/include/llvm/Analysis/KernelInfo.h b/llvm/include/llvm/Analysis/KernelInfo.h
index dac249ea28a07..eccf5a1cffd99 100644
--- a/llvm/include/llvm/Analysis/KernelInfo.h
+++ b/llvm/include/llvm/Analysis/KernelInfo.h
@@ -21,7 +21,7 @@ namespace llvm {
 
 class TargetMachine;
 
-class KernelInfoPrinter : public MandatoryPassInfoMixin<KernelInfoPrinter> {
+class KernelInfoPrinter : public RequiredPassInfoMixin<KernelInfoPrinter> {
   TargetMachine *TM;
 
 public:
diff --git a/llvm/include/llvm/Analysis/LazyCallGraph.h b/llvm/include/llvm/Analysis/LazyCallGraph.h
index 7812291f92238..24128a6946ecf 100644
--- a/llvm/include/llvm/Analysis/LazyCallGraph.h
+++ b/llvm/include/llvm/Analysis/LazyCallGraph.h
@@ -1283,7 +1283,7 @@ class LazyCallGraphAnalysis : public AnalysisInfoMixin<LazyCallGraphAnalysis> {
 ///
 /// This is primarily useful for testing the analysis.
 class LazyCallGraphPrinterPass
-    : public MandatoryPassInfoMixin<LazyCallGraphPrinterPass> {
+    : public RequiredPassInfoMixin<LazyCallGraphPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -1296,7 +1296,7 @@ class LazyCallGraphPrinterPass
 ///
 /// This is primarily useful for visualization purposes.
 class LazyCallGraphDOTPrinterPass
-    : public MandatoryPassInfoMixin<LazyCallGraphDOTPrinterPass> {
+    : public RequiredPassInfoMixin<LazyCallGraphDOTPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/LazyValueInfo.h b/llvm/include/llvm/Analysis/LazyValueInfo.h
index a24a90a5d2305..250aebd644734 100644
--- a/llvm/include/llvm/Analysis/LazyValueInfo.h
+++ b/llvm/include/llvm/Analysis/LazyValueInfo.h
@@ -147,7 +147,7 @@ class LazyValueAnalysis : public AnalysisInfoMixin<LazyValueAnalysis> {
 
 /// Printer pass for the LazyValueAnalysis results.
 class LazyValueInfoPrinterPass
-    : public MandatoryPassInfoMixin<LazyValueInfoPrinterPass> {
+    : public RequiredPassInfoMixin<LazyValueInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
index a695caedbce79..12e2f7a2ea05c 100644
--- a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
@@ -279,7 +279,7 @@ raw_ostream &operator<<(raw_ostream &OS, const CacheCost &CC);
 
 /// Printer pass for the \c CacheCost results.
 class LoopCachePrinterPass
-    : public MandatoryPassInfoMixin<LoopCachePrinterPass> {
+    : public RequiredPassInfoMixin<LoopCachePrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h
index 1879814d299cd..070f6faeda3b3 100644
--- a/llvm/include/llvm/Analysis/LoopInfo.h
+++ b/llvm/include/llvm/Analysis/LoopInfo.h
@@ -597,7 +597,7 @@ class LoopAnalysis : public AnalysisInfoMixin<LoopAnalysis> {
 };
 
 /// Printer pass for the \c LoopAnalysis results.
-class LoopPrinterPass : public MandatoryPassInfoMixin<LoopPrinterPass> {
+class LoopPrinterPass : public RequiredPassInfoMixin<LoopPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -606,7 +606,7 @@ class LoopPrinterPass : public MandatoryPassInfoMixin<LoopPrinterPass> {
 };
 
 /// Verifier pass for the \c LoopAnalysis results.
-struct LoopVerifierPass : public MandatoryPassInfoMixin<LoopVerifierPass> {
+struct LoopVerifierPass : public RequiredPassInfoMixin<LoopVerifierPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Analysis/LoopNestAnalysis.h b/llvm/include/llvm/Analysis/LoopNestAnalysis.h
index 959b86e3fe0c9..ac9ffb96ab5f8 100644
--- a/llvm/include/llvm/Analysis/LoopNestAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopNestAnalysis.h
@@ -211,7 +211,7 @@ class LoopNestAnalysis : public AnalysisInfoMixin<LoopNestAnalysis> {
 };
 
 /// Printer pass for the \c LoopNest results.
-class LoopNestPrinterPass : public MandatoryPassInfoMixin<LoopNestPrinterPass> {
+class LoopNestPrinterPass : public RequiredPassInfoMixin<LoopNestPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/MemDerefPrinter.h b/llvm/include/llvm/Analysis/MemDerefPrinter.h
index c17bd56241a14..c14c974d399cf 100644
--- a/llvm/include/llvm/Analysis/MemDerefPrinter.h
+++ b/llvm/include/llvm/Analysis/MemDerefPrinter.h
@@ -12,7 +12,7 @@
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {
-class MemDerefPrinterPass : public MandatoryPassInfoMixin<MemDerefPrinterPass> {
+class MemDerefPrinterPass : public RequiredPassInfoMixin<MemDerefPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/MemorySSA.h b/llvm/include/llvm/Analysis/MemorySSA.h
index 38b8dd391852b..5b4c65f100c89 100644
--- a/llvm/include/llvm/Analysis/MemorySSA.h
+++ b/llvm/include/llvm/Analysis/MemorySSA.h
@@ -944,7 +944,7 @@ class MemorySSAAnalysis : public AnalysisInfoMixin<MemorySSAAnalysis> {
 
 /// Printer pass for \c MemorySSA.
 class MemorySSAPrinterPass
-    : public MandatoryPassInfoMixin<MemorySSAPrinterPass> {
+    : public RequiredPassInfoMixin<MemorySSAPrinterPass> {
   raw_ostream &OS;
   bool EnsureOptimizedUses;
 
@@ -957,7 +957,7 @@ class MemorySSAPrinterPass
 
 /// Printer pass for \c MemorySSA via the walker.
 class MemorySSAWalkerPrinterPass
-    : public MandatoryPassInfoMixin<MemorySSAWalkerPrinterPass> {
+    : public RequiredPassInfoMixin<MemorySSAWalkerPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -967,7 +967,7 @@ class MemorySSAWalkerPrinterPass
 };
 
 /// Verifier pass for \c MemorySSA.
-struct MemorySSAVerifierPass : MandatoryPassInfoMixin<MemorySSAVerifierPass> {
+struct MemorySSAVerifierPass : RequiredPassInfoMixin<MemorySSAVerifierPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Analysis/ModuleDebugInfoPrinter.h b/llvm/include/llvm/Analysis/ModuleDebugInfoPrinter.h
index 48d64c1b2ca90..069071497d5a0 100644
--- a/llvm/include/llvm/Analysis/ModuleDebugInfoPrinter.h
+++ b/llvm/include/llvm/Analysis/ModuleDebugInfoPrinter.h
@@ -16,7 +16,7 @@ namespace llvm {
 class raw_ostream;
 
 class ModuleDebugInfoPrinterPass
-    : public MandatoryPassInfoMixin<ModuleDebugInfoPrinterPass> {
+    : public RequiredPassInfoMixin<ModuleDebugInfoPrinterPass> {
   DebugInfoFinder Finder;
   raw_ostream &OS;
 
diff --git a/llvm/include/llvm/Analysis/MustExecute.h b/llvm/include/llvm/Analysis/MustExecute.h
index 2b31cca54d54e..c5af3b72c8d05 100644
--- a/llvm/include/llvm/Analysis/MustExecute.h
+++ b/llvm/include/llvm/Analysis/MustExecute.h
@@ -544,7 +544,7 @@ struct MustBeExecutedContextExplorer {
 };
 
 class MustExecutePrinterPass
-    : public MandatoryPassInfoMixin<MustExecutePrinterPass> {
+    : public RequiredPassInfoMixin<MustExecutePrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -553,7 +553,7 @@ class MustExecutePrinterPass
 };
 
 class MustBeExecutedContextPrinterPass
-    : public MandatoryPassInfoMixin<MustBeExecutedContextPrinterPass> {
+    : public RequiredPassInfoMixin<MustBeExecutedContextPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/PhiValues.h b/llvm/include/llvm/Analysis/PhiValues.h
index 25347d3c77770..2a7fd196a6af2 100644
--- a/llvm/include/llvm/Analysis/PhiValues.h
+++ b/llvm/include/llvm/Analysis/PhiValues.h
@@ -128,7 +128,7 @@ class PhiValuesAnalysis : public AnalysisInfoMixin<PhiValuesAnalysis> {
 /// but instead first uses the PhiValues to analyze all the phis in the function
 /// so the complete information is printed.
 class PhiValuesPrinterPass
-    : public MandatoryPassInfoMixin<PhiValuesPrinterPass> {
+    : public RequiredPassInfoMixin<PhiValuesPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/PostDominators.h b/llvm/include/llvm/Analysis/PostDominators.h
index d058f052264a1..b7796fa75de31 100644
--- a/llvm/include/llvm/Analysis/PostDominators.h
+++ b/llvm/include/llvm/Analysis/PostDominators.h
@@ -62,7 +62,7 @@ class PostDominatorTreeAnalysis
 
 /// Printer pass for the \c PostDominatorTree.
 class PostDominatorTreePrinterPass
-    : public MandatoryPassInfoMixin<PostDominatorTreePrinterPass> {
+    : public RequiredPassInfoMixin<PostDominatorTreePrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
index 2e86aa5482693..02c412729081a 100644
--- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
+++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
@@ -387,7 +387,7 @@ class ProfileSummaryAnalysis
 
 /// Printer pass that uses \c ProfileSummaryAnalysis.
 class ProfileSummaryPrinterPass
-    : public MandatoryPassInfoMixin<ProfileSummaryPrinterPass> {
+    : public RequiredPassInfoMixin<ProfileSummaryPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/RegionInfo.h b/llvm/include/llvm/Analysis/RegionInfo.h
index 318e48f862f9b..77bbc897ab744 100644
--- a/llvm/include/llvm/Analysis/RegionInfo.h
+++ b/llvm/include/llvm/Analysis/RegionInfo.h
@@ -975,7 +975,7 @@ class RegionInfoAnalysis : public AnalysisInfoMixin<RegionInfoAnalysis> {
 
 /// Printer pass for the \c RegionInfo.
 class RegionInfoPrinterPass
-    : public MandatoryPassInfoMixin<RegionInfoPrinterPass> {
+    : public RequiredPassInfoMixin<RegionInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -985,7 +985,7 @@ class RegionInfoPrinterPass
 };
 
 /// Verifier pass for the \c RegionInfo.
-struct RegionInfoVerifierPass : MandatoryPassInfoMixin<RegionInfoVerifierPass> {
+struct RegionInfoVerifierPass : RequiredPassInfoMixin<RegionInfoVerifierPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 4cffe49f79504..79f16b318efcf 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -2547,14 +2547,14 @@ class ScalarEvolutionAnalysis
 
 /// Verifier pass for the \c ScalarEvolutionAnalysis results.
 class ScalarEvolutionVerifierPass
-    : public MandatoryPassInfoMixin<ScalarEvolutionVerifierPass> {
+    : public RequiredPassInfoMixin<ScalarEvolutionVerifierPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 /// Printer pass for the \c ScalarEvolutionAnalysis results.
 class ScalarEvolutionPrinterPass
-    : public MandatoryPassInfoMixin<ScalarEvolutionPrinterPass> {
+    : public RequiredPassInfoMixin<ScalarEvolutionPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/StackLifetime.h b/llvm/include/llvm/Analysis/StackLifetime.h
index 28edba708bc2a..5bbbc0e149bd3 100644
--- a/llvm/include/llvm/Analysis/StackLifetime.h
+++ b/llvm/include/llvm/Analysis/StackLifetime.h
@@ -180,7 +180,7 @@ inline raw_ostream &operator<<(raw_ostream &OS,
 
 /// Printer pass for testing.
 class StackLifetimePrinterPass
-    : public MandatoryPassInfoMixin<StackLifetimePrinterPass> {
+    : public RequiredPassInfoMixin<StackLifetimePrinterPass> {
   StackLifetime::LivenessType Type;
   raw_ostream &OS;
 
diff --git a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
index 6b6ddd44fbb6d..592ee8b52bb41 100644
--- a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
+++ b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
@@ -100,7 +100,7 @@ class StackSafetyAnalysis : public AnalysisInfoMixin<StackSafetyAnalysis> {
 
 /// Printer pass for the \c StackSafetyAnalysis results.
 class StackSafetyPrinterPass
-    : public MandatoryPassInfoMixin<StackSafetyPrinterPass> {
+    : public RequiredPassInfoMixin<StackSafetyPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -138,7 +138,7 @@ class StackSafetyGlobalAnalysis
 
 /// Printer pass for the \c StackSafetyGlobalAnalysis results.
 class StackSafetyGlobalPrinterPass
-    : public MandatoryPassInfoMixin<StackSafetyGlobalPrinterPass> {
+    : public RequiredPassInfoMixin<StackSafetyGlobalPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Analysis/StructuralHash.h b/llvm/include/llvm/Analysis/StructuralHash.h
index 013fbede3c3ed..4a6f54a609ffd 100644
--- a/llvm/include/llvm/Analysis/StructuralHash.h
+++ b/llvm/include/llvm/Analysis/StructuralHash.h
@@ -21,7 +21,7 @@ enum class StructuralHashOptions {
 
 /// Printer pass for  StructuralHashes
 class StructuralHashPrinterPass
-    : public MandatoryPassInfoMixin<StructuralHashPrinterPass> {
+    : public RequiredPassInfoMixin<StructuralHashPrinterPass> {
   raw_ostream &OS;
   const StructuralHashOptions Options;
 
diff --git a/llvm/include/llvm/Analysis/UniformityAnalysis.h b/llvm/include/llvm/Analysis/UniformityAnalysis.h
index 3c9422353c24e..78895da944346 100644
--- a/llvm/include/llvm/Analysis/UniformityAnalysis.h
+++ b/llvm/include/llvm/Analysis/UniformityAnalysis.h
@@ -42,7 +42,7 @@ class UniformityInfoAnalysis
 
 /// Printer pass for the \c UniformityInfo.
 class UniformityInfoPrinterPass
-    : public MandatoryPassInfoMixin<UniformityInfoPrinterPass> {
+    : public RequiredPassInfoMixin<UniformityInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
index af97e5024efe9..b9707583f07b1 100644
--- a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
+++ b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
@@ -40,7 +40,7 @@ LLVM_ABI bool isBitcodeWriterPass(Pass *P);
 ///
 /// Note that this is intended for use with the new pass manager. To construct
 /// a pass for the legacy pass manager, use the function above.
-class BitcodeWriterPass : public MandatoryPassInfoMixin<BitcodeWriterPass> {
+class BitcodeWriterPass : public RequiredPassInfoMixin<BitcodeWriterPass> {
   raw_ostream &OS;
   bool ShouldPreserveUseListOrder;
   bool EmitSummaryIndex;
diff --git a/llvm/include/llvm/CodeGen/BranchRelaxation.h b/llvm/include/llvm/CodeGen/BranchRelaxation.h
index 1a3ab6ad86dfa..cee7fcf50fc01 100644
--- a/llvm/include/llvm/CodeGen/BranchRelaxation.h
+++ b/llvm/include/llvm/CodeGen/BranchRelaxation.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class BranchRelaxationPass
-    : public MandatoryPassInfoMixin<BranchRelaxationPass> {
+    : public RequiredPassInfoMixin<BranchRelaxationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/DetectDeadLanes.h b/llvm/include/llvm/CodeGen/DetectDeadLanes.h
index 2e523c0335d2c..3a9a73b9b4794 100644
--- a/llvm/include/llvm/CodeGen/DetectDeadLanes.h
+++ b/llvm/include/llvm/CodeGen/DetectDeadLanes.h
@@ -116,7 +116,7 @@ class DeadLaneDetector {
   BitVector DefinedByCopy;
 };
 
-class DetectDeadLanesPass : public MandatoryPassInfoMixin<DetectDeadLanesPass> {
+class DetectDeadLanesPass : public RequiredPassInfoMixin<DetectDeadLanesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/ExpandIRInsts.h b/llvm/include/llvm/CodeGen/ExpandIRInsts.h
index 18adf05f429bb..5971acb2c1cf2 100644
--- a/llvm/include/llvm/CodeGen/ExpandIRInsts.h
+++ b/llvm/include/llvm/CodeGen/ExpandIRInsts.h
@@ -16,7 +16,7 @@ namespace llvm {
 
 class TargetMachine;
 
-class ExpandIRInstsPass : public MandatoryPassInfoMixin<ExpandIRInstsPass> {
+class ExpandIRInstsPass : public RequiredPassInfoMixin<ExpandIRInstsPass> {
 private:
   const TargetMachine *TM;
   CodeGenOptLevel OptLevel;
diff --git a/llvm/include/llvm/CodeGen/ExpandPostRAPseudos.h b/llvm/include/llvm/CodeGen/ExpandPostRAPseudos.h
index 79e6c1d6f3167..e4abb30a034d8 100644
--- a/llvm/include/llvm/CodeGen/ExpandPostRAPseudos.h
+++ b/llvm/include/llvm/CodeGen/ExpandPostRAPseudos.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class ExpandPostRAPseudosPass
-    : public MandatoryPassInfoMixin<ExpandPostRAPseudosPass> {
+    : public RequiredPassInfoMixin<ExpandPostRAPseudosPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/FEntryInserter.h b/llvm/include/llvm/CodeGen/FEntryInserter.h
index 6160217ccd381..d7590fd8ac4e2 100644
--- a/llvm/include/llvm/CodeGen/FEntryInserter.h
+++ b/llvm/include/llvm/CodeGen/FEntryInserter.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class FEntryInserterPass : public MandatoryPassInfoMixin<FEntryInserterPass> {
+class FEntryInserterPass : public RequiredPassInfoMixin<FEntryInserterPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/FinalizeISel.h b/llvm/include/llvm/CodeGen/FinalizeISel.h
index 4fc06ef76b4e1..b940dbfd1d89c 100644
--- a/llvm/include/llvm/CodeGen/FinalizeISel.h
+++ b/llvm/include/llvm/CodeGen/FinalizeISel.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class FinalizeISelPass : public MandatoryPassInfoMixin<FinalizeISelPass> {
+class FinalizeISelPass : public RequiredPassInfoMixin<FinalizeISelPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
 };
diff --git a/llvm/include/llvm/CodeGen/InitUndef.h b/llvm/include/llvm/CodeGen/InitUndef.h
index a4399b2b25fa7..bf72a03a81b71 100644
--- a/llvm/include/llvm/CodeGen/InitUndef.h
+++ b/llvm/include/llvm/CodeGen/InitUndef.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class InitUndefPass : public MandatoryPassInfoMixin<InitUndefPass> {
+class InitUndefPass : public RequiredPassInfoMixin<InitUndefPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/KCFI.h b/llvm/include/llvm/CodeGen/KCFI.h
index 9981fdb22e1e7..f0dd093f99b04 100644
--- a/llvm/include/llvm/CodeGen/KCFI.h
+++ b/llvm/include/llvm/CodeGen/KCFI.h
@@ -19,7 +19,7 @@
 
 namespace llvm {
 
-class MachineKCFIPass : public MandatoryPassInfoMixin<MachineKCFIPass> {
+class MachineKCFIPass : public RequiredPassInfoMixin<MachineKCFIPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/LiveIntervals.h b/llvm/include/llvm/CodeGen/LiveIntervals.h
index ec4a04d4bbc95..99a0122265d3b 100644
--- a/llvm/include/llvm/CodeGen/LiveIntervals.h
+++ b/llvm/include/llvm/CodeGen/LiveIntervals.h
@@ -528,7 +528,7 @@ class LiveIntervalsAnalysis : public AnalysisInfoMixin<LiveIntervalsAnalysis> {
 };
 
 class LiveIntervalsPrinterPass
-    : public MandatoryPassInfoMixin<LiveIntervalsPrinterPass> {
+    : public RequiredPassInfoMixin<LiveIntervalsPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/LiveVariables.h b/llvm/include/llvm/CodeGen/LiveVariables.h
index c667a1cff4ec9..c6e0c8419f35b 100644
--- a/llvm/include/llvm/CodeGen/LiveVariables.h
+++ b/llvm/include/llvm/CodeGen/LiveVariables.h
@@ -310,7 +310,7 @@ class LiveVariablesAnalysis : public AnalysisInfoMixin<LiveVariablesAnalysis> {
 };
 
 class LiveVariablesPrinterPass
-    : public MandatoryPassInfoMixin<LiveVariablesPrinterPass> {
+    : public RequiredPassInfoMixin<LiveVariablesPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h b/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
index 8eebe6c60125a..4abb09b9cb541 100644
--- a/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
+++ b/llvm/include/llvm/CodeGen/LocalStackSlotAllocation.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class LocalStackSlotAllocationPass
-    : public MandatoryPassInfoMixin<LocalStackSlotAllocationPass> {
+    : public RequiredPassInfoMixin<LocalStackSlotAllocationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &);
 };
diff --git a/llvm/include/llvm/CodeGen/MIRPrinter.h b/llvm/include/llvm/CodeGen/MIRPrinter.h
index df2c3d124a1c7..829d16823d721 100644
--- a/llvm/include/llvm/CodeGen/MIRPrinter.h
+++ b/llvm/include/llvm/CodeGen/MIRPrinter.h
@@ -26,7 +26,7 @@ class MachineModuleInfo;
 class Module;
 template <typename T> class SmallVectorImpl;
 
-class PrintMIRPreparePass : public MandatoryPassInfoMixin<PrintMIRPreparePass> {
+class PrintMIRPreparePass : public RequiredPassInfoMixin<PrintMIRPreparePass> {
   raw_ostream &OS;
 
 public:
@@ -34,7 +34,7 @@ class PrintMIRPreparePass : public MandatoryPassInfoMixin<PrintMIRPreparePass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM);
 };
 
-class PrintMIRPass : public MandatoryPassInfoMixin<PrintMIRPass> {
+class PrintMIRPass : public RequiredPassInfoMixin<PrintMIRPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
index ba789e3acce86..e9c38d0189b2e 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
@@ -125,7 +125,7 @@ class MachineBlockFrequencyAnalysis
 
 /// Printer pass for the \c MachineBlockFrequencyInfo results.
 class MachineBlockFrequencyPrinterPass
-    : public MandatoryPassInfoMixin<MachineBlockFrequencyPrinterPass> {
+    : public RequiredPassInfoMixin<MachineBlockFrequencyPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
index dd24afd8cd444..363d6dc0b1ee2 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
@@ -118,7 +118,7 @@ class MachineBlockHashInfoAnalysis
 
 /// Printer pass for the \c MachineBlockHashInfoAnalysis results.
 class MachineBlockHashInfoPrinterPass
-    : public MandatoryPassInfoMixin<MachineBlockHashInfoPrinterPass> {
+    : public RequiredPassInfoMixin<MachineBlockHashInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineBlockPlacement.h b/llvm/include/llvm/CodeGen/MachineBlockPlacement.h
index 5e630e4e79d72..abc5a62ae57a1 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockPlacement.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockPlacement.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class MachineBlockPlacementPass
-    : public MandatoryPassInfoMixin<MachineBlockPlacementPass> {
+    : public RequiredPassInfoMixin<MachineBlockPlacementPass> {
 
   bool AllowTailMerge = true;
 
@@ -30,7 +30,7 @@ class MachineBlockPlacementPass
 };
 
 class MachineBlockPlacementStatsPass
-    : public MandatoryPassInfoMixin<MachineBlockPlacementStatsPass> {
+    : public RequiredPassInfoMixin<MachineBlockPlacementStatsPass> {
 
 public:
   PreservedAnalyses run(MachineFunction &MF,
diff --git a/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h b/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
index dac1d909ab211..9573f922bd1b2 100644
--- a/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
@@ -63,7 +63,7 @@ class MachineCycleAnalysis : public AnalysisInfoMixin<MachineCycleAnalysis> {
 };
 
 class MachineCycleInfoPrinterPass
-    : public MandatoryPassInfoMixin<MachineCycleInfoPrinterPass> {
+    : public RequiredPassInfoMixin<MachineCycleInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineDominators.h b/llvm/include/llvm/CodeGen/MachineDominators.h
index 36103ccbaba2e..f30688e13f212 100644
--- a/llvm/include/llvm/CodeGen/MachineDominators.h
+++ b/llvm/include/llvm/CodeGen/MachineDominators.h
@@ -112,7 +112,7 @@ class MachineDominatorTreeAnalysis
 
 /// \brief Machine function pass which print \c MachineDominatorTree.
 class MachineDominatorTreePrinterPass
-    : public MandatoryPassInfoMixin<MachineDominatorTreePrinterPass> {
+    : public RequiredPassInfoMixin<MachineDominatorTreePrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineLoopInfo.h b/llvm/include/llvm/CodeGen/MachineLoopInfo.h
index ebe3d59ca877b..60b3f6c6a3ba5 100644
--- a/llvm/include/llvm/CodeGen/MachineLoopInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineLoopInfo.h
@@ -149,7 +149,7 @@ class MachineLoopAnalysis : public AnalysisInfoMixin<MachineLoopAnalysis> {
 
 /// Printer pass for the \c LoopAnalysis results.
 class MachineLoopPrinterPass
-    : public MandatoryPassInfoMixin<MachineLoopPrinterPass> {
+    : public RequiredPassInfoMixin<MachineLoopPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachinePassManager.h b/llvm/include/llvm/CodeGen/MachinePassManager.h
index 4ff1756b8bae9..f200d56b94872 100644
--- a/llvm/include/llvm/CodeGen/MachinePassManager.h
+++ b/llvm/include/llvm/CodeGen/MachinePassManager.h
@@ -189,7 +189,7 @@ class FunctionAnalysisManagerMachineFunctionProxy
 };
 
 class FunctionToMachineFunctionPassAdaptor
-    : public MandatoryPassInfoMixin<FunctionToMachineFunctionPassAdaptor> {
+    : public RequiredPassInfoMixin<FunctionToMachineFunctionPassAdaptor> {
 public:
   using PassConceptT =
       detail::PassConcept<MachineFunction, MachineFunctionAnalysisManager>;
diff --git a/llvm/include/llvm/CodeGen/MachinePostDominators.h b/llvm/include/llvm/CodeGen/MachinePostDominators.h
index a1b7730c1af21..f4045a95bc386 100644
--- a/llvm/include/llvm/CodeGen/MachinePostDominators.h
+++ b/llvm/include/llvm/CodeGen/MachinePostDominators.h
@@ -81,7 +81,7 @@ class MachinePostDominatorTreeAnalysis
 };
 
 class MachinePostDominatorTreePrinterPass
-    : public MandatoryPassInfoMixin<MachinePostDominatorTreePrinterPass> {
+    : public RequiredPassInfoMixin<MachinePostDominatorTreePrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineTraceMetrics.h b/llvm/include/llvm/CodeGen/MachineTraceMetrics.h
index b21313013fca7..9d48d60626385 100644
--- a/llvm/include/llvm/CodeGen/MachineTraceMetrics.h
+++ b/llvm/include/llvm/CodeGen/MachineTraceMetrics.h
@@ -462,7 +462,7 @@ class MachineTraceMetricsAnalysis
 
 /// Verifier pass for \c MachineTraceMetrics.
 struct MachineTraceMetricsVerifierPass
-    : MandatoryPassInfoMixin<MachineTraceMetricsVerifierPass> {
+    : RequiredPassInfoMixin<MachineTraceMetricsVerifierPass> {
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
diff --git a/llvm/include/llvm/CodeGen/MachineUniformityAnalysis.h b/llvm/include/llvm/CodeGen/MachineUniformityAnalysis.h
index 4c16c2be21df8..390abaa6dd42c 100644
--- a/llvm/include/llvm/CodeGen/MachineUniformityAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineUniformityAnalysis.h
@@ -64,7 +64,7 @@ class MachineUniformityAnalysis
 };
 
 class MachineUniformityPrinterPass
-    : public MandatoryPassInfoMixin<MachineUniformityPrinterPass> {
+    : public RequiredPassInfoMixin<MachineUniformityPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/MachineVerifier.h b/llvm/include/llvm/CodeGen/MachineVerifier.h
index f6520ef78dda2..d37fd14296135 100644
--- a/llvm/include/llvm/CodeGen/MachineVerifier.h
+++ b/llvm/include/llvm/CodeGen/MachineVerifier.h
@@ -14,7 +14,7 @@
 #include <string>
 
 namespace llvm {
-class MachineVerifierPass : public MandatoryPassInfoMixin<MachineVerifierPass> {
+class MachineVerifierPass : public RequiredPassInfoMixin<MachineVerifierPass> {
   std::string Banner;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/PEI.h b/llvm/include/llvm/CodeGen/PEI.h
index f78f75e2dd05c..d75626b2cd1f4 100644
--- a/llvm/include/llvm/CodeGen/PEI.h
+++ b/llvm/include/llvm/CodeGen/PEI.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class PrologEpilogInserterPass
-    : public MandatoryPassInfoMixin<PrologEpilogInserterPass> {
+    : public RequiredPassInfoMixin<PrologEpilogInserterPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/PHIElimination.h b/llvm/include/llvm/CodeGen/PHIElimination.h
index 84d8c67076be9..397391f9df92a 100644
--- a/llvm/include/llvm/CodeGen/PHIElimination.h
+++ b/llvm/include/llvm/CodeGen/PHIElimination.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 
-class PHIEliminationPass : public MandatoryPassInfoMixin<PHIEliminationPass> {
+class PHIEliminationPass : public RequiredPassInfoMixin<PHIEliminationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/PatchableFunction.h b/llvm/include/llvm/CodeGen/PatchableFunction.h
index 7872f3a21bd85..b7c0a3780d50c 100644
--- a/llvm/include/llvm/CodeGen/PatchableFunction.h
+++ b/llvm/include/llvm/CodeGen/PatchableFunction.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class PatchableFunctionPass
-    : public MandatoryPassInfoMixin<PatchableFunctionPass> {
+    : public RequiredPassInfoMixin<PatchableFunctionPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/PostRAHazardRecognizer.h b/llvm/include/llvm/CodeGen/PostRAHazardRecognizer.h
index 4523304eebe21..91583a7377786 100644
--- a/llvm/include/llvm/CodeGen/PostRAHazardRecognizer.h
+++ b/llvm/include/llvm/CodeGen/PostRAHazardRecognizer.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class PostRAHazardRecognizerPass
-    : public MandatoryPassInfoMixin<PostRAHazardRecognizerPass> {
+    : public RequiredPassInfoMixin<PostRAHazardRecognizerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
index 5e617cf537863..da48c990b008d 100644
--- a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
+++ b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
@@ -326,7 +326,7 @@ class ReachingDefAnalysis : public AnalysisInfoMixin<ReachingDefAnalysis> {
 
 /// Printer pass for the \c ReachingDefInfo results.
 class ReachingDefPrinterPass
-    : public MandatoryPassInfoMixin<ReachingDefPrinterPass> {
+    : public RequiredPassInfoMixin<ReachingDefPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/RegAllocFast.h b/llvm/include/llvm/CodeGen/RegAllocFast.h
index 4f18b3a77beea..24e59ce60a3b0 100644
--- a/llvm/include/llvm/CodeGen/RegAllocFast.h
+++ b/llvm/include/llvm/CodeGen/RegAllocFast.h
@@ -14,7 +14,7 @@
 
 namespace llvm {
 
-class RegAllocFastPass : public MandatoryPassInfoMixin<RegAllocFastPass> {
+class RegAllocFastPass : public RequiredPassInfoMixin<RegAllocFastPass> {
 public:
   struct Options {
     RegAllocFilterFunc Filter;
diff --git a/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h b/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
index 28518a1153955..b0d7b5bee06b4 100644
--- a/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
+++ b/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
@@ -15,7 +15,7 @@
 
 using namespace llvm;
 
-class RAGreedyPass : public MandatoryPassInfoMixin<RAGreedyPass> {
+class RAGreedyPass : public RequiredPassInfoMixin<RAGreedyPass> {
 public:
   struct Options {
     RegAllocFilterFunc Filter;
diff --git a/llvm/include/llvm/CodeGen/RegisterUsageInfo.h b/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
index 6be03151eb259..0e5ec50cb257a 100644
--- a/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
+++ b/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
@@ -96,7 +96,7 @@ class PhysicalRegisterUsageAnalysis
 };
 
 class PhysicalRegisterUsageInfoPrinterPass
-    : public MandatoryPassInfoMixin<PhysicalRegisterUsageInfoPrinterPass> {
+    : public RequiredPassInfoMixin<PhysicalRegisterUsageInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/SanitizerBinaryMetadata.h b/llvm/include/llvm/CodeGen/SanitizerBinaryMetadata.h
index 6568ea59aefe4..f0f8418e1373b 100644
--- a/llvm/include/llvm/CodeGen/SanitizerBinaryMetadata.h
+++ b/llvm/include/llvm/CodeGen/SanitizerBinaryMetadata.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class MachineSanitizerBinaryMetadataPass
-    : public MandatoryPassInfoMixin<MachineSanitizerBinaryMetadataPass> {
+    : public RequiredPassInfoMixin<MachineSanitizerBinaryMetadataPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
index 10b844063aa0f..78f56fba774bc 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
@@ -582,7 +582,7 @@ class SelectionDAGISelLegacy : public MachineFunctionPass {
 };
 
 class SelectionDAGISelPass
-    : public MandatoryPassInfoMixin<SelectionDAGISelPass> {
+    : public RequiredPassInfoMixin<SelectionDAGISelPass> {
   std::unique_ptr<SelectionDAGISel> Selector;
 
 protected:
diff --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h
index cc5dc0d344c2b..5b40bd26a991c 100644
--- a/llvm/include/llvm/CodeGen/SlotIndexes.h
+++ b/llvm/include/llvm/CodeGen/SlotIndexes.h
@@ -660,7 +660,7 @@ class raw_ostream;
   };
 
   class SlotIndexesPrinterPass
-      : public MandatoryPassInfoMixin<SlotIndexesPrinterPass> {
+      : public RequiredPassInfoMixin<SlotIndexesPrinterPass> {
     raw_ostream &OS;
 
   public:
diff --git a/llvm/include/llvm/CodeGen/StackFrameLayoutAnalysisPass.h b/llvm/include/llvm/CodeGen/StackFrameLayoutAnalysisPass.h
index 5909e2f227046..e3c3dac049bdc 100644
--- a/llvm/include/llvm/CodeGen/StackFrameLayoutAnalysisPass.h
+++ b/llvm/include/llvm/CodeGen/StackFrameLayoutAnalysisPass.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class StackFrameLayoutAnalysisPass
-    : public MandatoryPassInfoMixin<StackFrameLayoutAnalysisPass> {
+    : public RequiredPassInfoMixin<StackFrameLayoutAnalysisPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/CodeGen/VirtRegMap.h b/llvm/include/llvm/CodeGen/VirtRegMap.h
index 10466de9cb2e0..c75b3eda00622 100644
--- a/llvm/include/llvm/CodeGen/VirtRegMap.h
+++ b/llvm/include/llvm/CodeGen/VirtRegMap.h
@@ -229,7 +229,7 @@ class VirtRegMapAnalysis : public AnalysisInfoMixin<VirtRegMapAnalysis> {
 };
 
 class VirtRegMapPrinterPass
-    : public MandatoryPassInfoMixin<VirtRegMapPrinterPass> {
+    : public RequiredPassInfoMixin<VirtRegMapPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -238,7 +238,7 @@ class VirtRegMapPrinterPass
                                  MachineFunctionAnalysisManager &MFAM);
 };
 
-class VirtRegRewriterPass : public MandatoryPassInfoMixin<VirtRegRewriterPass> {
+class VirtRegRewriterPass : public RequiredPassInfoMixin<VirtRegRewriterPass> {
   bool ClearVirtRegs = true;
 
 public:
diff --git a/llvm/include/llvm/CodeGen/XRayInstrumentation.h b/llvm/include/llvm/CodeGen/XRayInstrumentation.h
index bfb38fffbec0d..25355e0ada973 100644
--- a/llvm/include/llvm/CodeGen/XRayInstrumentation.h
+++ b/llvm/include/llvm/CodeGen/XRayInstrumentation.h
@@ -14,7 +14,7 @@
 namespace llvm {
 
 class XRayInstrumentationPass
-    : public MandatoryPassInfoMixin<XRayInstrumentationPass> {
+    : public RequiredPassInfoMixin<XRayInstrumentationPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/include/llvm/IR/Dominators.h b/llvm/include/llvm/IR/Dominators.h
index a846eba903a61..4ee3c81b55712 100644
--- a/llvm/include/llvm/IR/Dominators.h
+++ b/llvm/include/llvm/IR/Dominators.h
@@ -289,7 +289,7 @@ class DominatorTreeAnalysis : public AnalysisInfoMixin<DominatorTreeAnalysis> {
 
 /// Printer pass for the \c DominatorTree.
 class DominatorTreePrinterPass
-    : public MandatoryPassInfoMixin<DominatorTreePrinterPass> {
+    : public RequiredPassInfoMixin<DominatorTreePrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -300,7 +300,7 @@ class DominatorTreePrinterPass
 
 /// Verifier pass for the \c DominatorTree.
 struct DominatorTreeVerifierPass
-    : MandatoryPassInfoMixin<DominatorTreeVerifierPass> {
+    : RequiredPassInfoMixin<DominatorTreeVerifierPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index 6fc1a307f97ce..97338bcd92d0a 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -68,7 +68,7 @@ template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
 ///
 /// This provides some boilerplate for types that are passes.
 ///
-/// Actual passes should inherit from MandatoryPassInfoMixin or
+/// Actual passes should inherit from RequiredPassInfoMixin or
 /// OptionalPassInfoMixin.
 template <typename DerivedT> struct PassInfoMixin {
   /// Gets the name of the pass we are mixed into.
@@ -93,7 +93,7 @@ template <typename DerivedT> struct PassInfoMixin {
 
 /// A CRTP mix-in for passes that should not be skipped.
 template <typename DerivedT>
-struct MandatoryPassInfoMixin : PassInfoMixin<DerivedT> {
+struct RequiredPassInfoMixin : PassInfoMixin<DerivedT> {
   static bool isRequired() { return true; }
 };
 
@@ -177,7 +177,7 @@ getAnalysisResult(AnalysisManager<IRUnitT, AnalysisArgTs...> &AM, IRUnitT &IR,
 template <typename IRUnitT,
           typename AnalysisManagerT = AnalysisManager<IRUnitT>,
           typename... ExtraArgTs>
-class PassManager : public MandatoryPassInfoMixin<
+class PassManager : public RequiredPassInfoMixin<
                         PassManager<IRUnitT, AnalysisManagerT, ExtraArgTs...>> {
 public:
   /// Construct a pass manager.
@@ -864,7 +864,7 @@ using ModuleAnalysisManagerFunctionProxy =
 /// analyses are not invalidated while the function passes are running, so they
 /// may be stale.  Function analyses will not be stale.
 class ModuleToFunctionPassAdaptor
-    : public MandatoryPassInfoMixin<ModuleToFunctionPassAdaptor> {
+    : public RequiredPassInfoMixin<ModuleToFunctionPassAdaptor> {
 public:
   using PassConceptT = detail::PassConcept<Function, FunctionAnalysisManager>;
 
@@ -912,7 +912,7 @@ template <typename AnalysisT, typename IRUnitT,
           typename AnalysisManagerT = AnalysisManager<IRUnitT>,
           typename... ExtraArgTs>
 struct RequireAnalysisPass
-    : MandatoryPassInfoMixin<RequireAnalysisPass<
+    : RequiredPassInfoMixin<RequireAnalysisPass<
           AnalysisT, IRUnitT, AnalysisManagerT, ExtraArgTs...>> {
   /// Run this pass over some unit of IR.
   ///
@@ -939,7 +939,7 @@ struct RequireAnalysisPass
 /// to be invalidated.
 template <typename AnalysisT>
 struct InvalidateAnalysisPass
-    : MandatoryPassInfoMixin<InvalidateAnalysisPass<AnalysisT>> {
+    : RequiredPassInfoMixin<InvalidateAnalysisPass<AnalysisT>> {
   /// Run this pass over some unit of IR.
   ///
   /// This pass can be run over any unit of IR and use any analysis manager,
@@ -965,7 +965,7 @@ struct InvalidateAnalysisPass
 /// Because this preserves no analyses, any analysis passes queried after this
 /// pass runs will recompute fresh results.
 struct InvalidateAllAnalysesPass
-    : MandatoryPassInfoMixin<InvalidateAllAnalysesPass> {
+    : RequiredPassInfoMixin<InvalidateAllAnalysesPass> {
   /// Run this pass over some unit of IR.
   template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
   PreservedAnalyses run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...) {
diff --git a/llvm/include/llvm/IR/PassManagerInternal.h b/llvm/include/llvm/IR/PassManagerInternal.h
index da55722cc6716..f96fb02b1d3c5 100644
--- a/llvm/include/llvm/IR/PassManagerInternal.h
+++ b/llvm/include/llvm/IR/PassManagerInternal.h
@@ -58,7 +58,7 @@ struct PassConcept {
   /// Polymorphic method to let a pass optionally exempted from skipping by
   /// PassInstrumentation.
   /// To opt-in, pass should implement `static bool isRequired()`, or inherit
-  /// from `MandatoryPassInfoMixin` or `OptionalPassInfoMixin`.
+  /// from `RequiredPassInfoMixin` or `OptionalPassInfoMixin`.
   /// It's no-op to have `isRequired` always return false since that is the
   /// default.
   virtual bool isRequired() const = 0;
diff --git a/llvm/include/llvm/IR/SafepointIRVerifier.h b/llvm/include/llvm/IR/SafepointIRVerifier.h
index aa1e1e51db78c..ca4511b1ab8c8 100644
--- a/llvm/include/llvm/IR/SafepointIRVerifier.h
+++ b/llvm/include/llvm/IR/SafepointIRVerifier.h
@@ -35,7 +35,7 @@ FunctionPass *createSafepointIRVerifierPass();
 /// Create an instance of the safepoint verifier pass which can be added to
 /// a pass pipeline to check for relocation bugs.
 class SafepointIRVerifierPass
-    : public MandatoryPassInfoMixin<SafepointIRVerifierPass> {
+    : public RequiredPassInfoMixin<SafepointIRVerifierPass> {
 
 public:
   explicit SafepointIRVerifierPass() = default;
diff --git a/llvm/include/llvm/IR/Verifier.h b/llvm/include/llvm/IR/Verifier.h
index 19b2d42437437..b0ab1db1b2b60 100644
--- a/llvm/include/llvm/IR/Verifier.h
+++ b/llvm/include/llvm/IR/Verifier.h
@@ -131,7 +131,7 @@ class VerifierAnalysis : public AnalysisInfoMixin<VerifierAnalysis> {
 ///
 /// Note that this creates a pass suitable for the legacy pass manager. It has
 /// nothing to do with \c VerifierPass.
-class VerifierPass : public MandatoryPassInfoMixin<VerifierPass> {
+class VerifierPass : public RequiredPassInfoMixin<VerifierPass> {
   bool FatalErrors;
 
 public:
diff --git a/llvm/include/llvm/IRPrinter/IRPrintingPasses.h b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
index b1f1e4c87f48a..e574d94ca2f22 100644
--- a/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
+++ b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
@@ -30,7 +30,7 @@ class Pass;
 
 /// Pass (for the new pass manager) for printing a Module as
 /// LLVM's text IR assembly.
-class PrintModulePass : public MandatoryPassInfoMixin<PrintModulePass> {
+class PrintModulePass : public RequiredPassInfoMixin<PrintModulePass> {
   raw_ostream &OS;
   std::string Banner;
   bool ShouldPreserveUseListOrder;
@@ -47,7 +47,7 @@ class PrintModulePass : public MandatoryPassInfoMixin<PrintModulePass> {
 
 /// Pass (for the new pass manager) for printing a Function as
 /// LLVM's text IR assembly.
-class PrintFunctionPass : public MandatoryPassInfoMixin<PrintFunctionPass> {
+class PrintFunctionPass : public RequiredPassInfoMixin<PrintFunctionPass> {
   raw_ostream &OS;
   std::string Banner;
 
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroCleanup.h b/llvm/include/llvm/Transforms/Coroutines/CoroCleanup.h
index 3a3a92d112dc2..eee0112c59072 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroCleanup.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroCleanup.h
@@ -20,7 +20,7 @@ namespace llvm {
 
 class Module;
 
-struct CoroCleanupPass : MandatoryPassInfoMixin<CoroCleanupPass> {
+struct CoroCleanupPass : RequiredPassInfoMixin<CoroCleanupPass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
 } // end namespace llvm
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroConditionalWrapper.h b/llvm/include/llvm/Transforms/Coroutines/CoroConditionalWrapper.h
index b3f91ff2e7b2b..bdc803d785ab6 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroConditionalWrapper.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroConditionalWrapper.h
@@ -17,7 +17,7 @@ class Module;
 
 // Only runs passes in the contained pass manager if the module contains any
 // coroutine intrinsic declarations.
-struct CoroConditionalWrapper : MandatoryPassInfoMixin<CoroConditionalWrapper> {
+struct CoroConditionalWrapper : RequiredPassInfoMixin<CoroConditionalWrapper> {
   CoroConditionalWrapper(ModulePassManager &&);
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroEarly.h b/llvm/include/llvm/Transforms/Coroutines/CoroEarly.h
index d887dc562d6c4..194cc0b2b4ce5 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroEarly.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroEarly.h
@@ -23,7 +23,7 @@ namespace llvm {
 
 class Module;
 
-struct CoroEarlyPass : MandatoryPassInfoMixin<CoroEarlyPass> {
+struct CoroEarlyPass : RequiredPassInfoMixin<CoroEarlyPass> {
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 } // end namespace llvm
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroElide.h b/llvm/include/llvm/Transforms/Coroutines/CoroElide.h
index 9f3fd80a39107..51cd4f5149d58 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroElide.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroElide.h
@@ -22,7 +22,7 @@ namespace llvm {
 
 class Function;
 
-struct CoroElidePass : MandatoryPassInfoMixin<CoroElidePass> {
+struct CoroElidePass : RequiredPassInfoMixin<CoroElidePass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 } // end namespace llvm
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h b/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
index 136e3ace8cd05..3c589370a04fc 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
@@ -28,7 +28,7 @@ class BaseABI;
 struct Shape;
 } // namespace coro
 
-struct CoroSplitPass : MandatoryPassInfoMixin<CoroSplitPass> {
+struct CoroSplitPass : RequiredPassInfoMixin<CoroSplitPass> {
   using BaseABITy =
       std::function<std::unique_ptr<coro::BaseABI>(Function &, coro::Shape &)>;
 
diff --git a/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h b/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
index 1ef480778c558..28201ccac5656 100644
--- a/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
+++ b/llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
@@ -26,19 +26,19 @@ namespace llvm {
 class Module;
 
 class HipStdParAcceleratorCodeSelectionPass
-    : public MandatoryPassInfoMixin<HipStdParAcceleratorCodeSelectionPass> {
+    : public RequiredPassInfoMixin<HipStdParAcceleratorCodeSelectionPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
 
 class HipStdParAllocationInterpositionPass
-    : public MandatoryPassInfoMixin<HipStdParAllocationInterpositionPass> {
+    : public RequiredPassInfoMixin<HipStdParAllocationInterpositionPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
 
 class HipStdParMathFixupPass
-    : public MandatoryPassInfoMixin<HipStdParMathFixupPass> {
+    : public RequiredPassInfoMixin<HipStdParMathFixupPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
diff --git a/llvm/include/llvm/Transforms/IPO/AlwaysInliner.h b/llvm/include/llvm/Transforms/IPO/AlwaysInliner.h
index 7641f851dd5af..a7f93ae60212d 100644
--- a/llvm/include/llvm/Transforms/IPO/AlwaysInliner.h
+++ b/llvm/include/llvm/Transforms/IPO/AlwaysInliner.h
@@ -30,7 +30,7 @@ class Pass;
 /// be the simplest possible pass to remove always_inline function definitions'
 /// uses by inlining them. The \c GlobalDCE pass can be used to remove these
 /// functions once all users are gone.
-class AlwaysInlinerPass : public MandatoryPassInfoMixin<AlwaysInlinerPass> {
+class AlwaysInlinerPass : public RequiredPassInfoMixin<AlwaysInlinerPass> {
   bool InsertLifetime;
 
 public:
diff --git a/llvm/include/llvm/Transforms/IPO/EmbedBitcodePass.h b/llvm/include/llvm/Transforms/IPO/EmbedBitcodePass.h
index 7983bfe5e47c2..60bf218f2ff00 100644
--- a/llvm/include/llvm/Transforms/IPO/EmbedBitcodePass.h
+++ b/llvm/include/llvm/Transforms/IPO/EmbedBitcodePass.h
@@ -35,7 +35,7 @@ struct EmbedBitcodeOptions {
 
 /// Pass embeds a copy of the module optimized with the provided pass pipeline
 /// into a global variable.
-class EmbedBitcodePass : public MandatoryPassInfoMixin<EmbedBitcodePass> {
+class EmbedBitcodePass : public RequiredPassInfoMixin<EmbedBitcodePass> {
   bool IsThinLTO;
   bool EmitLTOSummary;
 
diff --git a/llvm/include/llvm/Transforms/IPO/FatLTOCleanup.h b/llvm/include/llvm/Transforms/IPO/FatLTOCleanup.h
index 1e0e04a97a42f..35ab3ebb3b24e 100644
--- a/llvm/include/llvm/Transforms/IPO/FatLTOCleanup.h
+++ b/llvm/include/llvm/Transforms/IPO/FatLTOCleanup.h
@@ -24,7 +24,7 @@ namespace llvm {
 class Module;
 class ModuleSummaryIndex;
 
-class FatLtoCleanup : public MandatoryPassInfoMixin<FatLtoCleanup> {
+class FatLtoCleanup : public RequiredPassInfoMixin<FatLtoCleanup> {
 public:
   FatLtoCleanup() = default;
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
diff --git a/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h b/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
index c8b0510efef2e..914a7db326a4f 100644
--- a/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
+++ b/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
@@ -201,7 +201,7 @@ enum class DropTestKind {
 
 } // end namespace lowertypetests
 
-class LowerTypeTestsPass : public MandatoryPassInfoMixin<LowerTypeTestsPass> {
+class LowerTypeTestsPass : public RequiredPassInfoMixin<LowerTypeTestsPass> {
   bool UseCommandLine = false;
 
   ModuleSummaryIndex *ExportSummary = nullptr;
@@ -216,7 +216,7 @@ class LowerTypeTestsPass : public MandatoryPassInfoMixin<LowerTypeTestsPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
-class DropTypeTestsPass : public MandatoryPassInfoMixin<DropTypeTestsPass> {
+class DropTypeTestsPass : public RequiredPassInfoMixin<DropTypeTestsPass> {
   lowertypetests::DropTestKind Kind = lowertypetests::DropTestKind::Assume;
 
 public:
diff --git a/llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h b/llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
index d58e2a7ef0520..e89e30beb3724 100644
--- a/llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
+++ b/llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
@@ -24,7 +24,7 @@ class Module;
 class raw_ostream;
 
 class ThinLTOBitcodeWriterPass
-    : public MandatoryPassInfoMixin<ThinLTOBitcodeWriterPass> {
+    : public RequiredPassInfoMixin<ThinLTOBitcodeWriterPass> {
   raw_ostream &OS;
   raw_ostream *ThinLinkOS;
   const bool ShouldPreserveUseListOrder;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
index d91c24bab8576..781b88175f562 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -38,7 +38,7 @@ struct AddressSanitizerOptions {
 /// This adds 'asan.module_ctor' to 'llvm.global_ctors'. This pass may also
 /// run intependently of the function address sanitizer.
 class AddressSanitizerPass
-    : public MandatoryPassInfoMixin<AddressSanitizerPass> {
+    : public RequiredPassInfoMixin<AddressSanitizerPass> {
 public:
   LLVM_ABI
   AddressSanitizerPass(const AddressSanitizerOptions &Options,
diff --git a/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h b/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h
index 8822c9c7af8c0..937a5ddbca00f 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AllocToken.h
@@ -33,7 +33,7 @@ struct AllocTokenOptions {
 
 /// A module pass that rewrites heap allocations to use token-enabled
 /// allocation functions based on various source-level properties.
-class AllocTokenPass : public MandatoryPassInfoMixin<AllocTokenPass> {
+class AllocTokenPass : public RequiredPassInfoMixin<AllocTokenPass> {
 public:
   LLVM_ABI explicit AllocTokenPass(AllocTokenOptions Opts = {});
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
diff --git a/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h b/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
index 5ee9acd7aa9bd..9c52f8ac929a6 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/BoundsChecking.h
@@ -19,7 +19,7 @@ class Function;
 
 /// A pass to instrument code and perform run-time bounds checking on loads,
 /// stores, and other memory intrinsics.
-class BoundsCheckingPass : public MandatoryPassInfoMixin<BoundsCheckingPass> {
+class BoundsCheckingPass : public RequiredPassInfoMixin<BoundsCheckingPass> {
 
 public:
   struct Options {
diff --git a/llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
index f9c14ea682a65..7073e2e854145 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
@@ -18,7 +18,7 @@ namespace llvm {
 class Module;
 
 class DataFlowSanitizerPass
-    : public MandatoryPassInfoMixin<DataFlowSanitizerPass> {
+    : public RequiredPassInfoMixin<DataFlowSanitizerPass> {
 private:
   std::vector<std::string> ABIListFiles;
   IntrusiveRefCntPtr<vfs::FileSystem> FS;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
index 106aae8d20bb1..d31488b1b6c41 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
@@ -38,7 +38,7 @@ struct HWAddressSanitizerOptions {
 /// instrumenting code to check for various memory errors at runtime, similar to
 /// AddressSanitizer but based on partial hardware assistance.
 class HWAddressSanitizerPass
-    : public MandatoryPassInfoMixin<HWAddressSanitizerPass> {
+    : public RequiredPassInfoMixin<HWAddressSanitizerPass> {
 public:
   explicit HWAddressSanitizerPass(HWAddressSanitizerOptions Options)
       : Options(Options){};
diff --git a/llvm/include/llvm/Transforms/Instrumentation/KCFI.h b/llvm/include/llvm/Transforms/Instrumentation/KCFI.h
index 7640aec28b92f..ff20d69dcc5bd 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/KCFI.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/KCFI.h
@@ -18,7 +18,7 @@
 #include "llvm/Support/Compiler.h"
 
 namespace llvm {
-class KCFIPass : public MandatoryPassInfoMixin<KCFIPass> {
+class KCFIPass : public RequiredPassInfoMixin<KCFIPass> {
 public:
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h b/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h
index 479dcff623586..cf5fe6d2ab506 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/LowerAllowCheckPass.h
@@ -23,7 +23,7 @@ namespace llvm {
 
 // This pass is responsible for removing optional traps, like llvm.ubsantrap
 // from the hot code.
-class LowerAllowCheckPass : public MandatoryPassInfoMixin<LowerAllowCheckPass> {
+class LowerAllowCheckPass : public RequiredPassInfoMixin<LowerAllowCheckPass> {
 public:
   struct Options {
     std::vector<unsigned int> cutoffs;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/MemProfInstrumentation.h b/llvm/include/llvm/Transforms/Instrumentation/MemProfInstrumentation.h
index 98f9f4d5f05d8..d672da40f4335 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/MemProfInstrumentation.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/MemProfInstrumentation.h
@@ -27,7 +27,7 @@ class Module;
 /// calls to the MemProfiler runtime library functions. The runtime library
 /// essentially replaces malloc() and free() with custom implementations that
 /// record data about the allocations.
-class MemProfilerPass : public MandatoryPassInfoMixin<MemProfilerPass> {
+class MemProfilerPass : public RequiredPassInfoMixin<MemProfilerPass> {
 public:
   LLVM_ABI explicit MemProfilerPass();
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
@@ -36,7 +36,7 @@ class MemProfilerPass : public MandatoryPassInfoMixin<MemProfilerPass> {
 /// Public interface to the memory profiler module pass for instrumenting code
 /// to profile memory allocations and accesses.
 class ModuleMemProfilerPass
-    : public MandatoryPassInfoMixin<ModuleMemProfilerPass> {
+    : public RequiredPassInfoMixin<ModuleMemProfilerPass> {
 public:
   LLVM_ABI explicit ModuleMemProfilerPass();
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
diff --git a/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
index 28f2a3b3305d3..b42f2e21aa52f 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
@@ -40,8 +40,7 @@ struct MemorySanitizerOptions {
 /// inserts calls to runtime library functions. If the functions aren't declared
 /// yet, the pass inserts the declarations. Otherwise the existing globals are
 /// used.
-struct MemorySanitizerPass
-    : public MandatoryPassInfoMixin<MemorySanitizerPass> {
+struct MemorySanitizerPass : public RequiredPassInfoMixin<MemorySanitizerPass> {
   MemorySanitizerPass(MemorySanitizerOptions Options) : Options(Options) {}
 
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
diff --git a/llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h
index 148fe880cf054..71e4a81dbaff1 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h
@@ -27,7 +27,7 @@ namespace llvm {
 /// This pass inserts calls to runtime library functions. If the
 /// functions aren't declared yet, the pass inserts the declarations.
 struct NumericalStabilitySanitizerPass
-    : public MandatoryPassInfoMixin<NumericalStabilitySanitizerPass> {
+    : public RequiredPassInfoMixin<NumericalStabilitySanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/RealtimeSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/RealtimeSanitizer.h
index 5122c8111a29c..6d7fd120537d1 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/RealtimeSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/RealtimeSanitizer.h
@@ -26,7 +26,7 @@ namespace llvm {
 
 /// Create ctor and init functions.
 struct RealtimeSanitizerPass
-    : public MandatoryPassInfoMixin<RealtimeSanitizerPass> {
+    : public RequiredPassInfoMixin<RealtimeSanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
index f8aa67bac429b..4cc0253ba0baf 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
@@ -53,7 +53,7 @@ inline constexpr char kSanitizerBinaryMetadataAtomicsSection[] =
 //
 /// The pass should be inserted after optimizations.
 class SanitizerBinaryMetadataPass
-    : public MandatoryPassInfoMixin<SanitizerBinaryMetadataPass> {
+    : public RequiredPassInfoMixin<SanitizerBinaryMetadataPass> {
 public:
   LLVM_ABI explicit SanitizerBinaryMetadataPass(
       SanitizerBinaryMetadataOptions Opts = {},
diff --git a/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h b/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
index ca41d6d175bcb..269bcbcd32265 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
@@ -32,7 +32,7 @@ class FileSystem;
 /// module for trace PC guards and 8bit counters if they are requested, and
 /// appends globals to llvm.compiler.used.
 class SanitizerCoveragePass
-    : public MandatoryPassInfoMixin<SanitizerCoveragePass> {
+    : public RequiredPassInfoMixin<SanitizerCoveragePass> {
 public:
   LLVM_ABI explicit SanitizerCoveragePass(
       SanitizerCoverageOptions Options = SanitizerCoverageOptions(),
diff --git a/llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
index 7ee0ea12e30af..39e09a458cba5 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
@@ -25,8 +25,7 @@ class Module;
 /// Instruments functions to detect race conditions reads. This function pass
 /// inserts calls to runtime library functions. If the functions aren't declared
 /// yet, the pass inserts the declarations. Otherwise the existing globals are
-struct ThreadSanitizerPass
-    : public MandatoryPassInfoMixin<ThreadSanitizerPass> {
+struct ThreadSanitizerPass : public RequiredPassInfoMixin<ThreadSanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
 };
 
@@ -34,7 +33,7 @@ struct ThreadSanitizerPass
 ///
 /// Create ctor and init functions.
 struct ModuleThreadSanitizerPass
-    : public MandatoryPassInfoMixin<ModuleThreadSanitizerPass> {
+    : public RequiredPassInfoMixin<ModuleThreadSanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/TypeSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/TypeSanitizer.h
index 669b75a156a82..df49cadb51003 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/TypeSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/TypeSanitizer.h
@@ -21,7 +21,7 @@ class Function;
 class FunctionPass;
 class Module;
 
-struct TypeSanitizerPass : public MandatoryPassInfoMixin<TypeSanitizerPass> {
+struct TypeSanitizerPass : public RequiredPassInfoMixin<TypeSanitizerPass> {
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
diff --git a/llvm/include/llvm/Transforms/Scalar/AnnotationRemarks.h b/llvm/include/llvm/Transforms/Scalar/AnnotationRemarks.h
index ac13e08b90573..d31e6b6b46a91 100644
--- a/llvm/include/llvm/Transforms/Scalar/AnnotationRemarks.h
+++ b/llvm/include/llvm/Transforms/Scalar/AnnotationRemarks.h
@@ -21,7 +21,7 @@ namespace llvm {
 class Function;
 
 struct AnnotationRemarksPass
-    : public MandatoryPassInfoMixin<AnnotationRemarksPass> {
+    : public RequiredPassInfoMixin<AnnotationRemarksPass> {
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 } // namespace llvm
diff --git a/llvm/include/llvm/Transforms/Scalar/IVUsersPrinter.h b/llvm/include/llvm/Transforms/Scalar/IVUsersPrinter.h
index cfebcde77041a..fe679d828b126 100644
--- a/llvm/include/llvm/Transforms/Scalar/IVUsersPrinter.h
+++ b/llvm/include/llvm/Transforms/Scalar/IVUsersPrinter.h
@@ -18,7 +18,7 @@ class Loop;
 class raw_ostream;
 
 /// Printer pass for the \c IVUsers for a loop.
-class IVUsersPrinterPass : public MandatoryPassInfoMixin<IVUsersPrinterPass> {
+class IVUsersPrinterPass : public RequiredPassInfoMixin<IVUsersPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h b/llvm/include/llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h
index de4be2860eb66..78a74b5d490b0 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopAccessAnalysisPrinter.h
@@ -18,7 +18,7 @@ class raw_ostream;
 
 /// Printer pass for the \c LoopAccessInfo results.
 class LoopAccessInfoPrinterPass
-    : public MandatoryPassInfoMixin<LoopAccessInfoPrinterPass> {
+    : public RequiredPassInfoMixin<LoopAccessInfoPrinterPass> {
   raw_ostream &OS;
   bool AllowPartial;
 
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index 6e4d3828803f0..86e53f15ba456 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -70,7 +70,7 @@ using HasRunOnLoopT = decltype(std::declval<PassT>().run(
 template <>
 class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
                   LPMUpdater &>
-    : public MandatoryPassInfoMixin<
+    : public RequiredPassInfoMixin<
           PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
                       LPMUpdater &>> {
 public:
@@ -184,7 +184,7 @@ typedef PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
 template <typename AnalysisT>
 struct RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
                            LoopStandardAnalysisResults &, LPMUpdater &>
-    : MandatoryPassInfoMixin<
+    : RequiredPassInfoMixin<
           RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
                               LoopStandardAnalysisResults &, LPMUpdater &>> {
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
@@ -394,7 +394,7 @@ std::optional<PreservedAnalyses> LoopPassManager::runSinglePass(
 /// \fn createLoopFunctionToLoopPassAdaptor to see when loop mode and loop-nest
 /// mode are used.
 class FunctionToLoopPassAdaptor
-    : public MandatoryPassInfoMixin<FunctionToLoopPassAdaptor> {
+    : public RequiredPassInfoMixin<FunctionToLoopPassAdaptor> {
 public:
   using PassConceptT =
       detail::PassConcept<Loop, LoopAnalysisManager,
diff --git a/llvm/include/llvm/Transforms/Scalar/LowerAtomicPass.h b/llvm/include/llvm/Transforms/Scalar/LowerAtomicPass.h
index e4bab58b297a3..d94ce33b5514a 100644
--- a/llvm/include/llvm/Transforms/Scalar/LowerAtomicPass.h
+++ b/llvm/include/llvm/Transforms/Scalar/LowerAtomicPass.h
@@ -19,7 +19,7 @@
 namespace llvm {
 
 /// A pass that lowers atomic intrinsic into non-atomic intrinsics.
-class LowerAtomicPass : public MandatoryPassInfoMixin<LowerAtomicPass> {
+class LowerAtomicPass : public RequiredPassInfoMixin<LowerAtomicPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
 };
diff --git a/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h b/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h
index aff39ae6d95e6..fc825b1b7866d 100644
--- a/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h
+++ b/llvm/include/llvm/Transforms/Scalar/LowerMatrixIntrinsics.h
@@ -17,7 +17,7 @@
 
 namespace llvm {
 class LowerMatrixIntrinsicsPass
-    : public MandatoryPassInfoMixin<LowerMatrixIntrinsicsPass> {
+    : public RequiredPassInfoMixin<LowerMatrixIntrinsicsPass> {
   bool Minimal;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Utils/AddDiscriminators.h b/llvm/include/llvm/Transforms/Utils/AddDiscriminators.h
index 13f7c0cb671f1..72bcad09e0347 100644
--- a/llvm/include/llvm/Transforms/Utils/AddDiscriminators.h
+++ b/llvm/include/llvm/Transforms/Utils/AddDiscriminators.h
@@ -22,7 +22,7 @@ namespace llvm {
 class Function;
 
 class AddDiscriminatorsPass
-    : public MandatoryPassInfoMixin<AddDiscriminatorsPass> {
+    : public RequiredPassInfoMixin<AddDiscriminatorsPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
diff --git a/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h b/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
index a0d4cdeacb5c8..592011f1bd58b 100644
--- a/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
+++ b/llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
@@ -22,7 +22,7 @@ namespace llvm {
 class Function;
 
 struct EntryExitInstrumenterPass
-    : public MandatoryPassInfoMixin<EntryExitInstrumenterPass> {
+    : public RequiredPassInfoMixin<EntryExitInstrumenterPass> {
   EntryExitInstrumenterPass(bool PostInlining) : PostInlining(PostInlining) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
diff --git a/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h b/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h
index 49c3e1d940e3f..c0884ec6cadd7 100644
--- a/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h
+++ b/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h
@@ -56,7 +56,7 @@ template <typename MarkerTy> struct ShouldRunExtraPasses {
 /// simplifications after loop-vectorization, if runtime checks have been added.
 template <typename MarkerTy>
 class ExtraFunctionPassManager
-    : public MandatoryPassInfoMixin<ExtraFunctionPassManager<MarkerTy>> {
+    : public RequiredPassInfoMixin<ExtraFunctionPassManager<MarkerTy>> {
   FunctionPassManager InnerFPM;
 
 public:
@@ -78,7 +78,7 @@ class ExtraFunctionPassManager
 /// An example is doing additional runs of SimpleLoopUnswitch.
 template <typename MarkerTy>
 class ExtraLoopPassManager
-    : public MandatoryPassInfoMixin<ExtraLoopPassManager<MarkerTy>> {
+    : public RequiredPassInfoMixin<ExtraLoopPassManager<MarkerTy>> {
   LoopPassManager InnerLPM;
 
 public:
diff --git a/llvm/include/llvm/Transforms/Utils/NameAnonGlobals.h b/llvm/include/llvm/Transforms/Utils/NameAnonGlobals.h
index 9d2305e354203..55e149ac98ec3 100644
--- a/llvm/include/llvm/Transforms/Utils/NameAnonGlobals.h
+++ b/llvm/include/llvm/Transforms/Utils/NameAnonGlobals.h
@@ -19,7 +19,7 @@
 namespace llvm {
 
 /// Simple pass that provides a name to every anonymous globals.
-class NameAnonGlobalPass : public MandatoryPassInfoMixin<NameAnonGlobalPass> {
+class NameAnonGlobalPass : public RequiredPassInfoMixin<NameAnonGlobalPass> {
 public:
   NameAnonGlobalPass() = default;
 
diff --git a/llvm/include/llvm/Transforms/Utils/PredicateInfo.h b/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
index b12229a2f8343..e472656d7b9fb 100644
--- a/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
+++ b/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
@@ -235,7 +235,7 @@ class PredicateInfo {
 
 /// Printer pass for \c PredicateInfo.
 class PredicateInfoPrinterPass
-    : public MandatoryPassInfoMixin<PredicateInfoPrinterPass> {
+    : public RequiredPassInfoMixin<PredicateInfoPrinterPass> {
   raw_ostream &OS;
 
 public:
@@ -245,7 +245,7 @@ class PredicateInfoPrinterPass
 
 /// Verifier pass for \c PredicateInfo.
 struct PredicateInfoVerifierPass
-    : MandatoryPassInfoMixin<PredicateInfoVerifierPass> {
+    : RequiredPassInfoMixin<PredicateInfoVerifierPass> {
   LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 4a6f59b0eaa81..c6dd1dbb62449 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -420,7 +420,7 @@ class SIModeRegisterPass : public OptionalPassInfoMixin<SIModeRegisterPass> {
 };
 
 class SIMemoryLegalizerPass
-    : public MandatoryPassInfoMixin<SIMemoryLegalizerPass> {
+    : public RequiredPassInfoMixin<SIMemoryLegalizerPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -440,7 +440,7 @@ class AMDGPUMarkLastScratchLoadPass
 };
 
 class SIInsertWaitcntsPass
-    : public MandatoryPassInfoMixin<SIInsertWaitcntsPass> {
+    : public RequiredPassInfoMixin<SIInsertWaitcntsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -454,14 +454,14 @@ class SIInsertHardClausesPass
 };
 
 class SILateBranchLoweringPass
-    : public MandatoryPassInfoMixin<SILateBranchLoweringPass> {
+    : public RequiredPassInfoMixin<SILateBranchLoweringPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
 };
 
 class SIPreEmitPeepholePass
-    : public MandatoryPassInfoMixin<SIPreEmitPeepholePass> {
+    : public RequiredPassInfoMixin<SIPreEmitPeepholePass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h b/llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h
index 8bf3c12c0e226..1c6e5b1d8cbce 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUNextUseAnalysis.h
@@ -364,7 +364,7 @@ class AMDGPUNextUseAnalysisPrinterLegacyPass : public MachineFunctionPass {
 };
 
 class AMDGPUNextUseAnalysisPrinterPass
-    : public MandatoryPassInfoMixin<AMDGPUNextUseAnalysisPrinterPass> {
+    : public RequiredPassInfoMixin<AMDGPUNextUseAnalysisPrinterPass> {
   raw_ostream &OS;
 
 public:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h b/llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h
index e92b1b5a3a7c4..4badd74547622 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUReserveWWMRegs.h
@@ -13,7 +13,7 @@
 
 namespace llvm {
 class AMDGPUReserveWWMRegsPass
-    : public MandatoryPassInfoMixin<AMDGPUReserveWWMRegsPass> {
+    : public RequiredPassInfoMixin<AMDGPUReserveWWMRegsPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/llvm/lib/Target/BPF/BPF.h b/llvm/lib/Target/BPF/BPF.h
index d561e0a2cb66b..8c35e61944482 100644
--- a/llvm/lib/Target/BPF/BPF.h
+++ b/llvm/lib/Target/BPF/BPF.h
@@ -45,7 +45,7 @@ void initializeBPFMIPreEmitPeepholePass(PassRegistry &);
 void initializeBPFMISimplifyPatchablePass(PassRegistry &);
 
 class BPFAbstractMemberAccessPass
-    : public MandatoryPassInfoMixin<BPFAbstractMemberAccessPass> {
+    : public RequiredPassInfoMixin<BPFAbstractMemberAccessPass> {
   BPFTargetMachine *TM;
 
 public:
@@ -54,18 +54,18 @@ class BPFAbstractMemberAccessPass
 };
 
 class BPFPreserveDITypePass
-    : public MandatoryPassInfoMixin<BPFPreserveDITypePass> {
+    : public RequiredPassInfoMixin<BPFPreserveDITypePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
-class BPFIRPeepholePass : public MandatoryPassInfoMixin<BPFIRPeepholePass> {
+class BPFIRPeepholePass : public RequiredPassInfoMixin<BPFIRPeepholePass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
 class BPFASpaceCastSimplifyPass
-    : public MandatoryPassInfoMixin<BPFASpaceCastSimplifyPass> {
+    : public RequiredPassInfoMixin<BPFASpaceCastSimplifyPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
@@ -76,7 +76,7 @@ class BPFAdjustOptPass : public OptionalPassInfoMixin<BPFAdjustOptPass> {
 };
 
 class BPFPreserveStaticOffsetPass
-    : public MandatoryPassInfoMixin<BPFPreserveStaticOffsetPass> {
+    : public RequiredPassInfoMixin<BPFPreserveStaticOffsetPass> {
   bool AllowPartial;
 
 public:
diff --git a/llvm/lib/Target/DirectX/DXILFinalizeLinkage.h b/llvm/lib/Target/DirectX/DXILFinalizeLinkage.h
index 71e78d54d6793..b12abee84ff3e 100644
--- a/llvm/lib/Target/DirectX/DXILFinalizeLinkage.h
+++ b/llvm/lib/Target/DirectX/DXILFinalizeLinkage.h
@@ -21,7 +21,7 @@
 
 namespace llvm {
 
-class DXILFinalizeLinkage : public MandatoryPassInfoMixin<DXILFinalizeLinkage> {
+class DXILFinalizeLinkage : public RequiredPassInfoMixin<DXILFinalizeLinkage> {
 public:
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
 };
diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h
index 4e76809a15d71..5668a4eeddbd8 100644
--- a/llvm/lib/Target/X86/X86.h
+++ b/llvm/lib/Target/X86/X86.h
@@ -228,7 +228,7 @@ FunctionPass *createX86LowerTileCopyLegacyPass();
 /// ensures that the open interval of function start and end PCs contains all
 /// return addresses for the benefit of the Windows x64 unwinder.
 class X86AvoidTrailingCallPass
-    : public MandatoryPassInfoMixin<X86AvoidTrailingCallPass> {
+    : public RequiredPassInfoMixin<X86AvoidTrailingCallPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
@@ -363,7 +363,7 @@ FunctionPass *createX86WinEHUnwindV2LegacyPass();
 
 /// The pass transforms load/store <256 x i32> to AMX load/store intrinsics
 /// or split the data to two <128 x i32>.
-class X86LowerAMXTypePass : public MandatoryPassInfoMixin<X86LowerAMXTypePass> {
+class X86LowerAMXTypePass : public RequiredPassInfoMixin<X86LowerAMXTypePass> {
 private:
   const TargetMachine *TM;
 
@@ -387,7 +387,7 @@ FunctionPass *createX86SuppressAPXForRelocationLegacyPass();
 /// The pass transforms amx intrinsics to scalar operation if the function has
 /// optnone attribute or it is O0.
 class X86LowerAMXIntrinsicsPass
-    : public MandatoryPassInfoMixin<X86LowerAMXIntrinsicsPass> {
+    : public RequiredPassInfoMixin<X86LowerAMXIntrinsicsPass> {
 private:
   const TargetMachine *TM;
 
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.h b/llvm/lib/Target/X86/X86AsmPrinter.h
index a9228e2f45f3b..142b68839501d 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.h
+++ b/llvm/lib/Target/X86/X86AsmPrinter.h
@@ -211,7 +211,7 @@ class X86AsmPrinterBeginPass
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
 };
 
-class X86AsmPrinterPass : public MandatoryPassInfoMixin<X86AsmPrinterPass> {
+class X86AsmPrinterPass : public RequiredPassInfoMixin<X86AsmPrinterPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
diff --git a/polly/include/polly/ScopDetection.h b/polly/include/polly/ScopDetection.h
index 68f21c3c63d2d..823f6e9a86606 100644
--- a/polly/include/polly/ScopDetection.h
+++ b/polly/include/polly/ScopDetection.h
@@ -69,12 +69,12 @@ using llvm::Function;
 using llvm::FunctionAnalysisManager;
 using llvm::IntrinsicInst;
 using llvm::LoopInfo;
-using llvm::MandatoryPassInfoMixin;
 using llvm::Module;
 using llvm::OptimizationRemarkEmitter;
 using llvm::OptionalPassInfoMixin;
 using llvm::PreservedAnalyses;
 using llvm::RegionInfo;
+using llvm::RequiredPassInfoMixin;
 using llvm::ScalarEvolution;
 using llvm::SCEVUnknown;
 using llvm::SetVector;
@@ -628,7 +628,7 @@ struct ScopAnalysis : AnalysisInfoMixin<ScopAnalysis> {
 };
 
 struct ScopAnalysisPrinterPass final
-    : MandatoryPassInfoMixin<ScopAnalysisPrinterPass> {
+    : RequiredPassInfoMixin<ScopAnalysisPrinterPass> {
   ScopAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
 
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 0a07ccc91be41..8c1bb5a3633fd 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -47,12 +47,12 @@ using llvm::isa;
 using llvm::iterator_range;
 using llvm::LoadInst;
 using llvm::make_range;
-using llvm::MandatoryPassInfoMixin;
 using llvm::MapVector;
 using llvm::MemIntrinsic;
 using llvm::OptionalPassInfoMixin;
 using llvm::PHINode;
 using llvm::RegionNode;
+using llvm::RequiredPassInfoMixin;
 using llvm::SetVector;
 using llvm::SmallPtrSetImpl;
 using llvm::SmallVector;
diff --git a/polly/include/polly/Support/DumpFunctionPass.h b/polly/include/polly/Support/DumpFunctionPass.h
index d765a8e002e4e..065f038454b9a 100644
--- a/polly/include/polly/Support/DumpFunctionPass.h
+++ b/polly/include/polly/Support/DumpFunctionPass.h
@@ -19,7 +19,7 @@
 namespace polly {
 
 /// A pass that isolates a function into a new Module and writes it into a file.
-struct DumpFunctionPass final : llvm::MandatoryPassInfoMixin<DumpFunctionPass> {
+struct DumpFunctionPass final : llvm::RequiredPassInfoMixin<DumpFunctionPass> {
   std::string Suffix;
 
   DumpFunctionPass(std::string Suffix) : Suffix(std::move(Suffix)) {}
diff --git a/polly/include/polly/Support/DumpModulePass.h b/polly/include/polly/Support/DumpModulePass.h
index 85b0913c29840..7895913c9a8b2 100644
--- a/polly/include/polly/Support/DumpModulePass.h
+++ b/polly/include/polly/Support/DumpModulePass.h
@@ -26,7 +26,7 @@ namespace polly {
 /// The intent of IsSuffix is to avoid the file being overwritten when
 /// processing multiple modules and/or with multiple dump passes in the
 /// pipeline.
-struct DumpModulePass final : llvm::MandatoryPassInfoMixin<DumpModulePass> {
+struct DumpModulePass final : llvm::RequiredPassInfoMixin<DumpModulePass> {
   std::string Filename;
   bool IsSuffix;
 

>From edfdd534791ec93dfcc7b11cc4cd1e66f6ffd426 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Mon, 4 May 2026 20:46:11 +0000
Subject: [PATCH 4/4] format

---
 llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h | 3 ++-
 llvm/lib/Target/X86/X86.h                     | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h b/llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h
index 5056a2476de4b..f8924ad61ed92 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h
+++ b/llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.h
@@ -15,7 +15,8 @@ namespace llvm {
 
 class SPIRVTargetMachine;
 
-class SPIRVPrepareFunctions : public OptionalPassInfoMixin<SPIRVPrepareFunctions> {
+class SPIRVPrepareFunctions
+    : public OptionalPassInfoMixin<SPIRVPrepareFunctions> {
   const SPIRVTargetMachine &TM;
 
 public:
diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h
index 5668a4eeddbd8..8570115054062 100644
--- a/llvm/lib/Target/X86/X86.h
+++ b/llvm/lib/Target/X86/X86.h
@@ -70,7 +70,8 @@ FunctionPass *createX86FPStackifierLegacyPass();
 
 /// This pass inserts AVX vzeroupper instructions before each call to avoid
 /// transition penalty between functions encoded with AVX and SSE.
-class X86InsertVZeroUpperPass : public OptionalPassInfoMixin<X86InsertVZeroUpperPass> {
+class X86InsertVZeroUpperPass
+    : public OptionalPassInfoMixin<X86InsertVZeroUpperPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);



More information about the cfe-commits mailing list