master: arm64, struct-by-value: don't split stack/registers in callbacks

stassats via Sbcl-commits <[email protected]>
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  0cb8e863d1080c96c243428cfe4628f86a63fdfb (commit)
      from  2c30eafc7e483a873b46edfcf3346e0c4a17cf4e (commit)

- Log -----------------------------------------------------------------
commit 0cb8e863d1080c96c243428cfe4628f86a63fdfb
Author: Stas Boukarev <[email protected]>
Date:   Thu Apr 23 11:18:28 2026 +0300

    arm64, struct-by-value: don't split stack/registers in callbacks
---
 src/compiler/arm64/c-call.lisp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/compiler/arm64/c-call.lisp b/src/compiler/arm64/c-call.lisp
index f2b67b8da..3140eb516 100644
--- a/src/compiler/arm64/c-call.lisp
+++ b/src/compiler/arm64/c-call.lisp
@@ -389,8 +389,7 @@
                                 (list off)))))))
                 (stack
                  (let* ((bytes (ceiling (sb-alien::alien-type-bits type) n-byte-bits))
-                        (words (/ (sb-alien::struct-classification-size classification)
-                                  n-word-bytes))
+                        (words (ceiling (sb-alien::struct-classification-size classification) n-word-bytes))
                         (arg-tns (loop repeat words
                                        collect (int-arg state 'unsigned-byte-64
                                                         unsigned-reg-sc-number
@@ -723,13 +722,13 @@
                                 target-tn))
                          (t
                           (setf stack-argument-bytes
-                                  (align-up stack-argument-bytes size))
+                                (align-up stack-argument-bytes size))
                           (case size
                             #+darwin
                             (4
                              (let ((reg (32-bit-reg temp-tn)))
-                              (inst ldr reg (@ nsp-save-tn stack-argument-bytes))
-                              (inst str reg target-tn)))
+                               (inst ldr reg (@ nsp-save-tn stack-argument-bytes))
+                               (inst str reg target-tn)))
                             (t
                              (inst ldr temp-tn (@ nsp-save-tn stack-argument-bytes))
                              (inst str temp-tn target-tn)))
@@ -802,6 +801,9 @@
                        ;; Small non-HFA struct (<=16 bytes): passed in GPRs
                        (t
                         (let ((num-regs (ceiling struct-bytes 8)))
+                          ;; Don't mix stack/registers
+                          (when (< (length gprs) num-regs)
+                            (setf gprs nil))
                           (dotimes (i num-regs)
                             (let ((gpr (pop gprs)))
                               (cond (gpr

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.