Skip to content

Commit 82432ac

Browse files
SixWeiningtru
authored andcommitted
[libunwind][LoongArch] Restore $r1 before $r4 in jumpto
$ra should be restored before $a0, otherwise the baseaddress ($a0) would be destroyed. See file `UnwindRegistersSave.S` for reference. This also makes libcxx and libcxxabi regtest pass for the `-DLIBCXXABI_USE_LLVM_UNWINDER=ON` build. Reviewed By: MaskRay, xen0n, #libunwind Differential Revision: https://reviews.llvm.org/D147372 (cherry picked from commit ff0aabf)
1 parent ecbc5ca commit 82432ac

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

libunwind/src/UnwindRegistersRestore.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,8 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind19Registers_loongarch6jumptoEv)
12211221
ld.d $r\i, $a0, (8 * \i)
12221222
.endr
12231223

1224-
ld.d $r4, $a0, (8 * 4) // restore $a0 last
1225-
ld.d $r1, $a0, (8 * 32) // load new pc into $ra
1224+
ld.d $ra, $a0, (8 * 32) // load new pc into $ra
1225+
ld.d $a0, $a0, (8 * 4) // restore $a0 last
12261226

12271227
jr $ra
12281228

libunwind/test/unw_resume.pass.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
// TODO: Figure out why this fails with Memory Sanitizer.
1717
// XFAIL: msan
1818

19-
// FIXME: The return address register($ra/$r1) is restored with a destroyed base
20-
// address register($a0/$r4) in the assembly file `UnwindRegistersRestore.S` on
21-
// LoongArch. And we will fix this issue in the next commit.
22-
// XFAIL: target={{loongarch64-.+}}
23-
2419
#include <libunwind.h>
2520

2621
void test_unw_resume() {

0 commit comments

Comments
 (0)