Move AccFuncMap from ScopInfo into Scop

Since the origin AccFuncMap in ScopInfo is used by the underlying Scop
  only, and it must stay alive until we delete the Scop. It will be better
  if we simply move the origin AccFuncMap in ScopInfo into the Scop class.

llvm-svn: 260820
This commit is contained in:
Hongbin Zheng 2016-02-13 15:12:58 +00:00
parent 192f69a0fb
commit 660f3ccfa5
2 changed files with 15 additions and 16 deletions

View File

@ -1238,8 +1238,10 @@ private:
/// 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 @@ private:
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 @@ class ScopInfo : public RegionPass {
/// @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;

View File

@ -2731,10 +2731,9 @@ static unsigned getMaxLoopDepthInRegion(const Region &R, LoopInfo &LI,
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 @@ MemoryAccess *ScopInfo::addMemoryAccess(BasicBlock *BB, Instruction *Inst,
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::addPHIReadAccess(PHINode *PHI) {
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::print(raw_ostream &OS, const Module *) const {
}
void ScopInfo::clear() {
AccFuncMap.clear();
if (scop) {
delete scop;
scop = 0;