[polly] r185253 - Refactor memory access getting code in ScopStmt.

Hongbin Zheng etherzhhb at gmail.com
Fri Jun 28 23:31:39 PDT 2013


Author: ether
Date: Sat Jun 29 01:31:39 2013
New Revision: 185253

URL: http://llvm.org/viewvc/llvm-project?rev=185253&view=rev
Log:
Refactor memory access getting code in ScopStmt.

1. Do not allow creating new memory access record in the InstructionToAccess map
   on the fly in function getAccessFor.
2. Do not allow user to modify the memory accesses returned by getAccessFor
   during the code generation process.

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/CodeGen/BlockGenerators.cpp

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=185253&r1=185252&r2=185253&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Sat Jun 29 01:31:39 2013
@@ -340,8 +340,10 @@ public:
   /// @return The BasicBlock represented by this ScopStmt.
   BasicBlock *getBasicBlock() const { return BB; }
 
-  MemoryAccess &getAccessFor(const Instruction *Inst) {
-    return *InstructionToAccess[Inst];
+  const MemoryAccess &getAccessFor(const Instruction *Inst) const {
+    MemoryAccess *A = lookupAccessFor(Inst);
+    assert(A && "Cannot get memory access because it does not exist!");
+    return *A;
   }
 
   MemoryAccess *lookupAccessFor(const Instruction *Inst) const {

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=185253&r1=185252&r2=185253&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Sat Jun 29 01:31:39 2013
@@ -281,7 +281,7 @@ Value *BlockGenerator::generateLocationA
                                                 ValueMapT &BBMap,
                                                 ValueMapT &GlobalMap,
                                                 LoopToScevMapT &LTS) {
-  MemoryAccess &Access = Statement.getAccessFor(Inst);
+  const MemoryAccess &Access = Statement.getAccessFor(Inst);
   isl_map *CurrentAccessRelation = Access.getAccessRelation();
   isl_map *NewAccessRelation = Access.getNewAccessRelation();
 
@@ -494,7 +494,7 @@ void VectorBlockGenerator::generateLoad(
     return;
   }
 
-  MemoryAccess &Access = Statement.getAccessFor(Load);
+  const MemoryAccess &Access = Statement.getAccessFor(Load);
 
   Value *NewLoad;
   if (Access.isStrideZero(isl_map_copy(Schedule)))
@@ -542,7 +542,7 @@ void VectorBlockGenerator::copyStore(con
                                      VectorValueMapT &ScalarMaps) {
   int VectorWidth = getVectorWidth();
 
-  MemoryAccess &Access = Statement.getAccessFor(Store);
+  const MemoryAccess &Access = Statement.getAccessFor(Store);
 
   const Value *Pointer = Store->getPointerOperand();
   Value *Vector = getVectorValue(Store->getValueOperand(), VectorMap,





More information about the llvm-commits mailing list