summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-05-08 20:22:21 -0700
committerOri Bernstein <ori@eigenstate.org>2015-05-08 20:22:21 -0700
commit927294f0ffc7029440111a48200aa2d476545650 (patch)
tree5be5286364828f7ae0fef88437aa941db39d45e9 /mi
parent1cb86ecfd69335631474bea4bb8a102e4559408a (diff)
downloadmc-927294f0ffc7029440111a48200aa2d476545650.tar.gz
Use before def checking is closer to working.
Reduce spurious errors.
Diffstat (limited to 'mi')
-rw-r--r--mi/dfcheck.c21
-rw-r--r--mi/reaching.c7
2 files changed, 23 insertions, 5 deletions
diff --git a/mi/dfcheck.c b/mi/dfcheck.c
index a5fc7c9..fbd536d 100644
--- a/mi/dfcheck.c
+++ b/mi/dfcheck.c
@@ -17,12 +17,16 @@ static void checkundef(Node *n, Reaching *r, Bitset *reach, Bitset *kill)
{
size_t i, j, did;
Node *def;
+ Type *t;
if (n->type != Nexpr)
return;
if (exprop(n) == Ovar) {
did = n->expr.did;
for (j = 0; j < r->ndefs[did]; j++) {
+ t = tybase(exprtype(n));
+ if (t->type == Tystruct || t->type == Tyunion || t->type == Tyarray || t->type == Tytuple)
+ continue;
if (bshas(kill, r->defs[did][j]))
continue;
if (!bshas(reach, r->defs[did][j]))
@@ -38,6 +42,17 @@ static void checkundef(Node *n, Reaching *r, Bitset *reach, Bitset *kill)
case Oblit:
checkundef(n->expr.args[1], r, reach, kill);
break;
+ case Oaddr:
+ case Oslice:
+ /* these don't actually look at the of args[0], so they're ok. */
+ for (i = 1; i < n->expr.nargs; i++)
+ checkundef(n->expr.args[i], r, reach, kill);
+ break;
+ case Ocall:
+ for (i = 1; i < n->expr.nargs; i++)
+ if (exprop(n->expr.args[i]) != Oaddr)
+ checkundef(n->expr.args[i], r, reach, kill);
+ break;
default:
for (i = 0; i < n->expr.nargs; i++)
checkundef(n->expr.args[i], r, reach, kill);
@@ -55,8 +70,11 @@ static void checkreach(Cfg *cfg)
Bb *bb;
r = reaching(cfg);
+// dumpcfg(cfg, stdout);
for (i = 0; i < cfg->nbb; i++) {
bb = cfg->bb[i];
+ if (!bb)
+ continue;
reach = bsdup(r->in[i]);
kill = mkbs();
for (j = 0; j < bb->nnl; j++) {
@@ -110,6 +128,5 @@ static void checkret(Cfg *cfg)
void check(Cfg *cfg)
{
checkret(cfg);
- if (0)
- checkreach(cfg);
+ if(0) checkreach(cfg);
}
diff --git a/mi/reaching.c b/mi/reaching.c
index fbfcd05..01bd798 100644
--- a/mi/reaching.c
+++ b/mi/reaching.c
@@ -18,7 +18,7 @@ Node *assignee(Node *n)
Node *a;
switch (exprop(n)) {
- case Oundef:
+ case Oundef: case Odef:
case Oset:
case Oasn: case Oaddeq:
case Osubeq: case Omuleq:
@@ -29,10 +29,11 @@ Node *assignee(Node *n)
return n->expr.args[0];
break;
case Oblit:
+ case Oclear:
a = n->expr.args[0];
if (exprop(a) != Oaddr)
break;
- a = n->expr.args[0];
+ a = a->expr.args[0];
if (exprop(a) != Ovar)
break;
return a;
@@ -156,7 +157,7 @@ Reaching *reaching(Cfg *cfg)
// printf("\tout: ");
// bsdump(out[i]);
// }
-//
+
reaching = xalloc(sizeof(Reaching));
reaching->in = in;
reaching->out = out;