Skip to content

Commit 6c03831

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Calculate stored register size based upon independent gp and vecd sizes
Summary: We use pairs of stores which keep the stack aligned in saveCalleeSavedRegsAarch64 and when there's an odd number we store a single register in 16-bytes of stack space. This updates the size calculation to account for this. Reviewed By: alexmalyshev Differential Revision: D93637622 fbshipit-source-id: d61af0676979804ca66947acc1a21cc136ee4c15
1 parent dfd6a8a commit 6c03831

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

cinderx/Jit/codegen/gen_asm.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@ class NativeGenerator {
108108
#if defined(CINDER_X86_64)
109109
return saved_regs.count() * kPointerSize;
110110
#elif defined(CINDER_AARCH64)
111-
return ((saved_regs.count() + 1) / 2) * kStackAlign;
111+
// GP and VecD registers cannot be paired in the same stp/ldp
112+
// instruction, so each group must be independently rounded up to
113+
// a pair count to match saveCalleeSavedRegsAarch64.
114+
auto gp_count = (saved_regs & ALL_GP_REGISTERS).count();
115+
auto vecd_count = (saved_regs & ALL_VECD_REGISTERS).count();
116+
return (((gp_count + 1) / 2) + ((vecd_count + 1) / 2)) * kStackAlign;
112117
#else
113118
CINDER_UNSUPPORTED
114119
return saved_regs.count() * kPointerSize;

0 commit comments

Comments
 (0)