aboutsummaryrefslogtreecommitdiffhomepage
path: root/amd64
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-11-22 19:32:24 +0100
committerlemon <lsof@mailbox.org>2025-11-22 19:40:25 +0100
commitd030198aea96012b635b559fc6021fd954205395 (patch)
treed4105f373c5b38f6b8bc680cf7c919602bd9945e /amd64
parent8cf560c502542af972eabd201a5b7bf05c891078 (diff)
make sure indirect function call pointer does not end up in clobber reg
Diffstat (limited to 'amd64')
-rw-r--r--amd64/isel.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/amd64/isel.c b/amd64/isel.c
index 6541c10..26ee6e0 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -147,6 +147,11 @@ selcall(struct function *fn, struct instr *ins, struct block *blk, int *curi)
++*curi;
insertinstr(blk, *curi+1, (struct instr){Oadd, KPTR, .keep=1, .reg = RSP+1, .l=mkref(RREG,RSP), disp});
}
+ if (call->vararg >= 0 && ins->l.t == RTMP) {
+ /* variadic calls write number of sse regs used to AL, so mark it as clobbered such that
+ * the function pointer of an indirect calls does not get allocated to RAX by regalloc */
+ insertinstr(blk, (*curi)++, mkinstr(Omove, KPTR, mkref(RREG, RAX), mkref(RREG, RAX)));
+ }
cls = ins->cls;
ins->cls = 0;
if (cls) {