diff options
author | Michael Kruse <llvm@meinersbur.de> | 2016-09-01 19:16:58 +0000 |
---|---|---|
committer | Michael Kruse <llvm@meinersbur.de> | 2016-09-01 19:16:58 +0000 |
commit | 772ce7200085db8cea395b3b962b8c9496cb9845 (patch) | |
tree | b4071a10dffae6c0980596f0896cfccebbe471eb | |
parent | 199a8e6a9237370b031685f216be5868ee43631c (diff) | |
download | bcm5719-llvm-772ce7200085db8cea395b3b962b8c9496cb9845.tar.gz bcm5719-llvm-772ce7200085db8cea395b3b962b8c9496cb9845.zip |
Check validity of new access relations. NFC.
There are some constraints on maps that can be access relations. In builds with assertions enabled, verify
- The access domain is the same space as the statement's domain (modulo parameters).
- Whether an access is defined for every instance of the statement. (codegen does not yet support partial access relations)
- Whether the access range links to an array, represented by a ScopArrayInfo.
- The number of access dimensions equals the dimensions of the array.
- The array is not an indirect access. (also not supported by codegen)
Differential Revision: https://reviews.llvm.org/D23916
llvm-svn: 280404
-rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 40eb6fb3a42..8ae04e8f96f 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -963,6 +963,44 @@ bool MemoryAccess::isStrideOne(__isl_take const isl_map *Schedule) const { } void MemoryAccess::setNewAccessRelation(__isl_take isl_map *NewAccess) { + assert(NewAccess); + +#ifndef NDEBUG + // Check domain space compatibility. + auto *NewSpace = isl_map_get_space(NewAccess); + auto *NewDomainSpace = isl_space_domain(isl_space_copy(NewSpace)); + auto *OriginalDomainSpace = getStatement()->getDomainSpace(); + assert(isl_space_has_equal_tuples(OriginalDomainSpace, NewDomainSpace)); + isl_space_free(NewDomainSpace); + isl_space_free(OriginalDomainSpace); + + // Check whether there is an access for every statement instance. + auto *StmtDomain = getStatement()->getDomain(); + StmtDomain = isl_set_intersect_params( + StmtDomain, getStatement()->getParent()->getContext()); + auto *NewDomain = isl_map_domain(isl_map_copy(NewAccess)); + assert(isl_set_is_subset(StmtDomain, NewDomain) && + "Partial accesses not supported"); + isl_set_free(NewDomain); + isl_set_free(StmtDomain); + + // Check whether access dimensions correspond to number of dimensions of the + // accesses array. + auto *NewAccessSpace = isl_space_range(NewSpace); + assert(isl_space_has_tuple_id(NewAccessSpace, isl_dim_set) && + "Must specify the array that is accessed"); + auto *NewArrayId = isl_space_get_tuple_id(NewAccessSpace, isl_dim_set); + auto *SAI = static_cast<ScopArrayInfo *>(isl_id_get_user(NewArrayId)); + assert(SAI && "Must set a ScopArrayInfo"); + assert(!SAI->getBasePtrOriginSAI() && + "Indirect array not supported by codegen"); + auto Dims = SAI->getNumberOfDimensions(); + assert(isl_space_dim(NewAccessSpace, isl_dim_set) == Dims && + "Access dims must match array dims"); + isl_space_free(NewAccessSpace); + isl_id_free(NewArrayId); +#endif + isl_map_free(NewAccessRelation); NewAccessRelation = NewAccess; } |