summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-19 11:07:07 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-19 11:07:54 -0400
commit43967b6306aa18903b3ba2b00e701facaf306840 (patch)
tree146330b3da69d9a27f83fe1db93dd09f2c0a6764
parent20c9ec62ffde331fad41c5f05cc05a20b7aa08fa (diff)
downloadroux-43967b6306aa18903b3ba2b00e701facaf306840.tar.gz
use assert for ssa invariants in fold/copy
-rw-r--r--copy.c12
-rw-r--r--fold.c4
2 files changed, 7 insertions, 9 deletions
diff --git a/copy.c b/copy.c
index 0ed62b0..71720f9 100644
--- a/copy.c
+++ b/copy.c
@@ -65,11 +65,9 @@ visitins(Ins *i, Ref *cp, RList **w)
 }
 
 static void
-subst(Ref *r, Ref *cp, Fn *fn)
+subst(Ref *r, Ref *cp)
 {
-	if (rtype(*r) == RTmp && req(copyof(*r, cp), R))
-		err("temporary %%%s is ill-defined",
-			fn->tmp[r->val].name);
+	assert((rtype(*r) != RTmp || !req(copyof(*r, cp), R)) && "ssa invariant broken");
 	*r = copyof(*r, cp);
 }
 
@@ -121,7 +119,7 @@ copy(Fn *fn)
 				continue;
 			}
 			for (a=0; a<p->narg; a++)
-				subst(&p->arg[a], cp, fn);
+				subst(&p->arg[a], cp);
 			pp=&p->link;
 		}
 		for (i=b->ins; i-b->ins < b->nins; i++) {
@@ -131,9 +129,9 @@ copy(Fn *fn)
 				continue;
 			}
 			for (a=0; a<2; a++)
-				subst(&i->arg[a], cp, fn);
+				subst(&i->arg[a], cp);
 		}
-		subst(&b->jmp.arg, cp, fn);
+		subst(&b->jmp.arg, cp);
 	}
 	if (debug['C']) {
 		fprintf(stderr, "\n> Copy information:");
diff --git a/fold.c b/fold.c
index 2c72999..3adb56b 100644
--- a/fold.c
+++ b/fold.c
@@ -126,7 +126,7 @@ visitjmp(Blk *b, int n, Fn *fn)
 	switch (b->jmp.type) {
 	case JJnz:
 		l = latval(b->jmp.arg);
-		assert(l != Top);
+		assert(l != Top && "ssa invariant broken");
 		if (l == Bot) {
 			edge[n][1].work = flowrk;
 			edge[n][0].work = &edge[n][1];
@@ -172,7 +172,7 @@ renref(Ref *r)
 
 	if (rtype(*r) == RTmp)
 		if ((l=val[r->val]) != Bot) {
-			assert(l != Top);
+			assert(l != Top && "ssa invariant broken");
 			*r = CON(l);
 			return 1;
 		}