summary refs log tree commit diff
path: root/lisc/isel.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-14 18:06:53 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:33 -0400
commitbad74e6dce897df9f21cea5bf0a32df298856351 (patch)
tree09399d0568c8a6af0528e7f91bfbefc352197b09 /lisc/isel.c
parentee46ff8dad6782a739fefd176e55a70754787917 (diff)
downloadroux-bad74e6dce897df9f21cea5bf0a32df298856351.tar.gz
emit stack fixup only when necessary
Diffstat (limited to 'lisc/isel.c')
-rw-r--r--lisc/isel.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lisc/isel.c b/lisc/isel.c
index 6d15488..6928a1a 100644
--- a/lisc/isel.c
+++ b/lisc/isel.c
@@ -500,11 +500,13 @@ selcall(Fn *fn, Ins *i0, Ins *i1)
 	if (rtype(i1->arg[1]) == RTyp)
 		diag("struct-returning function not implemented");
 
+	if (stk) {
+		r = newcon(-(int64_t)stk, fn);
+		emit(OSAlloc, 0, R, r, R);
+	}
 	for (n=0; n<8; n++)
 		emit(OCopy, 0, R, TMP(ireg[n]), R);
 	emit(OCopy, i1->wide, i1->to, TMP(RAX), R);
-	r = newcon(-(int64_t)stk, fn);
-	emit(OSAlloc, 0, R, r, R);
 	emit(OCall, 0, R, i->arg[0], R);
 	emit(OCopy, 1, TMP(RAX), R, R);
 	for (n=6-nint; n<8; n++)