LLVM  14.0.0git
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 155 of file PassManager.h.

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

References abandon().

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

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

## ◆ 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 345 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 169 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 330 of file PassManager.h.

## ◆ getChecker() [1/2]

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

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

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.

## ◆ 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 322 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 227 of file PassManager.h.

References Arg.

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

References Arg, and move.

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

## ◆ preserveSet() [2/2]

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

Mark an analysis set as preserved using its ID.

Definition at line 196 of file PassManager.h.

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