Index: include/polly/TempScopInfo.h =================================================================== --- include/polly/TempScopInfo.h +++ include/polly/TempScopInfo.h @@ -42,7 +42,8 @@ // The type of the scev affine function enum TypeKind { READ = 0x1, - WRITE = 0x2, + MUST_WRITE = 0x2, + MAY_WRITE = 0x3, }; private: @@ -72,7 +73,9 @@ bool isRead() const { return Type == READ; } - bool isWrite() const { return Type == WRITE; } + bool isWrite() const { return Type == MUST_WRITE; } + + bool isMayWrite() const { return Type == MAY_WRITE; } bool isScalar() const { return Subscripts.size() == 0; } Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -330,6 +330,18 @@ isl_map_free(newAccessRelation); } +static MemoryAccess::AccessType getMemoryAccessType(const IRAccess &Access) { + switch (Access.getType()) { + case IRAccess::READ: + return MemoryAccess::READ; + case IRAccess::MUST_WRITE: + return MemoryAccess::MUST_WRITE; + case IRAccess::MAY_WRITE: + return MemoryAccess::MAY_WRITE; + } + llvm_unreachable("Unknown IRAccess type!"); +} + isl_id *MemoryAccess::getArrayId() const { return isl_map_get_tuple_id(AccessRelation, isl_dim_out); } @@ -416,7 +428,8 @@ MemoryAccess::MemoryAccess(const IRAccess &Access, Instruction *AccInst, ScopStmt *Statement) - : Statement(Statement), Inst(AccInst), newAccessRelation(nullptr) { + : Type(getMemoryAccessType(Access)), Statement(Statement), Inst(AccInst), + newAccessRelation(nullptr) { isl_ctx *Ctx = Statement->getIslCtx(); BaseAddr = Access.getBase(); @@ -431,12 +444,9 @@ AccessRelation = isl_map_from_basic_map(createBasicAccessMap(Statement)); AccessRelation = isl_map_set_tuple_id(AccessRelation, isl_dim_out, BaseAddrId); - Type = Access.isRead() ? READ : MAY_WRITE; return; } - Type = Access.isRead() ? READ : MUST_WRITE; - isl_space *Space = isl_space_alloc(Ctx, 0, Statement->getNumIterators(), 0); AccessRelation = isl_map_universe(Space); Index: lib/Analysis/TempScopInfo.cpp =================================================================== --- lib/Analysis/TempScopInfo.cpp +++ lib/Analysis/TempScopInfo.cpp @@ -41,9 +41,11 @@ void IRAccess::print(raw_ostream &OS) const { if (isRead()) OS << "Read "; - else + else { + if (isMayWrite()) + OS << "May"; OS << "Write "; - + } OS << BaseAddress->getName() << '[' << *Offset << "]\n"; } @@ -160,7 +162,7 @@ StoreInst *Store = cast(Inst); SizeType = Store->getValueOperand()->getType(); Size = TD->getTypeStoreSize(SizeType); - Type = IRAccess::WRITE; + Type = IRAccess::MUST_WRITE; } const SCEV *AccessFunction = SE->getSCEVAtScope(getPointerOperand(*Inst), L); @@ -178,6 +180,9 @@ bool IsAffine = isAffineExpr(R, AccessFunction, *SE, BasePointer->getValue()); Subscripts.push_back(AccessFunction); + if (!IsAffine && Type == IRAccess::MUST_WRITE) + Type = IRAccess::MAY_WRITE; + Sizes.push_back(SE->getConstant(ZeroOffset->getType(), Size)); return IRAccess(Type, BasePointer->getValue(), AccessFunction, Size, IsAffine, Subscripts, Sizes); @@ -196,7 +201,7 @@ // If the Instruction is used outside the statement, we need to build the // write access. SmallVector Subscripts, Sizes; - IRAccess ScalarAccess(IRAccess::WRITE, Inst, ZeroOffset, 1, true, + IRAccess ScalarAccess(IRAccess::MUST_WRITE, Inst, ZeroOffset, 1, true, Subscripts, Sizes); Functions.push_back(std::make_pair(ScalarAccess, Inst)); }