summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-05-06 19:52:19 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-05-06 19:52:19 +0000
commitd5a7bfc51dfc951e72a187ba7d24ec3e6fdb6e6f (patch)
tree2a6e9e1baa2ea2fcf5514d9f31a80bd88cbc49d1
parent69f8514cb79a5a9f89a7a01c8ab9eb8f855fdeee (diff)
downloadbcm5719-llvm-d5a7bfc51dfc951e72a187ba7d24ec3e6fdb6e6f.tar.gz
bcm5719-llvm-d5a7bfc51dfc951e72a187ba7d24ec3e6fdb6e6f.zip
ScopInfo: Do not return reference to member variable 'domain'.
Instead of returning a pointer to the domain, we return a new copy of it. This is safer, as we do not give access to internal objects. It is also not expensive, as isl will just increment a reference counter. llvm-svn: 131010
-rwxr-xr-xpolly/include/polly/ScopInfo.h2
-rw-r--r--polly/lib/Analysis/Dependences.cpp2
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp9
-rw-r--r--polly/lib/Cloog.cpp2
-rwxr-xr-xpolly/lib/Exchange/OpenScopExporter.cpp4
-rw-r--r--polly/lib/Exchange/ScopLib.cpp4
6 files changed, 17 insertions, 6 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 4d4666b3acc..d8398c40fc1 100755
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -278,7 +278,7 @@ public:
/// @brief Get the iteration domain of this ScopStmt.
///
/// @return The iteration domain of this ScopStmt.
- isl_set *getDomain() const { return Domain; }
+ isl_set *getDomain() const;
/// @brief Get an isl string representing this domain.
std::string getDomainStr() const;
diff --git a/polly/lib/Analysis/Dependences.cpp b/polly/lib/Analysis/Dependences.cpp
index 74d23df4075..4de38804c43 100644
--- a/polly/lib/Analysis/Dependences.cpp
+++ b/polly/lib/Analysis/Dependences.cpp
@@ -96,7 +96,7 @@ bool Dependences::runOnScop(Scop &S) {
for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(),
ME = Stmt->memacc_end(); MI != ME; ++MI) {
- isl_set *domcp = isl_set_copy(Stmt->getDomain());
+ isl_set *domcp = Stmt->getDomain();
isl_map *accdom = isl_map_copy((*MI)->getAccessFunction());
accdom = isl_map_intersect_domain(accdom, domcp);
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 1cf1930419a..41dc3eeaae7 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -650,7 +650,10 @@ ScopStmt::ScopStmt(Scop &parent, SmallVectorImpl<unsigned> &Scatter)
}
std::string ScopStmt::getDomainStr() const {
- return stringFromIslObj(getDomain());
+ isl_set *domain = getDomain();
+ std::string string = stringFromIslObj(domain);
+ isl_set_free(domain);
+ return string;
}
std::string ScopStmt::getScatteringStr() const {
@@ -695,6 +698,10 @@ isl_ctx *ScopStmt::getIslContext() {
return Parent.getCtx();
}
+isl_set *ScopStmt::getDomain() const {
+ return isl_set_copy(Domain);
+}
+
ScopStmt::~ScopStmt() {
while (!MemAccs.empty()) {
delete MemAccs.back();
diff --git a/polly/lib/Cloog.cpp b/polly/lib/Cloog.cpp
index 98d72f8d151..b020adc0cfc 100644
--- a/polly/lib/Cloog.cpp
+++ b/polly/lib/Cloog.cpp
@@ -161,7 +161,7 @@ CloogUnionDomain *Cloog::buildCloogUnionDomain() {
CloogScattering *Scattering=
cloog_scattering_from_isl_map(isl_map_copy(Stmt->getScattering()));
CloogDomain *Domain =
- cloog_domain_from_isl_set(isl_set_copy(Stmt->getDomain()));
+ cloog_domain_from_isl_set(Stmt->getDomain());
std::string entryName = Stmt->getBaseName();
char *Name = (char*)malloc(sizeof(char) * (entryName.size() + 1));
diff --git a/polly/lib/Exchange/OpenScopExporter.cpp b/polly/lib/Exchange/OpenScopExporter.cpp
index 93d0b556ca0..71188e54e0a 100755
--- a/polly/lib/Exchange/OpenScopExporter.cpp
+++ b/polly/lib/Exchange/OpenScopExporter.cpp
@@ -143,8 +143,10 @@ openscop_statement_p OpenScop::initializeStatement(ScopStmt *stmt) {
openscop_statement_p Stmt = openscop_statement_malloc();
// Domain & Schedule
- Stmt->domain = domainToMatrix(stmt->getDomain());
+ isl_set *domain = stmt->getDomain();
+ Stmt->domain = domainToMatrix(domain);
Stmt->schedule = scatteringToMatrix(stmt->getScattering());
+ isl_set_free(domain);
// Statement name
const char* entryName = stmt->getBaseName();
diff --git a/polly/lib/Exchange/ScopLib.cpp b/polly/lib/Exchange/ScopLib.cpp
index cdff56742ea..98ffbaf4a88 100644
--- a/polly/lib/Exchange/ScopLib.cpp
+++ b/polly/lib/Exchange/ScopLib.cpp
@@ -88,10 +88,12 @@ scoplib_statement_p ScopLib::initializeStatement(ScopStmt *stmt) {
scoplib_statement_p Stmt = scoplib_statement_malloc();
// Domain & Schedule
+ isl_set *domain = stmt->getDomain();
Stmt->domain = scoplib_matrix_list_malloc();
- Stmt->domain->elt = domainToMatrix(stmt->getDomain());
+ Stmt->domain->elt = domainToMatrix(domain);
Stmt->domain->next = NULL;
Stmt->schedule = scatteringToMatrix(stmt->getScattering());
+ isl_set_free(domain);
// Statement name
std::string entryName;
OpenPOWER on IntegriCloud