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

Synopsis

Declared in <llvm/IR/Analysis.h>

class PreservedAnalyses;

Description

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 ... } `

Types

Name

Description

PreservedAnalysisChecker

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

Member Functions

Name

Description

abandon

abandon overloads

allAnalysesInSetPreserved

Directly test whether a set of analyses is preserved.

areAllPreserved

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

getChecker

getChecker overloads

intersect

intersect overloads

preserve

preserve overloads

preserveSet

preserveSet overloads

Static Member Functions

Name

Description

all

Construct a special preserved set that preserves all passes.

allInSet

Construct a preserved analyses object with a single preserved set.

none

Convenience factory function for the empty preserved set.

Non-Member Functions

Name

Description

getLoopPassPreservedAnalyses

Returns the minimum set of Analyses that all loop passes must preserve.

getMachineFunctionPassPreservedAnalyses

Returns the minimum set of Analyses that all machine function passes must preserve.

Created with MrDocs