[polly] r292120 - ScopInfo: Extract out buildAliasGroupsForAccesses [NFC]
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 16 06:07:57 PST 2017
Author: grosser
Date: Mon Jan 16 08:07:57 2017
New Revision: 292120
URL: http://llvm.org/viewvc/llvm-project?rev=292120&view=rev
Log:
ScopInfo: Extract out buildAliasGroupsForAccesses [NFC]
The function buildAliasGroups got very large. We extract out the actual
construction of alias groups to reduce its size and to better document the
current behavior.
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=292120&r1=292119&r2=292120&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Mon Jan 16 08:07:57 2017
@@ -2270,6 +2270,12 @@ public:
return isl_set_is_empty(InvalidContext);
}
+ /// A vector of memory accesses that belong to an alias group.
+ typedef SmallVector<MemoryAccess *, 4> AliasGroupTy;
+
+ /// A vector of alias groups.
+ typedef SmallVector<Scop::AliasGroupTy, 4> AliasGroupVectorTy;
+
/// Build the alias checks for this SCoP.
bool buildAliasChecks(AliasAnalysis &AA);
@@ -2278,6 +2284,21 @@ public:
/// @returns True if __no__ error occurred, false otherwise.
bool buildAliasGroups(AliasAnalysis &AA);
+ /// Build alias groups for all memory accesses in the Scop.
+ ///
+ /// Using the alias analysis and an alias set tracker we build alias sets
+ /// for all memory accesses inside the Scop. For each alias set we then map
+ /// the aliasing pointers back to the memory accesses we know, thus obtain
+ /// groups of memory accesses which might alias. We also collect the set of
+ /// base pointers through which memory is written.
+ ///
+ /// @param AA A reference to the alias analysis.
+ ///
+ /// @returns A pair consistent of a vector of alias groups and a set of values
+ /// that are used as base pointers for write accesses.
+ std::tuple<AliasGroupVectorTy, DenseSet<Value *>>
+ buildAliasGroupsForAccesses(AliasAnalysis &AA);
+
/// Return all alias groups for this SCoP.
const MinMaxVectorPairVectorTy &getAliasGroups() const {
return MinMaxAliasGroups;
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=292120&r1=292119&r2=292120&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Mon Jan 16 08:07:57 2017
@@ -2893,33 +2893,19 @@ bool Scop::buildAliasChecks(AliasAnalysi
return false;
}
-bool Scop::buildAliasGroups(AliasAnalysis &AA) {
- // To create sound alias checks we perform the following steps:
- // o) Use the alias analysis and an alias set tracker to build alias sets
- // for all memory accesses inside the SCoP.
- // o) For each alias set we then map the aliasing pointers back to the
- // memory accesses we know, thus obtain groups of memory accesses which
- // might alias.
- // o) We divide each group based on the domains of the minimal/maximal
- // accesses. That means two minimal/maximal accesses are only in a group
- // if their access domains intersect, otherwise they are in different
- // ones.
- // o) We partition each group into read only and non read only accesses.
- // o) For each group with more than one base pointer we then compute minimal
- // and maximal accesses to each array of a group in read only and non
- // read only partitions separately.
- using AliasGroupTy = SmallVector<MemoryAccess *, 4>;
-
+std::tuple<Scop::AliasGroupVectorTy, DenseSet<Value *>>
+Scop::buildAliasGroupsForAccesses(AliasAnalysis &AA) {
AliasSetTracker AST(AA);
DenseMap<Value *, MemoryAccess *> PtrToAcc;
DenseSet<Value *> HasWriteAccess;
for (ScopStmt &Stmt : *this) {
- // Skip statements with an empty domain as they will never be executed.
isl_set *StmtDomain = Stmt.getDomain();
bool StmtDomainEmpty = isl_set_is_empty(StmtDomain);
isl_set_free(StmtDomain);
+
+ // Statements with an empty domain will never be executed.
if (StmtDomainEmpty)
continue;
@@ -2937,7 +2923,7 @@ bool Scop::buildAliasGroups(AliasAnalysi
}
}
- SmallVector<AliasGroupTy, 4> AliasGroups;
+ AliasGroupVectorTy AliasGroups;
for (AliasSet &AS : AST) {
if (AS.isMustAlias() || AS.isForwardingAliasSet())
continue;
@@ -2949,6 +2935,24 @@ bool Scop::buildAliasGroups(AliasAnalysi
AliasGroups.push_back(std::move(AG));
}
+ return std::make_tuple(AliasGroups, HasWriteAccess);
+}
+
+bool Scop::buildAliasGroups(AliasAnalysis &AA) {
+ // To create sound alias checks we perform the following steps:
+ // o) We divide each group based on the domains of the minimal/maximal
+ // accesses. That means two minimal/maximal accesses are only in a group
+ // if their access domains intersect, otherwise they are in different
+ // ones.
+ // o) We partition each group into read only and non read only accesses.
+ // o) For each group with more than one base pointer we then compute minimal
+ // and maximal accesses to each array of a group in read only and non
+ // read only partitions separately.
+ AliasGroupVectorTy AliasGroups;
+ DenseSet<Value *> HasWriteAccess;
+
+ std::tie(AliasGroups, HasWriteAccess) = buildAliasGroupsForAccesses(AA);
+
// Split the alias groups based on their domain.
for (unsigned u = 0; u < AliasGroups.size(); u++) {
AliasGroupTy NewAG;
More information about the llvm-commits
mailing list