summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-21 19:53:12 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-21 19:53:12 -0400
commit95d9a335df2deb197ae9a74abc755694a7158462 (patch)
tree089b02c9b59bb3a78fc3c3858c861355eeeefd3d
parentff607f1a1e4d8f15adb075e427b4b9ea0ad34c03 (diff)
downloadroux-95d9a335df2deb197ae9a74abc755694a7158462.tar.gz
fix rega bug for indirect calls
-rw-r--r--lisc/rega.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/lisc/rega.c b/lisc/rega.c
index 66836be..e1f0a6d 100644
--- a/lisc/rega.c
+++ b/lisc/rega.c
@@ -327,24 +327,28 @@ rega(Fn *fn)
 				for (r=0; r<NRSave; r++)
 					if (!(BIT(rsave[r]) & rs))
 						rfree(&cur, rsave[r]);
-				continue;
+				r = 0;
+				break;
 			case OCopy:
-				if (!isreg(i->arg[0]))
-					break;
-				i = dopm(b, i, &cur);
-				continue;
-			}
-			if (!req(i->to, R)) {
-				assert(rtype(i->to) == RTmp);
-				r = rfree(&cur, i->to.val);
-				if (r == -1) {
-					*i = (Ins){.op = ONop};
+				if (isreg(i->arg[0])) {
+					i = dopm(b, i, &cur);
 					continue;
 				}
-				if (i->to.val >= Tmp0)
-					i->to = TMP(r);
-			} else
-				r = 0;
+				/* fall through */
+			default:
+				if (!req(i->to, R)) {
+					assert(rtype(i->to) == RTmp);
+					r = rfree(&cur, i->to.val);
+					if (r == -1) {
+						*i = (Ins){.op = ONop};
+						continue;
+					}
+					if (i->to.val >= Tmp0)
+						i->to = TMP(r);
+				} else
+					r = 0;
+				break;
+			}
 			for (x=0; x<2; x++)
 				if (rtype(i->arg[x]) == RTmp) {
 					/* <arch>