Index: include/polly/ScopInfo.h =================================================================== --- include/polly/ScopInfo.h +++ include/polly/ScopInfo.h @@ -1238,8 +1238,10 @@ /// The underlying Region. Region &R; - // Access function of bbs. - AccFuncMapType &AccFuncMap; + // Access function of statements (currently BasicBlocks) . + // + // This owns all the MemoryAccess objects of the Scop created in this pass. + AccFuncMapType AccFuncMap; /// Flag to indicate that the scheduler actually optimized the SCoP. bool IsOptimized; @@ -1369,8 +1371,13 @@ InvariantEquivClassesTy InvariantEquivClasses; /// @brief Scop constructor; invoked from ScopInfo::buildScop. - Scop(Region &R, AccFuncMapType &AccFuncMap, ScalarEvolution &SE, isl_ctx *ctx, - unsigned MaxLoopDepth); + Scop(Region &R, ScalarEvolution &SE, isl_ctx *ctx, unsigned MaxLoopDepth); + + /// @brief Get or create the access function set in a BasicBlock + AccFuncSetType &getOrCreateAccessFunctions(const BasicBlock *BB) { + return AccFuncMap[BB]; + } + //@} /// @brief Initialize this ScopInfo . void init(AliasAnalysis &AA, AssumptionCache &AC, ScopDetection &SD, @@ -2001,12 +2008,6 @@ /// @brief The ScalarEvolution to help building Scop. ScalarEvolution *SE; - // Access function of statements (currently BasicBlocks) . - // - // This owns all the MemoryAccess objects of the Scop created in this pass. It - // must live until #scop is deleted. - AccFuncMapType AccFuncMap; - // The Scop Scop *scop; isl_ctx *ctx; Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -2731,10 +2731,9 @@ return MaxLD - MinLD + 1; } -Scop::Scop(Region &R, AccFuncMapType &AccFuncMap, - ScalarEvolution &ScalarEvolution, isl_ctx *Context, +Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, isl_ctx *Context, unsigned MaxLoopDepth) - : SE(&ScalarEvolution), R(R), AccFuncMap(AccFuncMap), IsOptimized(false), + : SE(&ScalarEvolution), R(R), IsOptimized(false), HasSingleExitEdge(R.getExitingBlock()), HasErrorBlock(false), MaxLoopDepth(MaxLoopDepth), IslCtx(Context), Context(nullptr), Affinator(this), AssumedContext(nullptr), BoundaryContext(nullptr), @@ -3978,7 +3977,7 @@ if (!Stmt) return nullptr; - AccFuncSetType &AccList = AccFuncMap[BB]; + AccFuncSetType &AccList = scop->getOrCreateAccessFunctions(BB); Value *BaseAddr = BaseAddress; std::string BaseName = getIslCompatibleName("MemRef_", BaseAddr, ""); @@ -4127,7 +4126,7 @@ void ScopInfo::buildScop(Region &R, AssumptionCache &AC) { unsigned MaxLoopDepth = getMaxLoopDepthInRegion(R, *LI, *SD); - scop = new Scop(R, AccFuncMap, *SE, ctx, MaxLoopDepth); + scop = new Scop(R, *SE, ctx, MaxLoopDepth); buildStmts(R, R); buildAccessFunctions(R, R); @@ -4155,7 +4154,6 @@ } void ScopInfo::clear() { - AccFuncMap.clear(); if (scop) { delete scop; scop = 0;