class PreservedAnalyses

Declaration

class PreservedAnalyses { /* full declaration omitted */ };

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

Declared at: llvm/include/llvm/IR/PassManager.h:152

Member Variables

private SmallPtrSet<void*, 2> PreservedIDs
The IDs of analyses and analysis sets that are preserved.
private SmallPtrSet<llvm::AnalysisKey*, 2> NotPreservedAnalysisIDs
Also, a given ID should never occur both here and in `PreservedIDs`.
private static llvm::AnalysisSetKey AllAnalysesKey
A special key used to indicate all analyses.

Method Overview

  • public void abandon(llvm::AnalysisKey * ID)
  • public template <typename AnalysisT>void abandon()
  • public static llvm::PreservedAnalyses all()
  • public bool allAnalysesInSetPreserved(llvm::AnalysisSetKey * SetID) const
  • public template <typename AnalysisSetT>bool allAnalysesInSetPreserved() const
  • public template <typename AnalysisSetT>static llvm::PreservedAnalyses allInSet()
  • public bool areAllPreserved() const
  • public llvm::PreservedAnalyses::PreservedAnalysisChecker getChecker(llvm::AnalysisKey * ID) const
  • public template <typename AnalysisT>llvm::PreservedAnalyses::PreservedAnalysisChecker getChecker() const
  • public void intersect(const llvm::PreservedAnalyses & Arg)
  • public void intersect(llvm::PreservedAnalyses && Arg)
  • public static llvm::PreservedAnalyses none()
  • public void preserve(llvm::AnalysisKey * ID)
  • public template <typename AnalysisT>void preserve()
  • public void preserveSet(llvm::AnalysisSetKey * ID)
  • public template <typename AnalysisSetT>void preserveSet()

Methods

void abandon(llvm::AnalysisKey* ID)

Description

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.

Declared at: llvm/include/llvm/IR/PassManager.h:215

Parameters

llvm::AnalysisKey* ID

template <typename AnalysisT>
void abandon()

Description

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.

Declared at: llvm/include/llvm/IR/PassManager.h:206

Templates

AnalysisT

static llvm::PreservedAnalyses all()

Description

Construct a special preserved set that preserves all passes.

Declared at: llvm/include/llvm/IR/PassManager.h:158

bool allAnalysesInSetPreserved(
    llvm::AnalysisSetKey* SetID) const

Description

Directly test whether a set of analyses is preserved. This is only true when no analyses have been explicitly abandoned.

Declared at: llvm/include/llvm/IR/PassManager.h:342

Parameters

llvm::AnalysisSetKey* SetID

template <typename AnalysisSetT>
bool allAnalysesInSetPreserved() const

Description

Directly test whether a set of analyses is preserved. This is only true when no analyses have been explicitly abandoned.

Declared at: llvm/include/llvm/IR/PassManager.h:335

Templates

AnalysisSetT

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

Description

Construct a preserved analyses object with a single preserved set.

Declared at: llvm/include/llvm/IR/PassManager.h:166

Templates

AnalysisSetT

bool areAllPreserved() const

Description

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.

Declared at: llvm/include/llvm/IR/PassManager.h:327

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

Description

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

Declared at: llvm/include/llvm/IR/PassManager.h:319

Parameters

llvm::AnalysisKey* ID

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

Description

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

Declared at: llvm/include/llvm/IR/PassManager.h:310

Templates

AnalysisT

void intersect(const llvm::PreservedAnalyses& Arg)

Description

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.

Declared at: llvm/include/llvm/IR/PassManager.h:224

Parameters

const llvm::PreservedAnalyses& Arg

void intersect(llvm::PreservedAnalyses&& Arg)

Description

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.

Declared at: llvm/include/llvm/IR/PassManager.h:246

Parameters

llvm::PreservedAnalyses&& Arg

static llvm::PreservedAnalyses none()

Description

Convenience factory function for the empty preserved set.

Declared at: llvm/include/llvm/IR/PassManager.h:155

void preserve(llvm::AnalysisKey* ID)

Description

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

Declared at: llvm/include/llvm/IR/PassManager.h:177

Parameters

llvm::AnalysisKey* ID

template <typename AnalysisT>
void preserve()

Description

Mark an analysis as preserved.

Declared at: llvm/include/llvm/IR/PassManager.h:173

Templates

AnalysisT

void preserveSet(llvm::AnalysisSetKey* ID)

Description

Mark an analysis set as preserved using its ID.

Declared at: llvm/include/llvm/IR/PassManager.h:193

Parameters

llvm::AnalysisSetKey* ID

template <typename AnalysisSetT>
void preserveSet()

Description

Mark an analysis set as preserved.

Declared at: llvm/include/llvm/IR/PassManager.h:188

Templates

AnalysisSetT