Skip to content

[Pass] Convert methods in PreservedAnalyses to variadic template #130749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions llvm/include/llvm/IR/Analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ class PreservedAnalyses {
return PA;
}

/// Mark an analysis as preserved.
template <typename AnalysisT> PreservedAnalyses &preserve() {
preserve(AnalysisT::ID());
return *this;
/// Mark analyses as preserved.
template <typename... AnalysisTs> PreservedAnalyses &preserve() {
return preserve(AnalysisTs::ID()...);
}

/// Given an analysis's ID, mark the analysis as preserved, adding it
Expand All @@ -146,10 +145,15 @@ class PreservedAnalyses {
return *this;
}

/// Mark an analysis set as preserved.
template <typename AnalysisSetT> PreservedAnalyses &preserveSet() {
preserveSet(AnalysisSetT::ID());
return *this;
/// Mark analyses as preserved using IDs.
template <typename... AnalysisKeyPtrs>
PreservedAnalyses &preserve(AnalysisKeyPtrs... IDs) {
return (preserve(IDs), ..., *this);
}

/// Mark analysis sets as preserved.
template <typename... AnalysisSetTs> PreservedAnalyses &preserveSet() {
return preserveSet(AnalysisSetTs::ID()...);
}

/// Mark an analysis set as preserved using its ID.
Expand All @@ -160,16 +164,21 @@ class PreservedAnalyses {
return *this;
}

/// Mark an analysis as abandoned.
/// Mark analysis sets as preserved using IDs.
template <typename... AnalysisSetKeyPtrs>
PreservedAnalyses &preserveSet(AnalysisSetKeyPtrs... IDs) {
return (preserveSet(IDs), ..., *this);
}

/// Mark an analyses 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.
template <typename AnalysisT> PreservedAnalyses &abandon() {
abandon(AnalysisT::ID());
return *this;
template <typename... AnalysisTs> PreservedAnalyses &abandon() {
return abandon(AnalysisTs::ID()...);
}

/// Mark an analysis as abandoned using its ID.
Expand All @@ -185,6 +194,12 @@ class PreservedAnalyses {
return *this;
}

/// Mark analyses as abandoned using IDs.
template <typename... AnalysisKeyPtrs>
PreservedAnalyses &abandon(AnalysisKeyPtrs... IDs) {
return (abandon(IDs), ..., *this);
}

/// Intersect this set with another in place.
///
/// This is a mutating operation on this preserved set, removing all
Expand Down