Index: polly/trunk/include/polly/ScopInfo.h =================================================================== --- polly/trunk/include/polly/ScopInfo.h +++ polly/trunk/include/polly/ScopInfo.h @@ -842,10 +842,17 @@ /// group to ensure the SCoP is executed in an alias free environment. MinMaxVectorPairVectorTy MinMaxAliasGroups; + /// @brief Scop constructor; used by static createFromTempScop + Scop(Region &R, ScalarEvolution &SE, isl_ctx *ctx, unsigned MaxLoopDepth); + + /// @brief Initialize this ScopInfo using a TempScop object. + void initFromTempScop(TempScop &TempScop, LoopInfo &LI, ScopDetection &SD); + /// Create the static control part with a region, max loop depth of this /// region and parameters used in this region. - Scop(TempScop &TempScop, LoopInfo &LI, ScalarEvolution &SE, ScopDetection &SD, - isl_ctx *ctx); + static Scop *createFromTempScop(TempScop &TempScop, LoopInfo &LI, + ScalarEvolution &SE, ScopDetection &SD, + isl_ctx *ctx); /// @brief Check if a basic block is trivial. /// Index: polly/trunk/lib/Analysis/ScopInfo.cpp =================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp +++ polly/trunk/lib/Analysis/ScopInfo.cpp @@ -1664,19 +1664,20 @@ return MaxLD - MinLD + 1; } -Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution, - ScopDetection &SD, isl_ctx *Context) - : SE(&ScalarEvolution), R(tempScop.getMaxRegion()), IsOptimized(false), - MaxLoopDepth(getMaxLoopDepthInRegion(tempScop.getMaxRegion(), LI, SD)) { - IslCtx = Context; +Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, isl_ctx *Context, + unsigned MaxLoopDepth) + : SE(&ScalarEvolution), R(R), IsOptimized(false), + MaxLoopDepth(MaxLoopDepth), IslCtx(Context) {} +void Scop::initFromTempScop(TempScop &TempScop, LoopInfo &LI, + ScopDetection &SD) { buildContext(); SmallVector NestLoops; // Build the iteration domain, access functions and schedule functions // traversing the region tree. - Schedule = buildScop(tempScop, getRegion(), NestLoops, LI, SD); + Schedule = buildScop(TempScop, getRegion(), NestLoops, LI, SD); if (!Schedule) Schedule = isl_schedule_empty(getParamSpace()); @@ -1687,6 +1688,16 @@ assert(NestLoops.empty() && "NestLoops not empty at top level!"); } +Scop *Scop::createFromTempScop(TempScop &TempScop, LoopInfo &LI, + ScalarEvolution &SE, ScopDetection &SD, + isl_ctx *ctx) { + auto &R = TempScop.getMaxRegion(); + auto MaxLoopDepth = getMaxLoopDepthInRegion(R, LI, SD); + auto S = new Scop(R, SE, ctx, MaxLoopDepth); + S->initFromTempScop(TempScop, LI, SD); + return S; +} + Scop::~Scop() { isl_set_free(Context); isl_set_free(AssumedContext); @@ -2165,7 +2176,7 @@ return false; } - scop = new Scop(*tempScop, LI, SE, SD, ctx); + scop = Scop::createFromTempScop(*tempScop, LI, SE, SD, ctx); DEBUG(scop->print(dbgs())); Index: polly/trunk/lib/CodeGen/IslAst.cpp =================================================================== --- polly/trunk/lib/CodeGen/IslAst.cpp +++ polly/trunk/lib/CodeGen/IslAst.cpp @@ -71,8 +71,7 @@ namespace polly { class IslAst { public: - IslAst(Scop *Scop, const Dependences &D); - + static IslAst *create(Scop *Scop, const Dependences &D); ~IslAst(); /// Print a source code representation of the program. @@ -88,6 +87,9 @@ isl_ast_node *Root; isl_ast_expr *RunCondition; + IslAst(Scop *Scop); + void init(const Dependences &D); + void buildRunCondition(__isl_keep isl_ast_build *Build); }; } // End namespace polly. @@ -372,14 +374,14 @@ return true; } -IslAst::IslAst(Scop *Scop, const Dependences &D) - : S(Scop), Root(nullptr), RunCondition(nullptr) { +IslAst::IslAst(Scop *Scop) : S(Scop), Root(nullptr), RunCondition(nullptr) {} +void IslAst::init(const Dependences &D) { bool PerformParallelTest = PollyParallel || DetectParallel || PollyVectorizerChoice != VECTORIZER_NONE; // Skip AST and code generation if there was no benefit achieved. - if (!benefitsFromPolly(Scop, PerformParallelTest)) + if (!benefitsFromPolly(S, PerformParallelTest)) return; isl_ctx *Ctx = S->getIslCtx(); @@ -411,6 +413,12 @@ isl_ast_build_free(Build); } +IslAst *IslAst::create(Scop *Scop, const Dependences &D) { + auto Ast = new IslAst(Scop); + Ast->init(D); + return Ast; +} + IslAst::~IslAst() { isl_ast_node_free(Root); isl_ast_expr_free(RunCondition); @@ -436,7 +444,7 @@ const Dependences &D = getAnalysis().getDependences(); - Ast = new IslAst(&Scop, D); + Ast = IslAst::create(&Scop, D); DEBUG(printScop(dbgs(), Scop)); return false;