================ @@ -0,0 +1,419 @@ +//===------ PhaseManager.cpp ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "polly/Pass/PhaseManager.h" +#include "polly/CodeGen/CodeGeneration.h" +#include "polly/CodeGen/IslAst.h" +#include "polly/CodePreparation.h" +#include "polly/DeLICM.h" +#include "polly/DeadCodeElimination.h" +#include "polly/DependenceInfo.h" +#include "polly/FlattenSchedule.h" +#include "polly/ForwardOpTree.h" +#include "polly/JSONExporter.h" +#include "polly/MaximalStaticExpansion.h" +#include "polly/PruneUnprofitable.h" +#include "polly/ScheduleOptimizer.h" +#include "polly/ScopDetection.h" +#include "polly/ScopDetectionDiagnostic.h" +#include "polly/ScopGraphPrinter.h" +#include "polly/ScopInfo.h" +#include "polly/Simplify.h" +#include "llvm/Analysis/AssumptionCache.h" +#include "llvm/Analysis/OptimizationRemarkEmitter.h" +#include "llvm/IR/Module.h" + +#define DEBUG_TYPE "polly-pass" + +using namespace polly; +using namespace llvm; + +namespace { + +/// Recurse through all subregions and all regions and add them to RQ. +static void addRegionIntoQueue(Region &R, SmallVector<Region *> &RQ) { + RQ.push_back(&R); + for (const auto &E : R) + addRegionIntoQueue(*E, RQ); +} + +/// The phase pipeline of Polly to be embedded into another pass manager than +/// runs passes on functions. +/// +/// Polly holds state besides LLVM-IR (RegionInfo and ScopInfo) between phases +/// that LLVM pass managers do not consider when scheduling analyses and passes. +/// That is, the ScopInfo must persist between phases that a pass manager must +/// not invalidate to recompute later. +class PhaseManager { +private: + Function &F; + FunctionAnalysisManager &FAM; + PollyPassOptions Opts; + +public: + PhaseManager(Function &F, FunctionAnalysisManager &FAM, PollyPassOptions Opts) + : F(F), FAM(FAM), Opts(std::move(Opts)) {} + + /// Execute Polly's phases as indicated by the options. + bool run() { + // Get analyses from the function pass manager. + // These must be preserved during all phases so that if processing one SCoP + // has finished, the next SCoP can still use them. Recomputing is not an + // option because ScopDetection stores references to the old results. + // TODO: CodePreparation doesn't actually need these analysis, it just keeps + // them up-to-date. If they are not computed yet, can also compute after the + // prepare phase. + auto &LI = FAM.getResult<LoopAnalysis>(F); + auto &DT = FAM.getResult<DominatorTreeAnalysis>(F); + bool ModifiedIR = false; + + // Phase: prepare + // TODO: Setting ModifiedIR will invalidate any anlysis, even if DT, LI are + // preserved. + if (Opts.isPhaseEnabled(PassPhase::Prepare)) + ModifiedIR |= runCodePreparation(F, &DT, &LI, nullptr); + ---------------- Meinersbur wrote:
I agree, analyses that CodePreparation does not preserve should be barred from being used in later phases. https://github.com/llvm/llvm-project/pull/125442 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits