[llvm-commits] [polly] r141257 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/Dependences.cpp lib/Analysis/ScopInfo.cpp lib/CodeGeneration.cpp lib/Exchange/JSONExporter.cpp

Tobias Grosser grosser at fim.uni-passau.de
Wed Oct 5 17:04:12 PDT 2011


Author: grosser
Date: Wed Oct  5 19:04:11 2011
New Revision: 141257

URL: http://llvm.org/viewvc/llvm-project?rev=141257&view=rev
Log:
ScopInfo: Only give away a copy of the access relation.

Also take the chance and rename access functions to access relations. This is
because we do not only allow plain functions to describe an access, but we
can have any access relation that can be described with linear constraints.

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/Dependences.cpp
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/lib/CodeGeneration.cpp
    polly/trunk/lib/Exchange/JSONExporter.cpp

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=141257&r1=141256&r2=141257&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Wed Oct  5 19:04:11 2011
@@ -119,11 +119,10 @@
   /// @brief Is this a read memory access?
   bool isRead() const { return Type == MemoryAccess::Read; }
 
-  isl_map *getAccessFunction() { return AccessRelation; }
-  isl_map *getAccessFunction() const { return AccessRelation; }
+  isl_map *getAccessRelation() const;
 
   /// @brief Get an isl string representing this access function.
-  std::string getAccessFunctionStr() const;
+  std::string getAccessRelationStr() const;
 
   const Value *getBaseAddr() const {
     return BaseAddr;
@@ -134,9 +133,7 @@
   }
 
   /// @brief Get the new access function imported from JSCOP file
-  isl_map *getNewAccessFunction() {
-    return newAccessRelation;
-  }
+  isl_map *getNewAccessRelation() const;
 
   /// @brief Get the stride of this memory access in the specified domain
   ///        subset.
@@ -154,7 +151,7 @@
   ScopStmt *getStatement() const { return statement; }
 
   /// @brief Set the updated access relation read from JSCOP file.
-  void setNewAccessFunction(isl_map *newAccessRelation);
+  void setNewAccessRelation(isl_map *newAccessRelation);
   /// @brief Print the MemoryAccess.
   ///
   /// @param OS The output stream the MemoryAccess is printed to.

Modified: polly/trunk/lib/Analysis/Dependences.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=141257&r1=141256&r2=141257&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/Dependences.cpp (original)
+++ polly/trunk/lib/Analysis/Dependences.cpp Wed Oct  5 19:04:11 2011
@@ -97,7 +97,7 @@
     for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(),
           ME = Stmt->memacc_end(); MI != ME; ++MI) {
       isl_set *domcp = Stmt->getDomain();
-      isl_map *accdom = isl_map_copy((*MI)->getAccessFunction());
+      isl_map *accdom = (*MI)->getAccessRelation();
 
       accdom = isl_map_intersect_domain(accdom, domcp);
 

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=141257&r1=141256&r2=141257&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Oct  5 19:04:11 2011
@@ -295,8 +295,16 @@
   BaseName = "MemRef_" + BaseName;
 }
 
-std::string MemoryAccess::getAccessFunctionStr() const {
-  return stringFromIslObj(getAccessFunction());
+isl_map *MemoryAccess::getAccessRelation() const {
+  return isl_map_copy(AccessRelation);
+}
+
+std::string MemoryAccess::getAccessRelationStr() const {
+  return stringFromIslObj(AccessRelation);
+}
+
+isl_map *MemoryAccess::getNewAccessRelation() const {
+  return isl_map_copy(newAccessRelation);
 }
 
 isl_basic_map *MemoryAccess::createBasicAccessMap(ScopStmt *Statement) {
@@ -358,7 +366,7 @@
 
 void MemoryAccess::print(raw_ostream &OS) const {
   OS.indent(12) << (isRead() ? "Read" : "Write") << "Access := \n";
-  OS.indent(16) << getAccessFunctionStr() << ";\n";
+  OS.indent(16) << getAccessRelationStr() << ";\n";
 }
 
 void MemoryAccess::dump() const {
@@ -424,7 +432,7 @@
 }
 
 isl_set *MemoryAccess::getStride(const isl_set *domainSubset) const {
-  isl_map *accessRelation = isl_map_copy(getAccessFunction());
+  isl_map *accessRelation = getAccessRelation();
   isl_set *scatteringDomain = isl_set_copy(const_cast<isl_set*>(domainSubset));
   isl_map *scattering = getStatement()->getScattering();
 
@@ -506,7 +514,7 @@
   return isStrideOne;
 }
 
-void MemoryAccess::setNewAccessFunction(isl_map *newAccess) {
+void MemoryAccess::setNewAccessRelation(isl_map *newAccess) {
   isl_map_free(newAccessRelation);
   newAccessRelation = newAccess;
 }

Modified: polly/trunk/lib/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=141257&r1=141256&r2=141257&view=diff
==============================================================================
--- polly/trunk/lib/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGeneration.cpp Wed Oct  5 19:04:11 2011
@@ -358,22 +358,26 @@
   /// @brief Generate the operand address
   Value *generateLocationAccessed(const Instruction *Inst,
                                   const Value *pointer, ValueMapT &BBMap ) {
-    MemoryAccess &access = statement.getAccessFor(Inst);
-    isl_map *currentAccessRelation = access.getAccessFunction();
-    isl_map *newAccessRelation = access.getNewAccessFunction();
+    MemoryAccess &Access = statement.getAccessFor(Inst);
+    isl_map *CurrentAccessRelation = Access.getAccessRelation();
+    isl_map *NewAccessRelation = Access.getNewAccessRelation();
 
-    assert(isl_map_has_equal_space(currentAccessRelation, newAccessRelation)
+    assert(isl_map_has_equal_space(CurrentAccessRelation, NewAccessRelation)
            && "Current and new access function use different spaces");
 
-    if (!newAccessRelation) {
-      Value *newPointer = getOperand(pointer, BBMap);
-      return newPointer;
+    Value *NewPointer;
+
+    if (!NewAccessRelation) {
+      NewPointer = getOperand(pointer, BBMap);
+    } else {
+      Value *BaseAddr = const_cast<Value*>(Access.getBaseAddr());
+      NewPointer = getNewAccessOperand(NewAccessRelation, BaseAddr, pointer,
+                                       BBMap);
     }
 
-    Value *baseAddr = const_cast<Value*>(access.getBaseAddr());
-    Value *newPointer = getNewAccessOperand(newAccessRelation, baseAddr,
-                                            pointer, BBMap);
-    return newPointer;
+    isl_map_free(CurrentAccessRelation);
+    isl_map_free(NewAccessRelation);
+    return NewPointer;
   }
 
   Value *generateScalarLoad(const LoadInst *load, ValueMapT &BBMap) {

Modified: polly/trunk/lib/Exchange/JSONExporter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=141257&r1=141256&r2=141257&view=diff
==============================================================================
--- polly/trunk/lib/Exchange/JSONExporter.cpp (original)
+++ polly/trunk/lib/Exchange/JSONExporter.cpp Wed Oct  5 19:04:11 2011
@@ -117,7 +117,7 @@
       Json::Value access;
 
       access["kind"] = (*MI)->isRead() ? "read" : "write";
-      access["relation"] = (*MI)->getAccessFunctionStr();
+      access["relation"] = (*MI)->getAccessRelationStr();
 
       statement["accesses"].append(access);
     }
@@ -247,11 +247,11 @@
     return false;
   }
 
-   for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
-     ScopStmt *Stmt = *SI;
+  for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
+    ScopStmt *Stmt = *SI;
 
-     if (NewScattering.find(Stmt) != NewScattering.end())
-       Stmt->setScattering(NewScattering[Stmt]);
+    if (NewScattering.find(Stmt) != NewScattering.end())
+      Stmt->setScattering(NewScattering[Stmt]);
   }
 
   int statementIdx = 0;
@@ -268,15 +268,17 @@
                                   ["accesses"][memoryAccessIdx]["relation"];
       isl_map *newAccessMap = isl_map_read_from_str(S->getIslCtx(),
                                                     accesses.asCString());
-      isl_map *currentAccessMap = (*MI)->getAccessFunction();
+      isl_map *currentAccessMap = (*MI)->getAccessRelation();
       if (!isl_map_has_equal_space(currentAccessMap, newAccessMap)) {
         errs() << "JScop file contains access function with incompatible "
                << "dimensions\n";
+        isl_map_free(currentAccessMap);
         isl_map_free(newAccessMap);
         return false;
       }
       if (isl_map_dim(newAccessMap, isl_dim_out) != 1) {
         errs() << "New access map in JScop file should be single dimensional\n";
+        isl_map_free(currentAccessMap);
         isl_map_free(newAccessMap);
         return false;
       }
@@ -284,10 +286,11 @@
         // Statistics.
         ++NewAccessMapFound;
         newAccessStrings.push_back(accesses.asCString());
-        (*MI)->setNewAccessFunction(newAccessMap);
+        (*MI)->setNewAccessRelation(newAccessMap);
       } else {
         isl_map_free(newAccessMap);
       }
+      isl_map_free(currentAccessMap);
       memoryAccessIdx++;
     }
     statementIdx++;





More information about the llvm-commits mailing list