[llvm] 3aab3fe - [NPM][NFC] Chain PreservedAnalyses methods (#129505)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 3 20:53:05 PST 2025
Author: Akshat Oke
Date: 2025-03-04T10:23:01+05:30
New Revision: 3aab3fe56fbd60b49a47ae0f90d96de2cd09fc18
URL: https://github.com/llvm/llvm-project/commit/3aab3fe56fbd60b49a47ae0f90d96de2cd09fc18
DIFF: https://github.com/llvm/llvm-project/commit/3aab3fe56fbd60b49a47ae0f90d96de2cd09fc18.diff
LOG: [NPM][NFC] Chain PreservedAnalyses methods (#129505)
Added:
Modified:
llvm/include/llvm/IR/Analysis.h
llvm/lib/CodeGen/MachineScheduler.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Analysis.h b/llvm/include/llvm/IR/Analysis.h
index 6c80c771d40b4..dd43f5ee5f706 100644
--- a/llvm/include/llvm/IR/Analysis.h
+++ b/llvm/include/llvm/IR/Analysis.h
@@ -128,11 +128,14 @@ class PreservedAnalyses {
}
/// Mark an analysis as preserved.
- template <typename AnalysisT> void preserve() { preserve(AnalysisT::ID()); }
+ template <typename AnalysisT> PreservedAnalyses &preserve() {
+ preserve(AnalysisT::ID());
+ return *this;
+ }
/// Given an analysis's ID, mark the analysis as preserved, adding it
/// to the set.
- void preserve(AnalysisKey *ID) {
+ PreservedAnalyses &preserve(AnalysisKey *ID) {
// Clear this ID from the explicit not-preserved set if present.
NotPreservedAnalysisIDs.erase(ID);
@@ -140,18 +143,21 @@ class PreservedAnalyses {
// NotPreservedAnalysisIDs).
if (!areAllPreserved())
PreservedIDs.insert(ID);
+ return *this;
}
/// Mark an analysis set as preserved.
- template <typename AnalysisSetT> void preserveSet() {
+ template <typename AnalysisSetT> PreservedAnalyses &preserveSet() {
preserveSet(AnalysisSetT::ID());
+ return *this;
}
/// Mark an analysis set as preserved using its ID.
- void preserveSet(AnalysisSetKey *ID) {
+ PreservedAnalyses &preserveSet(AnalysisSetKey *ID) {
// If we're not already in the saturated 'all' state, add this set.
if (!areAllPreserved())
PreservedIDs.insert(ID);
+ return *this;
}
/// Mark an analysis as abandoned.
@@ -161,7 +167,10 @@ class PreservedAnalyses {
///
/// Note that you can only abandon a specific analysis, not a *set* of
/// analyses.
- template <typename AnalysisT> void abandon() { abandon(AnalysisT::ID()); }
+ template <typename AnalysisT> PreservedAnalyses &abandon() {
+ abandon(AnalysisT::ID());
+ return *this;
+ }
/// Mark an analysis as abandoned using its ID.
///
@@ -170,9 +179,10 @@ class PreservedAnalyses {
///
/// Note that you can only abandon a specific analysis, not a *set* of
/// analyses.
- void abandon(AnalysisKey *ID) {
+ PreservedAnalyses &abandon(AnalysisKey *ID) {
PreservedIDs.erase(ID);
NotPreservedAnalysisIDs.insert(ID);
+ return *this;
}
/// Intersect this set with another in place.
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 4ee8e12bf276c..0c0c616aac660 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -602,11 +602,10 @@ MachineSchedulerPass::run(MachineFunction &MF,
if (!Changed)
return PreservedAnalyses::all();
- PreservedAnalyses PA = getMachineFunctionPassPreservedAnalyses();
- PA.preserveSet<CFGAnalyses>();
- PA.preserve<SlotIndexesAnalysis>();
- PA.preserve<LiveIntervalsAnalysis>();
- return PA;
+ return getMachineFunctionPassPreservedAnalyses()
+ .preserveSet<CFGAnalyses>()
+ .preserve<SlotIndexesAnalysis>()
+ .preserve<LiveIntervalsAnalysis>();
}
bool PostMachineSchedulerLegacy::runOnMachineFunction(MachineFunction &MF) {
More information about the llvm-commits
mailing list