diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-03-20 11:40:34 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-06-04 11:58:51 +0000 |
| commit | 4b6eb0e63c698094db5506763df44cc83c19f643 (patch) | |
| tree | f1d30b8c10bc6db323b91538745ae8ab8b593910 /contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopPassManager.cpp | |
| parent | 76886853f03395abb680824bcc74e98f83bd477a (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopPassManager.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopPassManager.cpp | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopPassManager.cpp b/contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopPassManager.cpp index f4fce4871331..3df4cfe8e4c1 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopPassManager.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Scalar/LoopPassManager.cpp @@ -10,6 +10,7 @@ #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/BasicAliasAnalysis.h" #include "llvm/Analysis/BlockFrequencyInfo.h" +#include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" @@ -44,6 +45,18 @@ PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, return PA; } +void PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, + LPMUpdater &>::printPipeline(raw_ostream &OS, + function_ref<StringRef(StringRef)> + MapClassName2PassName) { + for (unsigned Idx = 0, Size = LoopPasses.size(); Idx != Size; ++Idx) { + auto *P = LoopPasses[Idx].get(); + P->printPipeline(OS, MapClassName2PassName); + if (Idx + 1 < Size) + OS << ","; + } +} + // Run both loop passes and loop-nest passes on top-level loop \p L. PreservedAnalyses LoopPassManager::runWithLoopNestPasses(Loop &L, LoopAnalysisManager &AM, @@ -112,12 +125,6 @@ LoopPassManager::runWithLoopNestPasses(Loop &L, LoopAnalysisManager &AM, // notify the updater, otherwise U.ParentL might gets outdated and triggers // assertion failures in addSiblingLoops and addChildLoops. U.setParentLoop(L.getParentLoop()); - - // FIXME: Historically, the pass managers all called the LLVM context's - // yield function here. We don't have a generic way to acquire the - // context and it isn't yet clear what the right pattern is for yielding - // in the new pass manager so it is currently omitted. - // ...getContext().yield(); } return PA; } @@ -161,17 +168,17 @@ LoopPassManager::runWithoutLoopNestPasses(Loop &L, LoopAnalysisManager &AM, // notify the updater, otherwise U.ParentL might gets outdated and triggers // assertion failures in addSiblingLoops and addChildLoops. U.setParentLoop(L.getParentLoop()); - - // FIXME: Historically, the pass managers all called the LLVM context's - // yield function here. We don't have a generic way to acquire the - // context and it isn't yet clear what the right pattern is for yielding - // in the new pass manager so it is currently omitted. - // ...getContext().yield(); } return PA; } } // namespace llvm +void FunctionToLoopPassAdaptor::printPipeline( + raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) { + OS << (UseMemorySSA ? "loop-mssa(" : "loop("); + Pass->printPipeline(OS, MapClassName2PassName); + OS << ")"; +} PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F, FunctionAnalysisManager &AM) { // Before we even compute any loop analyses, first run a miniature function @@ -201,6 +208,10 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F, BlockFrequencyInfo *BFI = UseBlockFrequencyInfo && F.hasProfileData() ? (&AM.getResult<BlockFrequencyAnalysis>(F)) : nullptr; + BranchProbabilityInfo *BPI = + UseBranchProbabilityInfo && F.hasProfileData() + ? (&AM.getResult<BranchProbabilityAnalysis>(F)) + : nullptr; LoopStandardAnalysisResults LAR = {AM.getResult<AAManager>(F), AM.getResult<AssumptionAnalysis>(F), AM.getResult<DominatorTreeAnalysis>(F), @@ -209,6 +220,7 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F, AM.getResult<TargetLibraryAnalysis>(F), AM.getResult<TargetIRAnalysis>(F), BFI, + BPI, MSSA}; // Setup the loop analysis manager from its proxy. It is important that @@ -285,6 +297,10 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F, else PI.runAfterPass<Loop>(*Pass, *L, PassPA); + if (LAR.MSSA && !PassPA.getChecker<MemorySSAAnalysis>().preserved()) + report_fatal_error("Loop pass manager using MemorySSA contains a pass " + "that does not preserve MemorySSA"); + #ifndef NDEBUG // LoopAnalysisResults should always be valid. // Note that we don't LAR.SE.verify() because that can change observed SE @@ -325,6 +341,8 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F, PA.preserve<ScalarEvolutionAnalysis>(); if (UseBlockFrequencyInfo && F.hasProfileData()) PA.preserve<BlockFrequencyAnalysis>(); + if (UseBranchProbabilityInfo && F.hasProfileData()) + PA.preserve<BranchProbabilityAnalysis>(); if (UseMemorySSA) PA.preserve<MemorySSAAnalysis>(); return PA; |
