summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2015-12-16 16:14:03 +0000
committerTobias Grosser <tobias@grosser.es>2015-12-16 16:14:03 +0000
commit10120189ab3203ce0f23e7e25b54992d85f83417 (patch)
treebb34b5298f2df0ca6eb8fad5c41c0c4e64bd07c3
parent2ed317383b9ef7191134f907662463baeff629cf (diff)
downloadbcm5719-llvm-10120189ab3203ce0f23e7e25b54992d85f83417.tar.gz
bcm5719-llvm-10120189ab3203ce0f23e7e25b54992d85f83417.zip
ScopInfo: Directly store MemoryAccessList in InstructionToAccess
This avoids the need for explicit memory management, simplifies the code and also fixes a memory leak in removeMemoryAccesses. llvm-svn: 255777
-rw-r--r--polly/include/polly/ScopInfo.h30
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp14
2 files changed, 7 insertions, 37 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 1a920561fde..16a5275fe32 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -827,7 +827,7 @@ private:
MemoryAccessVec MemAccs;
/// @brief Mapping from instructions to (scalar) memory accesses.
- DenseMap<const Instruction *, MemoryAccessList *> InstructionToAccess;
+ DenseMap<const Instruction *, MemoryAccessList> InstructionToAccess;
//@}
@@ -957,14 +957,6 @@ public:
/// @brief Return true if this statement does not contain any accesses.
bool isEmpty() const { return MemAccs.empty(); }
- /// @brief Return the (scalar) memory accesses for @p Inst if any.
- MemoryAccessList *lookupAccessesFor(const Instruction *Inst) const {
- auto It = InstructionToAccess.find(Inst);
- if (It == InstructionToAccess.end())
- return nullptr;
- return It->getSecond()->empty() ? nullptr : It->getSecond();
- }
-
/// @brief Return the only array access for @p Inst.
///
/// @param Inst The instruction for which to look up the access.
@@ -973,13 +965,10 @@ public:
auto It = InstructionToAccess.find(Inst);
assert(It != InstructionToAccess.end() &&
"No memory accesses found for instruction");
- auto *Accesses = It->getSecond();
-
- assert(Accesses && "No memory accesses found for instruction");
MemoryAccess *ArrayAccess = nullptr;
- for (auto Access : *Accesses) {
+ for (auto Access : It->getSecond()) {
if (!Access->isArrayKind())
continue;
@@ -1002,12 +991,7 @@ public:
if (It == InstructionToAccess.end())
return 0;
- auto *Accesses = It->getSecond();
-
- if (!Accesses)
- return 0;
-
- for (auto Access : *Accesses) {
+ for (auto Access : It->getSecond()) {
if (Access->isArrayKind())
NumAccesses++;
}
@@ -1015,14 +999,6 @@ public:
return NumAccesses;
}
- /// @brief Return the __first__ (scalar) memory access for @p Inst if any.
- MemoryAccess *lookupAccessFor(const Instruction *Inst) const {
- auto It = InstructionToAccess.find(Inst);
- if (It == InstructionToAccess.end())
- return nullptr;
- return It->getSecond()->empty() ? nullptr : It->getSecond()->front();
- }
-
void setBasicBlock(BasicBlock *Block) {
// TODO: Handle the case where the statement is a region statement, thus
// the entry block was split and needs to be changed in the region R.
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 8209b5b5723..a617e1ace1e 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -899,11 +899,9 @@ void ScopStmt::buildAccessRelations() {
void ScopStmt::addAccess(MemoryAccess *Access) {
Instruction *AccessInst = Access->getAccessInstruction();
- MemoryAccessList *&MAL = InstructionToAccess[AccessInst];
- if (!MAL)
- MAL = new MemoryAccessList();
- MAL->emplace_front(Access);
- MemAccs.push_back(MAL->front());
+ MemoryAccessList &MAL = InstructionToAccess[AccessInst];
+ MAL.emplace_front(Access);
+ MemAccs.push_back(MAL.front());
}
void ScopStmt::realignParams() {
@@ -1435,10 +1433,7 @@ __isl_give isl_id *ScopStmt::getDomainId() const {
return isl_set_get_tuple_id(Domain);
}
-ScopStmt::~ScopStmt() {
- DeleteContainerSeconds(InstructionToAccess);
- isl_set_free(Domain);
-}
+ScopStmt::~ScopStmt() { isl_set_free(Domain); }
void ScopStmt::print(raw_ostream &OS) const {
OS << "\t" << getBaseName() << "\n";
@@ -1472,7 +1467,6 @@ void ScopStmt::removeMemoryAccesses(MemoryAccessList &InvMAs) {
MemAccs.erase(std::remove_if(MemAccs.begin(), MemAccs.end(), Predicate),
MemAccs.end());
InstructionToAccess.erase(MA->getAccessInstruction());
- delete lookupAccessesFor(MA->getAccessInstruction());
}
}
OpenPOWER on IntegriCloud