LLVM  6.0.0svn
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 153 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 207 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 216 of file PassManager.h.

◆ all()

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

Construct a special preserved set that preserves all passes.

Definition at line 159 of file PassManager.h.

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

Referenced by getTypePartition(), INITIALIZE_PASS(), isOptimizingForSize(), llvm::ExpandReductionsPass::run(), llvm::BoundsCheckingPass::run(), llvm::CorrelatedValuePropagationPass::run(), llvm::LibCallsShrinkWrapPass::run(), llvm::LowerGuardIntrinsicPass::run(), llvm::PreISelIntrinsicLoweringPass::run(), llvm::GCOVProfilerPass::run(), llvm::CrossDSOCFIPass::run(), llvm::LowerInvokePass::run(), llvm::CallSiteSplittingPass::run(), llvm::DCEPass::run(), llvm::IVUsersPrinterPass::run(), llvm::LoopAccessInfoPrinterPass::run(), llvm::LowerAtomicPass::run(), llvm::ForceFunctionAttrsPass::run(), llvm::PromotePass::run(), llvm::DivRemPairsPass::run(), llvm::ArgumentPromotionPass::run(), llvm::PartiallyInlineLibCallsPass::run(), llvm::SinkingPass::run(), llvm::BreakCriticalEdgesPass::run(), llvm::InferFunctionAttrsPass::run(), llvm::PartialInlinerPass::run(), llvm::InstSimplifierPass::run(), llvm::StripDeadPrototypesPass::run(), llvm::BDCEPass::run(), llvm::Float2IntPass::run(), llvm::GuardWideningPass::run(), llvm::LoopPredicationPass::run(), llvm::LoopRotatePass::run(), llvm::NewGVNPass::run(), llvm::AddDiscriminatorsPass::run(), llvm::NameAnonGlobalPass::run(), llvm::IndVarSimplifyPass::run(), llvm::LoopDataPrefetchPass::run(), llvm::LoopDistributePass::run(), llvm::LoopInstSimplifyPass::run(), llvm::EliminateAvailableExternallyPass::run(), llvm::GlobalOptPass::run(), llvm::LoopDeletionPass::run(), llvm::LoopLoadEliminationPass::run(), llvm::LoopSimplifyCFGPass::run(), llvm::LoopFullUnrollPass::run(), llvm::GlobalSplitPass::run(), llvm::AlignmentFromAssumptionsPass::run(), llvm::LoopIdiomRecognizePass::run(), llvm::SampleProfileLoaderPass::run(), llvm::DSEPass::run(), llvm::AlwaysInlinerPass::run(), llvm::CalledValuePropagationPass::run(), llvm::RewriteStatepointsForGC::run(), llvm::GlobalDCEPass::run(), llvm::ConstantMergePass::run(), llvm::LowerExpectIntrinsicPass::run(), llvm::CFGViewerPass::run(), llvm::UnreachableBlockElimPass::run(), llvm::ADCEPass::run(), llvm::PGOInstrumentationGen::run(), llvm::SCCPPass::run(), llvm::IPSCCPPass::run(), llvm::MergedLoadStoreMotionPass::run(), llvm::EarlyCSEPass::run(), llvm::ThinLTOBitcodeWriterPass::run(), llvm::LoopStrengthReducePass::run(), llvm::LoopSinkPass::run(), llvm::InstCombinePass::run(), llvm::LCSSAPass::run(), llvm::InstrProfiling::run(), llvm::PGOInstrumentationUse::run(), llvm::LoopUnrollPass::run(), llvm::SimpleLoopUnswitchPass::run(), llvm::LICMPass::run(), llvm::MemCpyOptPass::run(), llvm::SimplifyCFGPass::run(), llvm::PostOrderFunctionAttrsPass::run(), llvm::LoopSimplifyPass::run(), llvm::PGOIndirectCallPromotion::run(), llvm::AAEvaluator::run(), llvm::PostDominatorTreePrinterPass::run(), llvm::TailCallElimPass::run(), llvm::PGOMemOPSizeOpt::run(), llvm::InternalizePass::run(), llvm::BitcodeWriterPass::run(), llvm::PrintModulePass::run(), llvm::FunctionImportPass::run(), llvm::ReversePostOrderFunctionAttrsPass::run(), llvm::GVN::run(), llvm::SpeculativeExecutionPass::run(), llvm::SLPVectorizerPass::run(), llvm::DeadArgumentEliminationPass::run(), llvm::ReassociatePass::run(), llvm::PrintFunctionPass::run(), llvm::LoopVectorizePass::run(), llvm::RequireAnalysisPass< AnalysisT, Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::run(), llvm::InlinerPass::run(), llvm::NaryReassociatePass::run(), llvm::SpeculateAroundPHIsPass::run(), llvm::ConstantHoistingPass::run(), llvm::DemandedBitsPrinterPass::run(), llvm::JumpThreadingPass::run(), llvm::RewriteSymbolPass::run(), llvm::BlockFrequencyPrinterPass::run(), llvm::VerifierPass::run(), llvm::RequireAnalysisPass< AnalysisT, LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & >::run(), llvm::ProfileSummaryPrinterPass::run(), llvm::AssumptionPrinterPass::run(), llvm::LowerTypeTestsPass::run(), llvm::DominanceFrontierPrinterPass::run(), llvm::WholeProgramDevirtPass::run(), llvm::BranchProbabilityPrinterPass::run(), llvm::DominatorTreePrinterPass::run(), llvm::DominatorTreeVerifierPass::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::MemorySSAPrinterPass::run(), llvm::MemorySSAVerifierPass::run(), llvm::LoopPrinterPass::run(), llvm::LoopVerifierPass::run(), llvm::RegionInfoPrinterPass::run(), llvm::RegionInfoVerifierPass::run(), llvm::ModuleToFunctionPassAdaptor< FunctionPassT >::run(), llvm::RequireAnalysisPass< AnalysisT, IRUnitT, AnalysisManagerT, ExtraArgTs >::run(), llvm::LazyCallGraphPrinterPass::run(), llvm::InvalidateAnalysisPass< AnalysisT >::run(), llvm::LazyCallGraphDOTPrinterPass::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 329 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 336 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 167 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 321 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 313 of file PassManager.h.

◆ intersect() [1/2]

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

◆ 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 247 of file PassManager.h.

References Arg.

◆ none()

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

◆ 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 178 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 194 of file PassManager.h.


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