summaryrefslogtreecommitdiffstats
path: root/polly/lib/Cloog.cpp
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-08-20 11:11:25 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-08-20 11:11:25 +0000
commitb76f385334405e6517ee60b5dfdf569ff4e94f1f (patch)
treef1bd4056fc00da863dd7ebdbb9967686883329ca /polly/lib/Cloog.cpp
parent15f5efff8f44ccbb3c1f184bbd858c2b7ff5be4f (diff)
downloadbcm5719-llvm-b76f385334405e6517ee60b5dfdf569ff4e94f1f.tar.gz
bcm5719-llvm-b76f385334405e6517ee60b5dfdf569ff4e94f1f.zip
Free isl_ctx and fix several memory leaks
Because of me not understanding the LLVM pass structure well, I did not find a good way to allocate isl_ctx and to free it later without getting issues with reference counting. I now found this place, such that we can free isl_ctx. This patch also fixes the memory leaks that were ignored beforehand. llvm-svn: 138204
Diffstat (limited to 'polly/lib/Cloog.cpp')
-rw-r--r--polly/lib/Cloog.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/polly/lib/Cloog.cpp b/polly/lib/Cloog.cpp
index aa1ac9f5c58..cf403fc39b8 100644
--- a/polly/lib/Cloog.cpp
+++ b/polly/lib/Cloog.cpp
@@ -30,6 +30,7 @@
#include "llvm/Module.h"
#include "cloog/isl/domain.h"
+#include "cloog/isl/cloog.h"
using namespace llvm;
using namespace polly;
@@ -61,14 +62,14 @@ public:
};
Cloog::Cloog(Scop *Scop) : S(Scop) {
- State = cloog_state_malloc();
+ State = cloog_isl_state_malloc(Scop->getCtx());
buildCloogOptions();
ClastRoot = cloog_clast_create_from_input(buildCloogInput(), Options);
}
Cloog::~Cloog() {
- cloog_options_free(Options);
cloog_clast_free(ClastRoot);
+ cloog_options_free(Options);
cloog_state_free(State);
}
@@ -164,10 +165,9 @@ CloogUnionDomain *Cloog::buildCloogUnionDomain() {
cloog_domain_from_isl_set(Stmt->getDomain());
std::string entryName = Stmt->getBaseName();
- char *Name = (char*)malloc(sizeof(char) * (entryName.size() + 1));
- strcpy(Name, entryName.c_str());
- DU = cloog_union_domain_add_domain(DU, Name, Domain, Scattering, Stmt);
+ DU = cloog_union_domain_add_domain(DU, entryName.c_str(), Domain,
+ Scattering, Stmt);
}
return DU;
@@ -265,6 +265,13 @@ const struct clast_root *CloogInfo::getClast() {
return C->getClast();
}
+void CloogInfo::releaseMemory() {
+ if (C) {
+ delete C;
+ C = 0;
+ }
+}
+
bool CloogInfo::runOnScop(Scop &S) {
if (C)
delete C;
OpenPOWER on IntegriCloud