summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeining Lu <luweining@loongson.cn>2023-04-07 13:38:44 +0800
committerTobias Hieta <tobias@hieta.se>2023-04-17 16:25:59 +0200
commit82432ac5cc7d824328a9b59d73cdbd3ca1e9a07d (patch)
treee65592faa5137199a87f39f872c830ccee13e375
parentecbc5ca533cd45a0d9741c87ada3c5ce2cd18f9a (diff)
downloadllvm-82432ac5cc7d824328a9b59d73cdbd3ca1e9a07d.tar.gz
[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 ff0aabf14dfa0a369c38f6e267c56a83ee48d647)
-rw-r--r--libunwind/src/UnwindRegistersRestore.S4
-rw-r--r--libunwind/test/unw_resume.pass.cpp5
2 files changed, 2 insertions, 7 deletions
diff --git a/libunwind/src/UnwindRegistersRestore.S b/libunwind/src/UnwindRegistersRestore.S
index 543b19f7e72a..951189ea54dd 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -1221,8 +1221,8 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind19Registers_loongarch6jumptoEv)
ld.d $r\i, $a0, (8 * \i)
.endr
- ld.d $r4, $a0, (8 * 4) // restore $a0 last
- ld.d $r1, $a0, (8 * 32) // load new pc into $ra
+ ld.d $ra, $a0, (8 * 32) // load new pc into $ra
+ ld.d $a0, $a0, (8 * 4) // restore $a0 last
jr $ra
diff --git a/libunwind/test/unw_resume.pass.cpp b/libunwind/test/unw_resume.pass.cpp
index e652620a4a05..76273e4a8ef0 100644
--- a/libunwind/test/unw_resume.pass.cpp
+++ b/libunwind/test/unw_resume.pass.cpp
@@ -16,11 +16,6 @@
// TODO: Figure out why this fails with Memory Sanitizer.
// XFAIL: msan
-// FIXME: The return address register($ra/$r1) is restored with a destroyed base
-// address register($a0/$r4) in the assembly file `UnwindRegistersRestore.S` on
-// LoongArch. And we will fix this issue in the next commit.
-// XFAIL: target={{loongarch64-.+}}
-
#include <libunwind.h>
void test_unw_resume() {