Index: include/polly/ScopBuilder.h =================================================================== --- include/polly/ScopBuilder.h +++ include/polly/ScopBuilder.h @@ -117,7 +117,8 @@ // @} // Build the SCoP for Region @p R. - void buildScop(Region &R, AssumptionCache &AC); + void buildScop(Region &R, AssumptionCache &AC, + OptimizationRemarkEmitter &ORE); /// Try to build a multi-dimensional fixed sized MemoryAccess from the /// Load/Store instruction. @@ -311,7 +312,8 @@ public: explicit ScopBuilder(Region *R, AssumptionCache &AC, AliasAnalysis &AA, const DataLayout &DL, DominatorTree &DT, LoopInfo &LI, - ScopDetection &SD, ScalarEvolution &SE); + ScopDetection &SD, ScalarEvolution &SE, + OptimizationRemarkEmitter &ORE); ~ScopBuilder() {} /// Try to build the Polly IR of static control part on the current Index: include/polly/ScopDetection.h =================================================================== --- include/polly/ScopDetection.h +++ include/polly/ScopDetection.h @@ -611,6 +611,7 @@ countBeneficialLoops(Region *R, ScalarEvolution &SE, LoopInfo &LI, unsigned MinProfitableTrips); +private: /// OptimizationRemarkEmitter object used to emit diagnostic remarks OptimizationRemarkEmitter &ORE; }; Index: include/polly/ScopInfo.h =================================================================== --- include/polly/ScopInfo.h +++ include/polly/ScopInfo.h @@ -3056,11 +3056,12 @@ AliasAnalysis &AA; DominatorTree &DT; AssumptionCache &AC; + OptimizationRemarkEmitter &ORE; public: ScopInfo(const DataLayout &DL, ScopDetection &SD, ScalarEvolution &SE, LoopInfo &LI, AliasAnalysis &AA, DominatorTree &DT, - AssumptionCache &AC); + AssumptionCache &AC, OptimizationRemarkEmitter &ORE); /// Get the Scop object for the given Region. /// Index: lib/Analysis/ScopBuilder.cpp =================================================================== --- lib/Analysis/ScopBuilder.cpp +++ lib/Analysis/ScopBuilder.cpp @@ -926,8 +926,9 @@ : RN->getNodeAs(); } -void ScopBuilder::buildScop(Region &R, AssumptionCache &AC) { - scop.reset(new Scop(R, SE, LI, *SD.getDetectionContext(&R), SD.ORE)); +void ScopBuilder::buildScop(Region &R, AssumptionCache &AC, + OptimizationRemarkEmitter &ORE) { + scop.reset(new Scop(R, SE, LI, *SD.getDetectionContext(&R), ORE)); buildStmts(R); buildAccessFunctions(); @@ -1026,7 +1027,8 @@ ScopBuilder::ScopBuilder(Region *R, AssumptionCache &AC, AliasAnalysis &AA, const DataLayout &DL, DominatorTree &DT, LoopInfo &LI, - ScopDetection &SD, ScalarEvolution &SE) + ScopDetection &SD, ScalarEvolution &SE, + OptimizationRemarkEmitter &ORE) : AA(AA), DL(DL), DT(DT), LI(LI), SD(SD), SE(SE) { DebugLoc Beg, End; @@ -1034,10 +1036,10 @@ getDebugLocations(P, Beg, End); std::string Msg = "SCoP begins here."; - SD.ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "ScopEntry", Beg, P.first) - << Msg); + ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "ScopEntry", Beg, P.first) + << Msg); - buildScop(*R, AC); + buildScop(*R, AC, ORE); DEBUG(dbgs() << *scop); @@ -1053,9 +1055,9 @@ } if (R->isTopLevelRegion()) - SD.ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "ScopEnd", End, P.first) - << Msg); + ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "ScopEnd", End, P.first) + << Msg); else - SD.ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "ScopEnd", End, P.second) - << Msg); + ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "ScopEnd", End, P.second) + << Msg); } Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -5152,6 +5152,7 @@ AU.addRequiredTransitive(); AU.addRequired(); AU.addRequired(); + AU.addRequired(); AU.setPreservesAll(); } @@ -5187,8 +5188,9 @@ auto const &DL = F->getParent()->getDataLayout(); auto &DT = getAnalysis().getDomTree(); auto &AC = getAnalysis().getAssumptionCache(*F); + auto &ORE = getAnalysis().getORE(); - ScopBuilder SB(R, AC, AA, DL, DT, LI, SD, SE); + ScopBuilder SB(R, AC, AA, DL, DT, LI, SD, SE, ORE); S = SB.getScop(); // take ownership of scop object if (S) { @@ -5228,8 +5230,8 @@ //===----------------------------------------------------------------------===// ScopInfo::ScopInfo(const DataLayout &DL, ScopDetection &SD, ScalarEvolution &SE, LoopInfo &LI, AliasAnalysis &AA, DominatorTree &DT, - AssumptionCache &AC) - : DL(DL), SD(SD), SE(SE), LI(LI), AA(AA), DT(DT), AC(AC) { + AssumptionCache &AC, OptimizationRemarkEmitter &ORE) + : DL(DL), SD(SD), SE(SE), LI(LI), AA(AA), DT(DT), AC(AC), ORE(ORE) { recompute(); } @@ -5242,7 +5244,7 @@ if (!SD.isMaxRegionInScop(*R)) continue; - ScopBuilder SB(R, AC, AA, DL, DT, LI, SD, SE); + ScopBuilder SB(R, AC, AA, DL, DT, LI, SD, SE, ORE); std::unique_ptr S = SB.getScop(); if (!S) continue; @@ -5280,7 +5282,8 @@ auto &DT = FAM.getResult(F); auto &AC = FAM.getResult(F); auto &DL = F.getParent()->getDataLayout(); - return {DL, SD, SE, LI, AA, DT, AC}; + auto &ORE = FAM.getResult(F); + return {DL, SD, SE, LI, AA, DT, AC, ORE}; } PreservedAnalyses ScopInfoPrinterPass::run(Function &F, @@ -5305,6 +5308,7 @@ AU.addRequiredTransitive(); AU.addRequired(); AU.addRequired(); + AU.addRequired(); AU.setPreservesAll(); } @@ -5316,8 +5320,9 @@ auto const &DL = F.getParent()->getDataLayout(); auto &DT = getAnalysis().getDomTree(); auto &AC = getAnalysis().getAssumptionCache(F); + auto &ORE = getAnalysis().getORE(); - Result.reset(new ScopInfo{DL, SD, SE, LI, AA, DT, AC}); + Result.reset(new ScopInfo{DL, SD, SE, LI, AA, DT, AC, ORE}); return false; } Index: lib/Analysis/ScopPass.cpp =================================================================== --- lib/Analysis/ScopPass.cpp +++ lib/Analysis/ScopPass.cpp @@ -15,6 +15,10 @@ #include "polly/ScopInfo.h" #include "llvm/Analysis/AssumptionCache.h" +#include "llvm/Analysis/BasicAliasAnalysis.h" +#include "llvm/Analysis/GlobalsModRef.h" +#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" +#include "llvm/Analysis/TargetTransformInfo.h" using namespace llvm; using namespace polly; @@ -38,7 +42,19 @@ void ScopPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); - AU.setPreservesAll(); + + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); } namespace polly { Index: lib/CodeGen/CodeGeneration.cpp =================================================================== --- lib/CodeGen/CodeGeneration.cpp +++ lib/CodeGen/CodeGeneration.cpp @@ -298,6 +298,8 @@ /// Register all analyses and transformation required. void getAnalysisUsage(AnalysisUsage &AU) const override { + ScopPass::getAnalysisUsage(AU); + AU.addRequired(); AU.addRequired(); AU.addRequired(); @@ -307,21 +309,10 @@ AU.addRequired(); AU.addPreserved(); - - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); // FIXME: We do not yet add regions for the newly generated code to the // region tree. - AU.addPreserved(); - AU.addPreserved(); } }; } // namespace Index: lib/CodeGen/IslAst.cpp =================================================================== --- lib/CodeGen/IslAst.cpp +++ lib/CodeGen/IslAst.cpp @@ -705,6 +705,8 @@ ScopPass::getAnalysisUsage(AU); AU.addRequired(); AU.addRequired(); + + AU.addPreserved(); } void IslAstInfoWrapperPass::printScop(raw_ostream &OS, Scop &S) const { Index: lib/CodeGen/PPCGCodeGeneration.cpp =================================================================== --- lib/CodeGen/PPCGCodeGeneration.cpp +++ lib/CodeGen/PPCGCodeGeneration.cpp @@ -3519,6 +3519,8 @@ void printScop(raw_ostream &, Scop &) const override {} void getAnalysisUsage(AnalysisUsage &AU) const override { + ScopPass::getAnalysisUsage(AU); + AU.addRequired(); AU.addRequired(); AU.addRequired(); @@ -3526,19 +3528,8 @@ AU.addRequired(); AU.addRequired(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - // FIXME: We do not yet add regions for the newly generated code to the // region tree. - AU.addPreserved(); - AU.addPreserved(); } }; } // namespace Index: lib/Exchange/JSONExporter.cpp =================================================================== --- lib/Exchange/JSONExporter.cpp +++ lib/Exchange/JSONExporter.cpp @@ -792,6 +792,9 @@ void JSONImporter::getAnalysisUsage(AnalysisUsage &AU) const { ScopPass::getAnalysisUsage(AU); AU.addRequired(); + + // TODO: JSONImporter should throw away DependenceInfo. + AU.addPreserved(); } Pass *polly::createJSONImporterPass() { return new JSONImporter(); } Index: lib/Transform/ScheduleOptimizer.cpp =================================================================== --- lib/Transform/ScheduleOptimizer.cpp +++ lib/Transform/ScheduleOptimizer.cpp @@ -1477,6 +1477,8 @@ ScopPass::getAnalysisUsage(AU); AU.addRequired(); AU.addRequired(); + + AU.addPreserved(); } Pass *polly::createIslScheduleOptimizerPass() {