Index: lib/Analysis/ScopBuilder.cpp =================================================================== --- lib/Analysis/ScopBuilder.cpp +++ lib/Analysis/ScopBuilder.cpp @@ -686,7 +686,7 @@ Loop *L = LI.getLoopFor(Inst.getParent()); if (shouldModelInst(&Inst, L)) Instructions.push_back(&Inst); - if (Inst.getMetadata("polly_split_after")) { + if (isa(Inst)) { Loop *SurroundingLoop = LI.getLoopFor(I->getNodeAs()); scop->addScopStmt(I->getNodeAs(), SurroundingLoop, Instructions, Count); @@ -694,9 +694,11 @@ Instructions.clear(); } } - Loop *SurroundingLoop = LI.getLoopFor(I->getNodeAs()); - scop->addScopStmt(I->getNodeAs(), SurroundingLoop, - Instructions, Count); + if (Count == 0 || !Instructions.empty()) { + Loop *SurroundingLoop = LI.getLoopFor(I->getNodeAs()); + scop->addScopStmt(I->getNodeAs(), SurroundingLoop, + Instructions, Count); + } } } @@ -720,9 +722,12 @@ Split = false; Count++; } - if (Inst.getMetadata("polly_split_after")) + if (isa(Inst)) Split = true; + if (Count > scop->getStmtListFor(&BB).size() - 1) + break; + if (Stmt && Stmt->isBlockStmt() && Stmt != scop->getStmtListFor(&BB)[Count]) continue;