@@ -129,6 +129,8 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
129129 // First, get the FDE for the old location and then update it.
130130 co->getInfo (&info);
131131
132+ pint_t sp = (pint_t )co->getReg (UNW_REG_SP);
133+
132134#if __has_feature(ptrauth_calls)
133135 // It is only valid to set the IP within the current function.
134136 // This is important for ptrauth, otherwise the IP cannot be correctly
@@ -137,8 +139,6 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
137139 (unw_word_t )ptrauth_strip ((void *)value, ptrauth_key_return_address);
138140 assert (stripped_value >= info.start_ip && stripped_value <= info.end_ip );
139141
140- pint_t sp = (pint_t )co->getReg (UNW_REG_SP);
141-
142142 {
143143 // PC should have been signed with the sp, so we verify that
144144 // roundtripping does not fail.
@@ -162,7 +162,7 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
162162 // this should actually be - info.gp. LLVM doesn't currently support
163163 // any such platforms and Clang doesn't export a macro for them.
164164 if (info.gp )
165- co->setReg (UNW_REG_SP, co-> getReg (UNW_REG_SP) + info.gp );
165+ co->setReg (UNW_REG_SP, sp + info.gp );
166166 co->setReg (UNW_REG_IP, value);
167167 co->setInfoBasedOnIPRegister (false );
168168 } else {
0 commit comments