LLVM  8.0.1
Classes | Public Member Functions | Static Public Member Functions | List of all members
llvm::PreservedAnalyses Class Reference

A set of analyses that are preserved following a run of a transformation pass. More...

#include "llvm/IR/PassManager.h"

Classes

class  PreservedAnalysisChecker
 A checker object that makes it easy to query for whether an analysis or some set covering it is preserved. More...
 

Public Member Functions

template<typename AnalysisT >
void preserve ()
 Mark an analysis as preserved. More...
 
void preserve (AnalysisKey *ID)
 Given an analysis's ID, mark the analysis as preserved, adding it to the set. More...
 
template<typename AnalysisSetT >
void preserveSet ()
 Mark an analysis set as preserved. More...
 
void preserveSet (AnalysisSetKey *ID)
 Mark an analysis set as preserved using its ID. More...
 
template<typename AnalysisT >
void abandon ()
 Mark an analysis as abandoned. More...
 
void abandon (AnalysisKey *ID)
 Mark an analysis as abandoned using its ID. More...
 
void intersect (const PreservedAnalyses &Arg)
 Intersect this set with another in place. More...
 
void intersect (PreservedAnalyses &&Arg)
 Intersect this set with a temporary other set in place. More...
 
template<typename AnalysisT >
PreservedAnalysisChecker getChecker () const
 Build a checker for this PreservedAnalyses and the specified analysis type. More...
 
PreservedAnalysisChecker getChecker (AnalysisKey *ID) const
 Build a checker for this PreservedAnalyses and the specified analysis ID. More...
 
bool areAllPreserved () const
 Test whether all analyses are preserved (and none are abandoned). More...
 
template<typename AnalysisSetT >
bool allAnalysesInSetPreserved () const
 Directly test whether a set of analyses is preserved. More...
 
bool allAnalysesInSetPreserved (AnalysisSetKey *SetID) const
 Directly test whether a set of analyses is preserved. More...
 

Static Public Member Functions

static PreservedAnalyses none ()
 Convenience factory function for the empty preserved set. More...
 
static PreservedAnalyses all ()
 Construct a special preserved set that preserves all passes. More...
 
template<typename AnalysisSetT >
static PreservedAnalyses allInSet ()
 Construct a preserved analyses object with a single preserved set. More...
 

Detailed Description

A set of analyses that are preserved following a run of a transformation pass.

Transformation passes build and return these objects to communicate which analyses are still valid after the transformation. For most passes this is fairly simple: if they don't change anything all analyses are preserved, otherwise only a short list of analyses that have been explicitly updated are preserved.

This class also lets transformation passes mark abstract sets of analyses as preserved. A transformation that (say) does not alter the CFG can indicate such by marking a particular AnalysisSetKey as preserved, and then analyses can query whether that AnalysisSetKey is preserved.

Finally, this class can represent an "abandoned" analysis, which is not preserved even if it would be covered by some abstract set of analyses.

Given a PreservedAnalyses object, an analysis will typically want to figure out whether it is preserved. In the example below, MyAnalysisType is preserved if it's not abandoned, and (a) it's explicitly marked as preserved, (b), the set AllAnalysesOn<MyIRUnit> is preserved, or (c) both AnalysisSetA and AnalysisSetB are preserved.

auto PAC = PA.getChecker<MyAnalysisType>();
if (PAC.preserved() || PAC.preservedSet<AllAnalysesOn<MyIRUnit>>() ||
(PAC.preservedSet<AnalysisSetA>() &&
PAC.preservedSet<AnalysisSetB>())) {
// The analysis has been successfully preserved ...
}

Definition at line 154 of file PassManager.h.

Member Function Documentation

◆ abandon() [1/2]

template<typename AnalysisT >
void llvm::PreservedAnalyses::abandon ( )
inline

Mark an analysis as abandoned.

An abandoned analysis is not preserved, even if it is nominally covered by some other set or was previously explicitly marked as preserved.

Note that you can only abandon a specific analysis, not a set of analyses.

Definition at line 208 of file PassManager.h.

References abandon().

Referenced by abandon(), llvm::FunctionAnalysisManagerCGSCCProxy::Result::invalidate(), llvm::PassManager< Function >::run(), and llvm::InvalidateAnalysisPass< AnalysisT >::run().

◆ abandon() [2/2]

void llvm::PreservedAnalyses::abandon ( AnalysisKey ID)
inline

Mark an analysis as abandoned using its ID.

An abandoned analysis is not preserved, even if it is nominally covered by some other set or was previously explicitly marked as preserved.

Note that you can only abandon a specific analysis, not a set of analyses.

Definition at line 217 of file PassManager.h.

