From 6a0ed71107670b404af04bc20a2461165483f390 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 13 Sep 2020 16:25:34 +0900 Subject: [PATCH] Align stack frame to 16 byte boundaries --- codegen.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/codegen.c b/codegen.c index e29302a..819c10a 100644 --- a/codegen.c +++ b/codegen.c @@ -283,7 +283,14 @@ static void gen_expr(Node *node) { pop(argreg64[i]); println(" mov $0, %%rax"); - println(" call %s", node->funcname); + + if (depth % 2 == 0) { + println(" call %s", node->funcname); + } else { + println(" sub $8, %%rsp"); + println(" call %s", node->funcname); + println(" add $8, %%rsp"); + } return; } }