Browse Source

check for trivial undefined uses in ssacheck

Quentin Carbonneaux 9 years ago
parent
commit
20c9ec62ff
1 changed files with 6 additions and 1 deletions
  1. 6 1
      ssa.c

+ 6 - 1
ssa.c

@@ -536,10 +536,15 @@ ssacheck(Fn *fn)
 	Blk *b, *bu;
 	Blk *b, *bu;
 	Ref r;
 	Ref r;
 
 
-	for (t=&fn->tmp[Tmp0]; t-fn->tmp < fn->ntmp; t++)
+	for (t=&fn->tmp[Tmp0]; t-fn->tmp < fn->ntmp; t++) {
 		if (t->ndef > 1)
 		if (t->ndef > 1)
 			err("ssa temporary %%%s defined more than once",
 			err("ssa temporary %%%s defined more than once",
 				t->name);
 				t->name);
+		if (t->nuse > 0 && t->ndef == 0) {
+			bu = fn->rpo[t->use[0].bid];
+			goto Err;
+		}
+	}
 	for (b=fn->start; b; b=b->link) {
 	for (b=fn->start; b; b=b->link) {
 		for (p=b->phi; p; p=p->link) {
 		for (p=b->phi; p; p=p->link) {
 			r = p->to;
 			r = p->to;