Index: include/polly/Support/ScopHelper.h =================================================================== --- include/polly/Support/ScopHelper.h +++ include/polly/Support/ScopHelper.h @@ -435,5 +435,34 @@ std::tuple, std::vector> getIndexExpressionsFromGEP(llvm::GetElementPtrInst *GEP, llvm::ScalarEvolution &SE); + +// llvm::Loop *getFirstNonBoxedLoopFor(llvm::Loop *L, llvm::LoopInfo &LI, +// const BoxedLoopsSetTy &BoxedLoops); + +// llvm::Loop *getFirstNonBoxedLoopFor(llvm::BasicBlock *BB, llvm::LoopInfo &LI, +// const BoxedLoopsSetTy &BoxedLoops); + +// If the loop is nonaffine/boxed, return the first non-boxed surrounding loop +// for Polly. If the loop is affine, return the loop itself. Do not call +// `getSCEVAtScope()` on the result of `getFirstNonBoxedLoopFor()`, as we need +// to analyze the memory accesses of the nonaffine/boxed loops. +// +// @param L Pointer to the Loop object to analyze. +// @param LI Reference to the LoopInfo. +// @param Boxed Loops Set of Boxed Loops we get from the SCoP. +llvm::Loop *getFirstNonBoxedLoopFor(llvm::Loop *L, llvm::LoopInfo &LI, + const BoxedLoopsSetTy &BoxedLoops); + +// If the Basic Block belongs to a loop that is nonaffine/boxed, return the +// first non-boxed surrounding loop for Polly. If the loop is affine, return +// the loop itself. Do not call `getSCEVAtScope()` on the result of +// `getFirstNonBoxedLoopFor()`, as we need to analyze the memory accesses of +// the nonaffine/boxed loops. +// +// @param BB Pointer to the Basic Block to analyze. +// @param LI Reference to the LoopInfo. +// @param Boxed Loops Set of Boxed Loops we get from the SCoP. +llvm::Loop *getFirstNonBoxedLoopFor(llvm::BasicBlock *BB, llvm::LoopInfo &LI, + const BoxedLoopsSetTy &BoxedLoops); } // namespace polly #endif Index: lib/Analysis/ScopBuilder.cpp =================================================================== --- lib/Analysis/ScopBuilder.cpp +++ lib/Analysis/ScopBuilder.cpp @@ -31,17 +31,6 @@ STATISTIC(InfeasibleScops, "Number of SCoPs with statically infeasible context."); -// If the loop is nonaffine/boxed, return the first non-boxed surrounding loop -// for Polly. If the loop is affine, return the loop itself. Do not call -// `getSCEVAtScope()` on the result of `getFirstNonBoxedLoopFor()`, as we need -// to analyze the memory accesses of the nonaffine/boxed loops. -static Loop *getFirstNonBoxedLoopFor(Loop *L, LoopInfo &LI, - const BoxedLoopsSetTy &BoxedLoops) { - while (BoxedLoops.count(L)) - L = L->getParentLoop(); - return L; -} - static cl::opt ModelReadOnlyScalars( "polly-analyze-read-only-scalars", cl::desc("Model read-only scalar values in the scop description"), Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -2296,18 +2296,6 @@ return true; } -// If the loop is nonaffine/boxed, return the first non-boxed surrounding loop -// for Polly. If the loop is affine, return the loop itself. Do not call -// `getSCEVAtScope()` on the result of `getFirstNonBoxedLoopFor()`, as we need -// to analyze the memory accesses of the nonaffine/boxed loops. -static Loop *getFirstNonBoxedLoopFor(BasicBlock *BB, LoopInfo &LI, - const BoxedLoopsSetTy &BoxedLoops) { - auto *L = LI.getLoopFor(BB); - while (BoxedLoops.count(L)) - L = L->getParentLoop(); - return L; -} - /// Adjust the dimensions of @p Dom that was constructed for @p OldL /// to be compatible to domains constructed for loop @p NewL. /// Index: lib/Support/ScopHelper.cpp =================================================================== --- lib/Support/ScopHelper.cpp +++ lib/Support/ScopHelper.cpp @@ -570,3 +570,17 @@ return std::make_tuple(Subscripts, Sizes); } + +llvm::Loop *polly::getFirstNonBoxedLoopFor(llvm::Loop *L, llvm::LoopInfo &LI, + const BoxedLoopsSetTy &BoxedLoops) { + while (BoxedLoops.count(L)) + L = L->getParentLoop(); + return L; +} + +llvm::Loop *polly::getFirstNonBoxedLoopFor(llvm::BasicBlock *BB, + llvm::LoopInfo &LI, + const BoxedLoopsSetTy &BoxedLoops) { + auto *L = LI.getLoopFor(BB); + return getFirstNonBoxedLoopFor(L, LI, BoxedLoops); +}