◆ all()

static PreservedAnalyses llvm::PreservedAnalyses::all ( )
inlinestatic

Construct a special preserved set that preserves all passes.

Definition at line 160 of file PassManager.h.

References llvm::SmallPtrSetImpl< PtrType >::insert().

Referenced by INITIALIZE_PASS(), isOptimizingForSize(), llvm::SyntheticCountsPropagation::run(), llvm::LoadStoreVectorizerPass::run(), llvm::ExpandReductionsPass::run(), llvm::BoundsCheckingPass::run(), llvm::CorrelatedValuePropagationPass::run(), llvm::CGProfilePass::run(), llvm::LibCallsShrinkWrapPass::run(), llvm::LowerGuardIntrinsicPass::run(), llvm::CrossDSOCFIPass::run(), llvm::GCOVProfilerPass::run(), llvm::PreISelIntrinsicLoweringPass::run(), llvm::ForceFunctionAttrsPass::run(), llvm::HotColdSplittingPass::run(), llvm::LowerInvokePass::run(), llvm::CallSiteSplittingPass::run(), llvm::DCEPass::run(), llvm::IRCEPass::run(), llvm::IVUsersPrinterPass::run(), llvm::LoopAccessInfoPrinterPass::run(), llvm::LowerAtomicPass::run(), llvm::PartiallyInlineLibCallsPass::run(), llvm::SinkingPass::run(), llvm::BreakCriticalEdgesPass::run(), llvm::PromotePass::run(), llvm::DivRemPairsPass::run(), llvm::NewGVNPass::run(), llvm::ScalarizerPass::run(), llvm::AddDiscriminatorsPass::run(), llvm::InferFunctionAttrsPass::run(), llvm::CanonicalizeAliasesPass::run(), llvm::PartialInlinerPass::run(), llvm::StripDeadPrototypesPass::run(), llvm::BDCEPass::run(), llvm::Float2IntPass::run(), llvm::GuardWideningPass::run(), llvm::ControlHeightReductionPass::run(), llvm::LoopRotatePass::run(), llvm::LoopPredicationPass::run(), llvm::EliminateAvailableExternallyPass::run(), llvm::GlobalOptPass::run(), llvm::NameAnonGlobalPass::run(), llvm::IndVarSimplifyPass::run(), llvm::LoopDataPrefetchPass::run(), llvm::LoopDistributePass::run(), llvm::LoopInstSimplifyPass::run(), llvm::LoopDeletionPass::run(), llvm::LoopLoadEliminationPass::run(), llvm::LoopSimplifyCFGPass::run(), llvm::GlobalSplitPass::run(), llvm::LoopUnrollAndJamPass::run(), llvm::WarnMissedTransformationsPass::run(), llvm::AlignmentFromAssumptionsPass::run(), llvm::AggressiveInstCombinePass::run(), llvm::ThreadSanitizerPass::run(), llvm::LoopIdiomRecognizePass::run(), llvm::ArgumentPromotionPass::run(), llvm::RewriteStatepointsForGC::run(), llvm::DSEPass::run(), llvm::CalledValuePropagationPass::run(), llvm::ConstantMergePass::run(), llvm::GlobalDCEPass::run(), llvm::LowerExpectIntrinsicPass::run(), llvm::CFGViewerPass::run(), llvm::SampleProfileLoaderPass::run(), llvm::IPSCCPPass::run(), llvm::ADCEPass::run(), llvm::UnreachableBlockElimPass::run(), llvm::PGOInstrumentationGen::run(), llvm::MergedLoadStoreMotionPass::run(), llvm::EarlyCSEPass::run(), llvm::ThinLTOBitcodeWriterPass::run(), llvm::InstCombinePass::run(), llvm::LoopSinkPass::run(), llvm::LoopStrengthReducePass::run(), llvm::LoopFullUnrollPass::run(), llvm::AlwaysInlinerPass::run(), llvm::InstSimplifyPass::run(), llvm::SCCPPass::run(), llvm::MemorySanitizerPass::run(), llvm::LCSSAPass::run(), llvm::InstrProfiling::run(), llvm::PGOInstrumentationUse::run(), llvm::LICMPass::run(), llvm::SimplifyCFGPass::run(), llvm::MemCpyOptPass::run(), llvm::LoopSimplifyPass::run(), llvm::PostOrderFunctionAttrsPass::run(), llvm::PGOIndirectCallPromotion::run(), llvm::StackSafetyPrinterPass::run(), llvm::AAEvaluator::run(), llvm::TailCallElimPass::run(), llvm::PostDominatorTreePrinterPass::run(), llvm::InternalizePass::run(), llvm::PGOMemOPSizeOpt::run(), llvm::SimpleLoopUnswitchPass::run(), llvm::ReversePostOrderFunctionAttrsPass::run(), llvm::BitcodeWriterPass::run(), llvm::GVN::run(), llvm::SpeculativeExecutionPass::run(), llvm::SLPVectorizerPass::run(), llvm::DeadArgumentEliminationPass::run(), llvm::ReassociatePass::run(), llvm::PrintModulePass::run(), llvm::RequireAnalysisPass< AnalysisT, Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::run(), llvm::StackSafetyGlobalPrinterPass::run(), llvm::LoopVectorizePass::run(), llvm::InlinerPass::run(), llvm::JumpThreadingPass::run(), llvm::NaryReassociatePass::run(), llvm::SpeculateAroundPHIsPass::run(), llvm::PrintFunctionPass::run(), llvm::LoopUnrollPass::run(), llvm::ConstantHoistingPass::run(), llvm::FunctionImportPass::run(), llvm::DemandedBitsPrinterPass::run(), llvm::RewriteSymbolPass::run(), llvm::BlockFrequencyPrinterPass::run(), llvm::PhiValuesPrinterPass::run(), llvm::VerifierPass::run(), llvm::RequireAnalysisPass< AnalysisT, LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & >::run(), llvm::ProfileSummaryPrinterPass::run(), llvm::AssumptionPrinterPass::run(), llvm::DominanceFrontierPrinterPass::run(), llvm::LowerTypeTestsPass::run(), llvm::BranchProbabilityPrinterPass::run(), llvm::WholeProgramDevirtPass::run(), llvm::DominatorTreePrinterPass::run(), llvm::DominatorTreeVerifierPass::run(), llvm::FunctionToLoopPassAdaptor< LoopPassT >::run(), llvm::PredicateInfoPrinterPass::run(), llvm::PredicateInfoVerifierPass::run(), llvm::GVNHoistPass::run(), llvm::GVNSinkPass::run(), llvm::CallGraphPrinterPass::run(), llvm::ModuleToPostOrderCGSCCPassAdaptor< CGSCCPassT >::run(), llvm::PrintLoopPass::run(), llvm::PassManager< Function >::run(), llvm::CGSCCToFunctionPassAdaptor< FunctionPassT >::run(), llvm::DevirtSCCRepeatedPass< PassT >::run(), llvm::DependenceAnalysisPrinterPass::run(), llvm::MemorySSAPrinterPass::run(), llvm::MemorySSAVerifierPass::run(), llvm::LoopPrinterPass::run(), llvm::LoopVerifierPass::run(), llvm::RegionInfoPrinterPass::run(), llvm::RegionInfoVerifierPass::run(), llvm::LazyCallGraphPrinterPass::run(), llvm::ModuleToFunctionPassAdaptor< FunctionPassT >::run(), llvm::LazyCallGraphDOTPrinterPass::run(), llvm::RequireAnalysisPass< AnalysisT, IRUnitT, AnalysisManagerT, ExtraArgTs >::run(), llvm::InvalidateAnalysisPass< AnalysisT >::run(), llvm::RepeatedPass< PassT >::run(), llvm::ScalarEvolutionPrinterPass::run(), and updateNewSCCFunctionAnalyses().

