ScopInfo: Introduce getNumberOfArrayAccesses

Use the new function to clarify that we indeed only want to know it at least
one array access is associated with an instruction.

llvm-svn: 255776
This commit is contained in:
Tobias Grosser 2015-12-16 16:14:00 +00:00
parent 271186bbb6
commit 2ed317383b
2 changed files with 24 additions and 1 deletions

View File

@ -992,6 +992,29 @@ public:
return *ArrayAccess;
}
/// @brief Get the number of array accesses associated with an instruction.
///
/// @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;
auto *Accesses = It->getSecond();
if (!Accesses)
return 0;
for (auto Access : *Accesses) {
if (Access->isArrayKind())
NumAccesses++;
}
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);

View File

@ -2923,7 +2923,7 @@ void Scop::verifyInvariantLoads() {
for (LoadInst *LI : RIL) {
assert(LI && getRegion().contains(LI));
ScopStmt *Stmt = getStmtForBasicBlock(LI->getParent());
if (Stmt && Stmt->lookupAccessesFor(LI)) {
if (Stmt && Stmt->getNumberOfArrayAccessesFor(LI) > 0) {
invalidate(INVARIANTLOAD, LI->getDebugLoc());
return;
}