Index: include/polly/ScopInfo.h =================================================================== --- include/polly/ScopInfo.h +++ include/polly/ScopInfo.h @@ -434,6 +434,9 @@ std::string BaseName; + /// @brief Flag to remember errors during the construction of the statement. + bool IsValid; + /// Build the statement. //@{ __isl_give isl_set *buildConditionSet(const Comparison &Cmp); @@ -460,6 +463,9 @@ BasicBlock &bb, SmallVectorImpl &NestLoops, SmallVectorImpl &Scatter); + /// @brief Check if the construction went without an error. + bool isValid() const { return IsValid; } + friend class Scop; public: @@ -678,6 +684,14 @@ /// @brief Simplify the assumed context. void simplifyAssumedContext(); + /// @brief Check if all statements are valid or if at least one is not. + bool statementsAreValid() const { + for (ScopStmt *Stmt : *this) + if (!Stmt->isValid()) + return false; + return true; + } + /// Build the Scop and Statement with precalculated scop information. void buildScop(TempScop &TempScop, const Region &CurRegion, // Loops in Scop containing CurRegion Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -854,7 +854,8 @@ ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop, const Region &CurRegion, BasicBlock &bb, SmallVectorImpl &Nest, SmallVectorImpl &Scatter) - : Parent(parent), BB(&bb), IVS(Nest.size()), NestLoops(Nest.size()) { + : Parent(parent), BB(&bb), IVS(Nest.size()), NestLoops(Nest.size()), + IsValid(true) { // Setup the induction variables. for (unsigned i = 0, e = Nest.size(); i < e; ++i) { if (!SCEVCodegen) { @@ -1783,35 +1784,33 @@ return false; } - // Statistics. - ++ScopFound; - if (tempScop->getMaxLoopDepth() > 0) - ++RichScopFound; - scop = new Scop(*tempScop, LI, SE, ctx); - if (!PollyUseRuntimeAliasChecks) - return false; - - // If a problem occurs while building the alias groups we need to delete - // this SCoP and pretend it wasn't valid in the first place. - if (scop->buildAliasGroups(AA)) + // If a problem occurs while building the SCoP statements or the alias groups + // we need to delete this SCoP and pretend it wasn't valid in the first place. + bool Valid = scop->statementsAreValid(); + if (PollyUseRuntimeAliasChecks) + Valid = Valid && scop->buildAliasGroups(AA); + + if (!Valid) { + DEBUG(dbgs() << "There was a problem during the construction of the SCoP. " + "It will not be considered for optimization. Possible " + "reasons include:\n\tRuntime alias checks were to " + "complex/contained to many parameters.\n\t\t Use " + "--polly-rtc-max-parameters=X\n\tto adjust the maximal " + "number of parameters allowed (for the price of compile " + "time)."); + + delete scop; + scop = nullptr; return false; + } - --ScopFound; + // Statistics after we know the SCoP is valid. + ++ScopFound; if (tempScop->getMaxLoopDepth() > 0) - --RichScopFound; - - DEBUG(dbgs() - << "\n\nNOTE: Run time checks for " << scop->getNameStr() - << " could not be created as the number of parameters involved is too " - "high. The SCoP will be " - "dismissed.\nUse:\n\t--polly-rtc-max-parameters=X\nto adjust the " - "maximal number of parameters but be advised that the compile time " - "might increase exponentially.\n\n"); - - delete scop; - scop = nullptr; + ++RichScopFound; + return false; }