summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2015-12-21 07:10:39 +0000
committerTobias Grosser <tobias@grosser.es>2015-12-21 07:10:39 +0000
commit949e8c6ac67f643d9729ceba3cd4352ae1eeed26 (patch)
tree59465b9ee5e0c1c4f1fe8cfd4c7ccc225098cdee
parentdfe29ae5db68430d4c02c6916e38ac6a714169e3 (diff)
downloadbcm5719-llvm-949e8c6ac67f643d9729ceba3cd4352ae1eeed26.tar.gz
bcm5719-llvm-949e8c6ac67f643d9729ceba3cd4352ae1eeed26.zip
ScopInfo: Check for the existance of a single memory accesses
Instead of counting all array memory accesses associated with a load instruction, we now explicitly check that the single array access that could (potentially) be associated with a load instruction does not exist. This helps to document the current behavior of Polly where load instructions can indeed have at most one associated array access. In the unlikely case this changes in the future, we add an assert for the case where two load accesses would prevent us to return a single memory access, but we still should communicate that not all array memory accesses have been removed. This addresses post-commit comments from Johannes Doerfert for commit 255776. llvm-svn: 256136
-rw-r--r--polly/include/polly/ScopInfo.h35
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp2
2 files changed, 15 insertions, 22 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index d70d13d64ed..0252599afa2 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -958,14 +958,15 @@ public:
/// @brief Return true if this statement does not contain any accesses.
bool isEmpty() const { return MemAccs.empty(); }
- /// @brief Return the only array access for @p Inst.
+ /// @brief Return the only array access for @p Inst, if existing.
///
/// @param Inst The instruction for which to look up the access.
- /// @returns The unique array memory access related to Inst.
- MemoryAccess &getArrayAccessFor(const Instruction *Inst) const {
+ /// @returns The unique array memory access related to Inst or nullptr if
+ /// no array access exists
+ MemoryAccess *getArrayAccessOrNULLFor(const Instruction *Inst) const {
auto It = InstructionToAccess.find(Inst);
- assert(It != InstructionToAccess.end() &&
- "No memory accesses found for instruction");
+ if (It == InstructionToAccess.end())
+ return nullptr;
MemoryAccess *ArrayAccess = nullptr;
@@ -978,26 +979,18 @@ public:
ArrayAccess = Access;
}
- assert(ArrayAccess && "No array access found for instruction!");
- return *ArrayAccess;
+ return ArrayAccess;
}
- /// @brief Get the number of array accesses associated with an instruction.
+ /// @brief Return the only array access for @p Inst.
///
- /// @param Inst The instruction for which to obtain the access count.
- /// @returns The number of array accesses associated with this instruction.
- size_t getNumberOfArrayAccessesFor(const Instruction *Inst) const {
- size_t NumAccesses = 0;
- auto It = InstructionToAccess.find(Inst);
- if (It == InstructionToAccess.end())
- return 0;
-
- for (auto Access : It->getSecond()) {
- if (Access->isArrayKind())
- NumAccesses++;
- }
+ /// @param Inst The instruction for which to look up the access.
+ /// @returns The unique array memory access related to Inst.
+ MemoryAccess &getArrayAccessFor(const Instruction *Inst) const {
+ MemoryAccess *ArrayAccess = getArrayAccessOrNULLFor(Inst);
- return NumAccesses;
+ assert(ArrayAccess && "No array access found for instruction!");
+ return *ArrayAccess;
}
void setBasicBlock(BasicBlock *Block) {
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index e98218a5a1a..94e9deeff4d 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -2928,7 +2928,7 @@ void Scop::verifyInvariantLoads() {
for (LoadInst *LI : RIL) {
assert(LI && getRegion().contains(LI));
ScopStmt *Stmt = getStmtForBasicBlock(LI->getParent());
- if (Stmt && Stmt->getNumberOfArrayAccessesFor(LI) > 0) {
+ if (Stmt && Stmt->getArrayAccessOrNULLFor(LI)) {
invalidate(INVARIANTLOAD, LI->getDebugLoc());
return;
}
OpenPOWER on IntegriCloud