◆ allAnalysesInSetPreserved() [1/2]

template<typename AnalysisSetT >
bool llvm::PreservedAnalyses::allAnalysesInSetPreserved ( ) const
inline

Directly test whether a set of analyses is preserved.

This is only true when no analyses have been explicitly abandoned.

Definition at line 330 of file PassManager.h.

Referenced by llvm::FunctionAnalysisManagerCGSCCProxy::Result::invalidate(), llvm::AnalysisManager< IRUnitT, ExtraArgTs >::invalidate(), and llvm::PassManager< Function >::run().

◆ allAnalysesInSetPreserved() [2/2]

bool llvm::PreservedAnalyses::allAnalysesInSetPreserved ( AnalysisSetKey SetID) const
inline

Directly test whether a set of analyses is preserved.

This is only true when no analyses have been explicitly abandoned.

Definition at line 337 of file PassManager.h.

◆ allInSet()

template<typename AnalysisSetT >
static PreservedAnalyses llvm::PreservedAnalyses::allInSet ( )
inlinestatic

Construct a preserved analyses object with a single preserved set.

Definition at line 168 of file PassManager.h.

References preserveSet().

◆ areAllPreserved()

bool llvm::PreservedAnalyses::areAllPreserved ( ) const
inline

Test whether all analyses are preserved (and none are abandoned).

This is used primarily to optimize for the common case of a transformation which makes no changes to the IR.

