summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-12-06 20:04:39 -0800
committerOri Bernstein <ori@eigenstate.org>2016-12-06 20:04:39 -0800
commit51567134bf91de89705a64670abae17514ecc55a (patch)
treeceec815d46973d1965cd347681404cd3d22ad9a6 /mi
parent822da329297079d473f20a6fe14c7c2d712cdc83 (diff)
downloadmc-51567134bf91de89705a64670abae17514ecc55a.tar.gz
Reduce memory usage.
Diffstat (limited to 'mi')
-rw-r--r--mi/dfcheck.c1
-rw-r--r--mi/mi.h3
-rw-r--r--mi/reaching.c29
3 files changed, 33 insertions, 0 deletions
diff --git a/mi/dfcheck.c b/mi/dfcheck.c
index 5aeb174..5ccdf58 100644
--- a/mi/dfcheck.c
+++ b/mi/dfcheck.c
@@ -94,6 +94,7 @@ static void checkreach(Cfg *cfg)
bsfree(reach);
bsfree(kill);
}
+ reachingfree(r);
}
static void checkpredret(Cfg *cfg, Bb *bb)
diff --git a/mi/mi.h b/mi/mi.h
index 1a0ab06..6b9be4c 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -33,10 +33,13 @@ struct Reaching {
Bitset **out;
size_t **defs;
size_t *ndefs;
+ size_t nbb;
};
/* dataflow analysis */
Reaching *reaching(Cfg *cfg);
+void reachingfree(Reaching *r);
+
Node *assignee(Node *n);
/* Takes a reduced block, and returns a flow graph. */
diff --git a/mi/reaching.c b/mi/reaching.c
index 8442b19..e1b8090 100644
--- a/mi/reaching.c
+++ b/mi/reaching.c
@@ -139,15 +139,44 @@ Reaching *reaching(Cfg *cfg)
bsfree(out[i]);
in[i] = bbin;
out[i] = bbout;
+ } else {
+ bsfree(bbin);
+ bsfree(bbout);
}
}
} while (changed);
+ for (i = 0; i < cfg->nbb; i++) {
+ bsfree(gen[i]);
+ bsfree(kill[i]);
+ }
+ free(gen);
+ free(kill);
+
reaching = xalloc(sizeof(Reaching));
reaching->in = in;
reaching->out = out;
reaching->defs = defs;
reaching->ndefs = ndefs;
+ reaching->nbb = cfg->nbb;
return reaching;
}
+
+void reachingfree(Reaching *r)
+{
+ size_t i;
+
+ for (i = 0; i < r->nbb; i++) {
+ bsfree(r->in[i]);
+ bsfree(r->out[i]);
+ }
+ for (i = 0; i < ndecls; i++)
+ free(r->defs[i]);
+ free(r->in);
+ free(r->out);
+ free(r->defs);
+ free(r->ndefs);
+ free(r);
+}
+