summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--6/ra.c1
-rw-r--r--mi/dfcheck.c1
-rw-r--r--mi/mi.h3
-rw-r--r--mi/reaching.c29
4 files changed, 34 insertions, 0 deletions
diff --git a/6/ra.c b/6/ra.c
index b80e0fc..cc663dd 100644
--- a/6/ra.c
+++ b/6/ra.c
@@ -662,6 +662,7 @@ static void enablemove(Isel *s, regid n)
}
}
}
+ free(il);
}
static void decdegree(Isel *s, regid m)
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);
+}
+