[Refactor][NFC] Generalize the creation of ScopArrayInfo objects.
Differential Revision: http://reviews.llvm.org/D6031
llvm-svn: 221512
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index ece1fef..38576f1 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -828,8 +828,9 @@
//@}
/// @brief Return the (possibly new) ScopArrayInfo object for @p Access.
- const ScopArrayInfo *getOrCreateScopArrayInfo(const IRAccess &Access,
- Instruction *AccessInst);
+ const ScopArrayInfo *
+ getOrCreateScopArrayInfo(Value *BasePtr, Type *AccessType,
+ const SmallVector<const SCEV *, 4> &Sizes);
/// @brief Return the cached ScopArrayInfo object for @p BasePtr.
const ScopArrayInfo *getScopArrayInfo(Value *BasePtr);
diff --git a/polly/include/polly/Support/ScopHelper.h b/polly/include/polly/Support/ScopHelper.h
index ca30c85..9277c22c 100644
--- a/polly/include/polly/Support/ScopHelper.h
+++ b/polly/include/polly/Support/ScopHelper.h
@@ -15,6 +15,7 @@
#define POLLY_SUPPORT_IRHELPER_H
namespace llvm {
+class Type;
class Instruction;
class LoopInfo;
class Loop;
@@ -52,6 +53,9 @@
llvm::Value *getPointerOperand(llvm::Instruction &Inst);
llvm::BasicBlock *createSingleExitEdge(llvm::Region *R, llvm::Pass *P);
+/// @brief Return the type of the access.
+llvm::Type *getAccessInstType(llvm::Instruction *AccInst);
+
/// @brief Simplify the region in a SCoP to have a single unconditional entry
/// edge and a single exit edge.
///
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index b3f0550..be65e29 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -728,8 +728,10 @@
const IRAccess &Access = AccessPair.first;
Instruction *AccessInst = AccessPair.second;
- const ScopArrayInfo *SAI =
- getParent()->getOrCreateScopArrayInfo(Access, AccessInst);
+ Type *AccessType = getAccessInstType(AccessInst)->getPointerTo();
+ const ScopArrayInfo *SAI = getParent()->getOrCreateScopArrayInfo(
+ Access.getBase(), AccessType, Access.Sizes);
+
MemAccs.push_back(new MemoryAccess(Access, AccessInst, this, SAI));
// We do not track locations for scalar memory accesses at the moment.
@@ -1482,14 +1484,12 @@
}
}
-const ScopArrayInfo *Scop::getOrCreateScopArrayInfo(const IRAccess &Access,
- Instruction *AccessInst) {
- Value *BasePtr = Access.getBase();
+const ScopArrayInfo *
+Scop::getOrCreateScopArrayInfo(Value *BasePtr, Type *AccessType,
+ const SmallVector<const SCEV *, 4> &Sizes) {
const ScopArrayInfo *&SAI = ScopArrayInfoMap[BasePtr];
- if (!SAI) {
- Type *AccessType = getPointerOperand(*AccessInst)->getType();
- SAI = new ScopArrayInfo(BasePtr, AccessType, getIslCtx(), Access.Sizes);
- }
+ if (!SAI)
+ SAI = new ScopArrayInfo(BasePtr, AccessType, getIslCtx(), Sizes);
return SAI;
}
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index 9541c8e..1b7b9a2 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -66,6 +66,12 @@
return 0;
}
+Type *polly::getAccessInstType(Instruction *AccInst) {
+ if (StoreInst *Store = dyn_cast<StoreInst>(AccInst))
+ return Store->getValueOperand()->getType();
+ return AccInst->getType();
+}
+
bool polly::hasInvokeEdge(const PHINode *PN) {
for (unsigned i = 0, e = PN->getNumIncomingValues(); i < e; ++i)
if (InvokeInst *II = dyn_cast<InvokeInst>(PN->getIncomingValue(i)))