aboutsummaryrefslogtreecommitdiff
path: root/x86_64-gen.c
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji _at_ gmail.com>2009-04-02 01:40:00 +0900
committergrischka <grischka>2009-04-18 15:07:09 +0200
commit06fa15fb9912dde92c61541a759dc217962967b3 (patch)
tree6a01614479db0ceab884309b158f365a08be6fc6 /x86_64-gen.c
parentebb874e2164308b1b9a53a2b1f6d1b9f65894059 (diff)
downloadtinycc-06fa15fb9912dde92c61541a759dc217962967b3.tar.gz
tinycc-06fa15fb9912dde92c61541a759dc217962967b3.tar.bz2
x86-64: Save RDX and RCX before we use them as function parameters.
When the function call is indirect, these registers may be broken to load a function pointer.
Diffstat (limited to 'x86_64-gen.c')
-rw-r--r--x86_64-gen.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/x86_64-gen.c b/x86_64-gen.c
index f3382ae..1cbe414 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -582,6 +582,8 @@ void gfunc_call(int nb_args)
vtop--;
}
+ save_regs(0); /* save used temporary registers */
+
/* Copy R10 and R11 into RDX and RCX, respectively */
if (nb_reg_args > 2) {
o(0xd2894c); /* mov %r10, %rdx */
@@ -590,8 +592,6 @@ void gfunc_call(int nb_args)
}
}
- save_regs(0); /* save used temporary registers */
-
func_sym = vtop->type.ref;
func_call = FUNC_CALL(func_sym->r);
oad(0xb8, nb_sse_args < 8 ? nb_sse_args : 8); /* mov nb_sse_args, %eax */