[libunwind] ff0aabf - [libunwind][LoongArch] Restore $r1 before $r4 in `jumpto`

Weining Lu via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 6 22:43:55 PDT 2023


Author: Weining Lu
Date: 2023-04-07T13:42:23+08:00
New Revision: ff0aabf14dfa0a369c38f6e267c56a83ee48d647

URL: https://github.com/llvm/llvm-project/commit/ff0aabf14dfa0a369c38f6e267c56a83ee48d647
DIFF: https://github.com/llvm/llvm-project/commit/ff0aabf14dfa0a369c38f6e267c56a83ee48d647.diff

LOG: [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

Added: 
    

Modified: 
    libunwind/src/UnwindRegistersRestore.S
    libunwind/test/unw_resume.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libunwind/src/UnwindRegistersRestore.S b/libunwind/src/UnwindRegistersRestore.S
index 543b19f7e72a8..951189ea54dd2 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 e652620a4a050..76273e4a8ef0a 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() {


        


More information about the cfe-commits mailing list