Definition at line 322 of file PassManager.h.

Referenced by intersect(), llvm::FunctionAnalysisManagerCGSCCProxy::Result::invalidate(), llvm::PassManager< Function >::run(), llvm::ReassociatePass::run(), and llvm::sroa::SROALegacyPass::runOnFunction().

◆ getChecker() [1/2]

template<typename AnalysisT >
PreservedAnalysisChecker llvm::PreservedAnalyses::getChecker ( ) const
inline

◆ getChecker() [2/2]

PreservedAnalysisChecker llvm::PreservedAnalyses::getChecker ( AnalysisKey ID) const
inline

Build a checker for this PreservedAnalyses and the specified analysis ID.

You can use the returned object to query whether an analysis was preserved. See the example in the comment on PreservedAnalysis.

Definition at line 314 of file PassManager.h.

◆ intersect() [1/2]

void llvm::PreservedAnalyses::intersect ( const PreservedAnalyses Arg)
inline

Intersect this set with another in place.

This is a mutating operation on this preserved set, removing all preserved passes which are not also preserved in the argument.

Definition at line 226 of file PassManager.h.

References areAllPreserved(), Arg, and llvm::SmallPtrSetImpl< PtrType >::count().

Referenced by llvm::PassManager< Function >::run(), llvm::CGSCCToFunctionPassAdaptor< FunctionPassT >::run(), and llvm::DevirtSCCRepeatedPass< PassT >::run().

◆ intersect() [2/2]

void llvm::PreservedAnalyses::intersect ( PreservedAnalyses &&  Arg)
inline

Intersect this set with a temporary other set in place.

This is a mutating operation on this preserved set, removing all preserved passes which are not also preserved in the argument.

Definition at line 248 of file PassManager.h.

References Arg.

◆ none()

static PreservedAnalyses llvm::PreservedAnalyses::none ( )
inlinestatic

Convenience factory function for the empty preserved set.

Definition at line 157 of file PassManager.h.

Referenced by INITIALIZE_PASS(), llvm::BoundsCheckingPass::run(), llvm::LowerGuardIntrinsicPass::run(), llvm::GCOVProfilerPass::run(), llvm::CrossDSOCFIPass::run(), llvm::ForceFunctionAttrsPass::run(), llvm::LowerInvokePass::run(), llvm::HotColdSplittingPass::run(), llvm::PreISelIntrinsicLoweringPass::run(), llvm::LowerAtomicPass::run(), llvm::PartiallyInlineLibCallsPass::run(), llvm::ScalarizerPass::run(), llvm::CanonicalizeAliasesPass::run(), llvm::AddDiscriminatorsPass::run(), llvm::InferFunctionAttrsPass::run(), llvm::PartialInlinerPass::run(), llvm::StripDeadPrototypesPass::run(), llvm::EliminateAvailableExternallyPass::run(), llvm::NameAnonGlobalPass::run(), llvm::GlobalOptPass::run(), llvm::GlobalSplitPass::run(), llvm::ThreadSanitizerPass::run(), llvm::ArgumentPromotionPass::run(), llvm::GlobalDCEPass::run(), llvm::ConstantMergePass::run(), llvm::LowerExpectIntrinsicPass::run(), llvm::PGOInstrumentationGen::run(), llvm::SampleProfileLoaderPass::run(), llvm::AlwaysInlinerPass::run(), llvm::MemorySanitizerPass::run(), llvm::InstrProfiling::run(), llvm::PGOInstrumentationUse::run(), llvm::PostOrderFunctionAttrsPass::run(), llvm::PGOIndirectCallPromotion::run(), llvm::DeadArgumentEliminationPass::run(), llvm::FunctionImportPass::run(), llvm::RewriteSymbolPass::run(), llvm::LowerTypeTestsPass::run(), llvm::WholeProgramDevirtPass::run(), and llvm::InvalidateAllAnalysesPass::run().

◆ preserve() [1/2]

template<typename AnalysisT >
void llvm::PreservedAnalyses::preserve ( )
inline

◆ preserve() [2/2]

void llvm::PreservedAnalyses::preserve ( AnalysisKey ID)
inline

Given an analysis's ID, mark the analysis as preserved, adding it to the set.

Definition at line 179 of file PassManager.h.

◆ preserveSet() [1/2]

template<typename AnalysisSetT >
void llvm::PreservedAnalyses::preserveSet ( )
inline

◆ preserveSet() [2/2]

void llvm::PreservedAnalyses::preserveSet ( AnalysisSetKey ID)
inline

Mark an analysis set as preserved using its ID.

Definition at line 195 of file PassManager.h.


The documentation for this class was generated from the following files: