[polly] r221512 - [Refactor][NFC] Generalize the creation of ScopArrayInfo objects.
Johannes Doerfert
doerfert at cs.uni-saarland.de
Fri Nov 7 00:31:32 PST 2014
Author: jdoerfert
Date: Fri Nov 7 02:31:31 2014
New Revision: 221512
URL: http://llvm.org/viewvc/llvm-project?rev=221512&view=rev
Log:
[Refactor][NFC] Generalize the creation of ScopArrayInfo objects.
Differential Revision: http://reviews.llvm.org/D6031
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/include/polly/Support/ScopHelper.h
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/lib/Support/ScopHelper.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=221512&r1=221511&r2=221512&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Fri Nov 7 02:31:31 2014
@@ -828,8 +828,9 @@ public:
//@}
/// @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);
Modified: polly/trunk/include/polly/Support/ScopHelper.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/ScopHelper.h?rev=221512&r1=221511&r2=221512&view=diff
==============================================================================
--- polly/trunk/include/polly/Support/ScopHelper.h (original)
+++ polly/trunk/include/polly/Support/ScopHelper.h Fri Nov 7 02:31:31 2014
@@ -15,6 +15,7 @@
#define POLLY_SUPPORT_IRHELPER_H
namespace llvm {
+class Type;
class Instruction;
class LoopInfo;
class Loop;
@@ -52,6 +53,9 @@ bool hasInvokeEdge(const llvm::PHINode *
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.
///
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=221512&r1=221511&r2=221512&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Fri Nov 7 02:31:31 2014
@@ -728,8 +728,10 @@ void ScopStmt::buildAccesses(TempScop &t
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 @@ Scop::~Scop() {
}
}
-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;
}
Modified: polly/trunk/lib/Support/ScopHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/ScopHelper.cpp?rev=221512&r1=221511&r2=221512&view=diff
==============================================================================
--- polly/trunk/lib/Support/ScopHelper.cpp (original)
+++ polly/trunk/lib/Support/ScopHelper.cpp Fri Nov 7 02:31:31 2014
@@ -66,6 +66,12 @@ Value *polly::getPointerOperand(Instruct
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)))
More information about the llvm-commits
mailing list