forked from OSchip/llvm-project
[Polly] Decompose object construction and detection algorithm. NFC.
Avoid doing the detection work inside the constructor. In addition to polymorphism being unintuitive in constructors and other design problems such as if an exception is thrown, the ScopDetection class is usable without detection in the sense of "no Scop found" or "function skipped".
This commit is contained in:
parent
581a80304c
commit
0232c1d10d
|
@ -497,7 +497,7 @@ private:
|
|||
/// Check if the function @p F is marked as invalid.
|
||||
///
|
||||
/// @note An OpenMP subfunction will be marked as invalid.
|
||||
bool isValidFunction(Function &F);
|
||||
static bool isValidFunction(Function &F);
|
||||
|
||||
/// Can ISL compute the trip count of a loop.
|
||||
///
|
||||
|
@ -529,9 +529,10 @@ private:
|
|||
Args &&...Arguments) const;
|
||||
|
||||
public:
|
||||
ScopDetection(Function &F, const DominatorTree &DT, ScalarEvolution &SE,
|
||||
LoopInfo &LI, RegionInfo &RI, AAResults &AA,
|
||||
OptimizationRemarkEmitter &ORE);
|
||||
ScopDetection(const DominatorTree &DT, ScalarEvolution &SE, LoopInfo &LI,
|
||||
RegionInfo &RI, AAResults &AA, OptimizationRemarkEmitter &ORE);
|
||||
|
||||
void detect(Function &F);
|
||||
|
||||
/// Get the RegionInfo stored in this pass.
|
||||
///
|
||||
|
|
|
@ -333,10 +333,14 @@ static bool doesStringMatchAnyRegex(StringRef Str,
|
|||
//===----------------------------------------------------------------------===//
|
||||
// ScopDetection.
|
||||
|
||||
ScopDetection::ScopDetection(Function &F, const DominatorTree &DT,
|
||||
ScalarEvolution &SE, LoopInfo &LI, RegionInfo &RI,
|
||||
AliasAnalysis &AA, OptimizationRemarkEmitter &ORE)
|
||||
: DT(DT), SE(SE), LI(LI), RI(RI), AA(AA), ORE(ORE) {
|
||||
ScopDetection::ScopDetection(const DominatorTree &DT, ScalarEvolution &SE,
|
||||
LoopInfo &LI, RegionInfo &RI, AliasAnalysis &AA,
|
||||
OptimizationRemarkEmitter &ORE)
|
||||
: DT(DT), SE(SE), LI(LI), RI(RI), AA(AA), ORE(ORE) {}
|
||||
|
||||
void ScopDetection::detect(Function &F) {
|
||||
assert(ValidRegions.empty() && "Detection must run only once");
|
||||
|
||||
if (!PollyProcessUnprofitable && LI.empty())
|
||||
return;
|
||||
|
||||
|
@ -1875,7 +1879,9 @@ bool ScopDetectionWrapperPass::runOnFunction(Function &F) {
|
|||
auto &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
|
||||
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
||||
auto &ORE = getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE();
|
||||
Result.reset(new ScopDetection(F, DT, SE, LI, RI, AA, ORE));
|
||||
|
||||
Result = std::make_unique<ScopDetection>(DT, SE, LI, RI, AA, ORE);
|
||||
Result->detect(F);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1922,7 +1928,10 @@ ScopDetection ScopAnalysis::run(Function &F, FunctionAnalysisManager &FAM) {
|
|||
auto &SE = FAM.getResult<ScalarEvolutionAnalysis>(F);
|
||||
auto &DT = FAM.getResult<DominatorTreeAnalysis>(F);
|
||||
auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
|
||||
return {F, DT, SE, LI, RI, AA, ORE};
|
||||
|
||||
ScopDetection Result(DT, SE, LI, RI, AA, ORE);
|
||||
Result.detect(F);
|
||||
return Result;
|
||||
}
|
||||
|
||||
PreservedAnalyses ScopAnalysisPrinterPass::run(Function &F,
|
||||
|
|
Loading…
Reference in New Issue