[polly] r311888 - [PM] Properly require and preserve OptimizationRemarkEmitter. NFCI.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 28 07:07:33 PDT 2017
Author: meinersbur
Date: Mon Aug 28 07:07:33 2017
New Revision: 311888
URL: http://llvm.org/viewvc/llvm-project?rev=311888&view=rev
Log:
[PM] Properly require and preserve OptimizationRemarkEmitter. NFCI.
Properly require and preserve the OptimizationRemarkEmitter for use in
ScopPass. Previously one had to get the ORE from ScopDetection because
CodeGeneration did not mark it as preserved. It would need to be
recomputed which results in the legacy PM to throw away all previous
SCoP analysis.
This also changes the implementation of ScopPass::getAnalysisUsage to
not unconditionally preserve all passes, but only those needed to be
preserved by any SCoP pass (at least when using the legacy PM). This
allows invalidating DependenceInfo (and IslAstInfo) in case the pass
would cause them to change (e.g. OpTree, DeLICM, MaximalArrayExpansion)
JSONImporter should also invalidate the DependenceInfo. In this patch
it marks DependenceInfo as preserved anyway because some regression
tests depend on it.
Differential Revision: https://reviews.llvm.org/D37010
Modified:
polly/trunk/include/polly/ScopBuilder.h
polly/trunk/include/polly/ScopDetection.h
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopBuilder.cpp
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/lib/Analysis/ScopPass.cpp
polly/trunk/lib/CodeGen/CodeGeneration.cpp
polly/trunk/lib/CodeGen/IslAst.cpp
polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
polly/trunk/lib/Exchange/JSONExporter.cpp
polly/trunk/lib/Transform/ScheduleOptimizer.cpp
Modified: polly/trunk/include/polly/ScopBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopBuilder.h?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopBuilder.h (original)
+++ polly/trunk/include/polly/ScopBuilder.h Mon Aug 28 07:07:33 2017
@@ -143,7 +143,8 @@ class ScopBuilder {
// @}
// 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.
@@ -337,7 +338,8 @@ class ScopBuilder {
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(const ScopBuilder &) = delete;
ScopBuilder &operator=(const ScopBuilder &) = delete;
~ScopBuilder() = default;
Modified: polly/trunk/include/polly/ScopDetection.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetection.h?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetection.h (original)
+++ polly/trunk/include/polly/ScopDetection.h Mon Aug 28 07:07:33 2017
@@ -630,6 +630,7 @@ public:
countBeneficialLoops(Region *R, ScalarEvolution &SE, LoopInfo &LI,
unsigned MinProfitableTrips);
+private:
/// OptimizationRemarkEmitter object used to emit diagnostic remarks
OptimizationRemarkEmitter &ORE;
};
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Mon Aug 28 07:07:33 2017
@@ -3096,11 +3096,12 @@ private:
AliasAnalysis &AA;
DominatorTree &DT;
AssumptionCache ∾
+ 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.
///
Modified: polly/trunk/lib/Analysis/ScopBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopBuilder.cpp?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopBuilder.cpp (original)
+++ polly/trunk/lib/Analysis/ScopBuilder.cpp Mon Aug 28 07:07:33 2017
@@ -964,8 +964,9 @@ static inline BasicBlock *getRegionNodeB
: RN->getNodeAs<BasicBlock>();
}
-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();
@@ -1064,17 +1065,18 @@ void ScopBuilder::buildScop(Region &R, A
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;
auto P = getBBPairForRegion(R);
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);
@@ -1090,9 +1092,9 @@ ScopBuilder::ScopBuilder(Region *R, Assu
}
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);
}
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Mon Aug 28 07:07:33 2017
@@ -5230,6 +5230,7 @@ void ScopInfoRegionPass::getAnalysisUsag
AU.addRequiredTransitive<ScopDetectionWrapperPass>();
AU.addRequired<AAResultsWrapperPass>();
AU.addRequired<AssumptionCacheTracker>();
+ AU.addRequired<OptimizationRemarkEmitterWrapperPass>();
AU.setPreservesAll();
}
@@ -5279,8 +5280,9 @@ bool ScopInfoRegionPass::runOnRegion(Reg
auto const &DL = F->getParent()->getDataLayout();
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(*F);
+ auto &ORE = getAnalysis<OptimizationRemarkEmitterWrapperPass>().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 !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
@@ -5322,8 +5324,8 @@ INITIALIZE_PASS_END(ScopInfoRegionPass,
//===----------------------------------------------------------------------===//
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();
}
@@ -5336,7 +5338,7 @@ void ScopInfo::recompute() {
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<Scop> S = SB.getScop();
if (!S)
continue;
@@ -5376,7 +5378,8 @@ ScopInfoAnalysis::Result ScopInfoAnalysi
auto &DT = FAM.getResult<DominatorTreeAnalysis>(F);
auto &AC = FAM.getResult<AssumptionAnalysis>(F);
auto &DL = F.getParent()->getDataLayout();
- return {DL, SD, SE, LI, AA, DT, AC};
+ auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
+ return {DL, SD, SE, LI, AA, DT, AC, ORE};
}
PreservedAnalyses ScopInfoPrinterPass::run(Function &F,
@@ -5401,6 +5404,7 @@ void ScopInfoWrapperPass::getAnalysisUsa
AU.addRequiredTransitive<ScopDetectionWrapperPass>();
AU.addRequired<AAResultsWrapperPass>();
AU.addRequired<AssumptionCacheTracker>();
+ AU.addRequired<OptimizationRemarkEmitterWrapperPass>();
AU.setPreservesAll();
}
@@ -5412,8 +5416,9 @@ bool ScopInfoWrapperPass::runOnFunction(
auto const &DL = F.getParent()->getDataLayout();
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
+ auto &ORE = getAnalysis<OptimizationRemarkEmitterWrapperPass>().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;
}
Modified: polly/trunk/lib/Analysis/ScopPass.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopPass.cpp?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopPass.cpp (original)
+++ polly/trunk/lib/Analysis/ScopPass.cpp Mon Aug 28 07:07:33 2017
@@ -15,6 +15,11 @@
#include "polly/ScopInfo.h"
#include "llvm/Analysis/AssumptionCache.h"
+#include "llvm/Analysis/BasicAliasAnalysis.h"
+#include "llvm/Analysis/GlobalsModRef.h"
+#include "llvm/Analysis/OptimizationDiagnosticInfo.h"
+#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
using namespace llvm;
using namespace polly;
@@ -38,7 +43,19 @@ void ScopPass::print(raw_ostream &OS, co
void ScopPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<ScopInfoRegionPass>();
- AU.setPreservesAll();
+
+ AU.addPreserved<AAResultsWrapperPass>();
+ AU.addPreserved<BasicAAWrapperPass>();
+ AU.addPreserved<LoopInfoWrapperPass>();
+ AU.addPreserved<DominatorTreeWrapperPass>();
+ AU.addPreserved<GlobalsAAWrapperPass>();
+ AU.addPreserved<ScopDetectionWrapperPass>();
+ AU.addPreserved<ScalarEvolutionWrapperPass>();
+ AU.addPreserved<SCEVAAWrapperPass>();
+ AU.addPreserved<OptimizationRemarkEmitterWrapperPass>();
+ AU.addPreserved<RegionInfoPass>();
+ AU.addPreserved<ScopInfoRegionPass>();
+ AU.addPreserved<TargetTransformInfoWrapperPass>();
}
namespace polly {
Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Mon Aug 28 07:07:33 2017
@@ -333,6 +333,8 @@ public:
/// Register all analyses and transformation required.
void getAnalysisUsage(AnalysisUsage &AU) const override {
+ ScopPass::getAnalysisUsage(AU);
+
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<IslAstInfoWrapperPass>();
AU.addRequired<RegionInfoPass>();
@@ -342,21 +344,10 @@ public:
AU.addRequired<LoopInfoWrapperPass>();
AU.addPreserved<DependenceInfo>();
-
- AU.addPreserved<AAResultsWrapperPass>();
- AU.addPreserved<BasicAAWrapperPass>();
- AU.addPreserved<LoopInfoWrapperPass>();
- AU.addPreserved<DominatorTreeWrapperPass>();
- AU.addPreserved<GlobalsAAWrapperPass>();
AU.addPreserved<IslAstInfoWrapperPass>();
- AU.addPreserved<ScopDetectionWrapperPass>();
- AU.addPreserved<ScalarEvolutionWrapperPass>();
- AU.addPreserved<SCEVAAWrapperPass>();
// FIXME: We do not yet add regions for the newly generated code to the
// region tree.
- AU.addPreserved<RegionInfoPass>();
- AU.addPreserved<ScopInfoRegionPass>();
}
};
Modified: polly/trunk/lib/CodeGen/IslAst.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslAst.cpp?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslAst.cpp (original)
+++ polly/trunk/lib/CodeGen/IslAst.cpp Mon Aug 28 07:07:33 2017
@@ -771,6 +771,8 @@ void IslAstInfoWrapperPass::getAnalysisU
ScopPass::getAnalysisUsage(AU);
AU.addRequired<ScopInfoRegionPass>();
AU.addRequired<DependenceInfo>();
+
+ AU.addPreserved<DependenceInfo>();
}
void IslAstInfoWrapperPass::printScop(raw_ostream &OS, Scop &S) const {
Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Mon Aug 28 07:07:33 2017
@@ -3520,6 +3520,8 @@ public:
void printScop(raw_ostream &, Scop &) const override {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
+ ScopPass::getAnalysisUsage(AU);
+
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<RegionInfoPass>();
AU.addRequired<ScalarEvolutionWrapperPass>();
@@ -3527,19 +3529,8 @@ public:
AU.addRequired<ScopInfoRegionPass>();
AU.addRequired<LoopInfoWrapperPass>();
- AU.addPreserved<AAResultsWrapperPass>();
- AU.addPreserved<BasicAAWrapperPass>();
- AU.addPreserved<LoopInfoWrapperPass>();
- AU.addPreserved<DominatorTreeWrapperPass>();
- AU.addPreserved<GlobalsAAWrapperPass>();
- AU.addPreserved<ScopDetectionWrapperPass>();
- AU.addPreserved<ScalarEvolutionWrapperPass>();
- AU.addPreserved<SCEVAAWrapperPass>();
-
// FIXME: We do not yet add regions for the newly generated code to the
// region tree.
- AU.addPreserved<RegionInfoPass>();
- AU.addPreserved<ScopInfoRegionPass>();
}
};
} // namespace
Modified: polly/trunk/lib/Exchange/JSONExporter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/lib/Exchange/JSONExporter.cpp (original)
+++ polly/trunk/lib/Exchange/JSONExporter.cpp Mon Aug 28 07:07:33 2017
@@ -792,6 +792,9 @@ bool JSONImporter::runOnScop(Scop &S) {
void JSONImporter::getAnalysisUsage(AnalysisUsage &AU) const {
ScopPass::getAnalysisUsage(AU);
AU.addRequired<DependenceInfo>();
+
+ // TODO: JSONImporter should throw away DependenceInfo.
+ AU.addPreserved<DependenceInfo>();
}
Pass *polly::createJSONImporterPass() { return new JSONImporter(); }
Modified: polly/trunk/lib/Transform/ScheduleOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Transform/ScheduleOptimizer.cpp?rev=311888&r1=311887&r2=311888&view=diff
==============================================================================
--- polly/trunk/lib/Transform/ScheduleOptimizer.cpp (original)
+++ polly/trunk/lib/Transform/ScheduleOptimizer.cpp Mon Aug 28 07:07:33 2017
@@ -1591,6 +1591,8 @@ void IslScheduleOptimizer::getAnalysisUs
ScopPass::getAnalysisUsage(AU);
AU.addRequired<DependenceInfo>();
AU.addRequired<TargetTransformInfoWrapperPass>();
+
+ AU.addPreserved<DependenceInfo>();
}
Pass *polly::createIslScheduleOptimizerPass() {
More information about the llvm-commits
mailing list