[polly] r237431 - Give each memory access a reference ID
Tobias Grosser
tobias at grosser.es
Fri May 15 02:58:32 PDT 2015
Author: grosser
Date: Fri May 15 04:58:32 2015
New Revision: 237431
URL: http://llvm.org/viewvc/llvm-project?rev=237431&view=rev
Log:
Give each memory access a reference ID
This reference ID is handy for use cases where we need to identify individual
memory accesses (e.g. to modify their access functions).
This is a reworked version of a patch originally developed by Yabin Hu as part
of his summer of code project.
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=237431&r1=237430&r2=237431&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Fri May 15 04:58:32 2015
@@ -206,6 +206,12 @@ private:
/// Updated access relation read from JSCOP file.
isl_map *newAccessRelation;
+ /// @brief A unique identifier for this memory access.
+ ///
+ /// The identifier is unique between all memory accesses belonging to the same
+ /// scop statement.
+ isl_id *Id;
+
void assumeNoOutOfBound(const IRAccess &Access);
/// @brief Compute bounds on an over approximated access relation.
@@ -257,12 +263,14 @@ private:
public:
/// @brief Create a memory access from an access in LLVM-IR.
///
- /// @param Access The memory access.
- /// @param AccInst The access instruction.
- /// @param Statement The statement that contains the access.
- /// @param SAI The ScopArrayInfo object for this base pointer.
+ /// @param Access The memory access.
+ /// @param AccInst The access instruction.
+ /// @param Statement The statement that contains the access.
+ /// @param SAI The ScopArrayInfo object for this base pointer.
+ /// @param Identifier An identifier that is unique for all memory accesses
+ /// belonging to the same scop statement.
MemoryAccess(const IRAccess &Access, Instruction *AccInst,
- ScopStmt *Statement, const ScopArrayInfo *SAI);
+ ScopStmt *Statement, const ScopArrayInfo *SAI, int Identifier);
~MemoryAccess();
@@ -369,6 +377,12 @@ public:
/// @brief Align the parameters in the access relation to the scop context
void realignParams();
+ /// @brief Get identifier for the memory access.
+ ///
+ /// This identifier is unique for all accesses that belong to the same scop
+ /// statement.
+ __isl_give isl_id *getId() const;
+
/// @brief Print the MemoryAccess.
///
/// @param OS The output stream the MemoryAccess is printed to.
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=237431&r1=237430&r2=237431&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Fri May 15 04:58:32 2015
@@ -418,6 +418,7 @@ static MemoryAccess::ReductionType getRe
//===----------------------------------------------------------------------===//
MemoryAccess::~MemoryAccess() {
+ isl_id_free(Id);
isl_map_free(AccessRelation);
isl_map_free(newAccessRelation);
}
@@ -624,7 +625,8 @@ __isl_give isl_map *MemoryAccess::foldAc
}
MemoryAccess::MemoryAccess(const IRAccess &Access, Instruction *AccInst,
- ScopStmt *Statement, const ScopArrayInfo *SAI)
+ ScopStmt *Statement, const ScopArrayInfo *SAI,
+ int Identifier)
: AccType(getMemoryAccessType(Access)), Statement(Statement), Inst(AccInst),
newAccessRelation(nullptr) {
@@ -634,6 +636,12 @@ MemoryAccess::MemoryAccess(const IRAcces
isl_id *BaseAddrId = SAI->getBasePtrId();
+ std::string IdName;
+ raw_string_ostream IdNameStream(IdName);
+ IdNameStream << "__polly_array_ref_ " << Identifier;
+ IdNameStream.flush();
+ this->Id = isl_id_alloc(Ctx, IdName.c_str(), nullptr);
+
if (!Access.isAffine()) {
// We overapproximate non-affine accesses with a possible access to the
// whole array. For read accesses it does not make a difference, if an
@@ -694,6 +702,8 @@ const std::string MemoryAccess::getReduc
return MemoryAccess::getReductionOperatorStr(getReductionType());
}
+__isl_give isl_id *MemoryAccess::getId() const { return isl_id_copy(Id); }
+
raw_ostream &polly::operator<<(raw_ostream &OS,
MemoryAccess::ReductionType RT) {
if (RT == MemoryAccess::RT_NONE)
@@ -868,6 +878,8 @@ void ScopStmt::buildAccesses(TempScop &t
if (!AFS)
return;
+ int Identifier = 0;
+
for (auto &AccessPair : *AFS) {
IRAccess &Access = AccessPair.first;
Instruction *AccessInst = AccessPair.second;
@@ -879,7 +891,9 @@ void ScopStmt::buildAccesses(TempScop &t
if (isApproximated && Access.isWrite())
Access.setMayWrite();
- MemAccs.push_back(new MemoryAccess(Access, AccessInst, this, SAI));
+ MemAccs.push_back(
+ new MemoryAccess(Access, AccessInst, this, SAI, Identifier));
+ Identifier++;
// We do not track locations for scalar memory accesses at the moment.
//
More information about the llvm-commits
mailing list