[libcxx-commits] [PATCH] D107042: [libunwind][OR1K] Fix register restore on resume

Oi Chee Cheung via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 29 00:53:47 PDT 2021


occheung created this revision.
occheung added a reviewer: whitequark.
occheung added a project: libunwind.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libunwind.
occheung requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently, OR1K architecture put the program counter at offset 0x128 of the current `or1k_thread_state_t`. However, the PC is restored after updating the thread pointer in `r3`, which causes the PC to be fetched incorrectly.

This patch swaps the order of restoration of `r9` and `r3`, such that the PC is restored to `r9` using the current thread state.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107042

Files:
  libunwind/src/UnwindRegistersRestore.S


Index: libunwind/src/UnwindRegistersRestore.S
===================================================================
--- libunwind/src/UnwindRegistersRestore.S
+++ libunwind/src/UnwindRegistersRestore.S
@@ -800,11 +800,12 @@
   l.lwz    r30,120(r3)
   l.lwz    r31,124(r3)
 
+  # load new pc into ra
+  l.lwz    r9, 128(r3)
+
   # at last, restore r3
   l.lwz    r3,  12(r3)
 
-  # load new pc into ra
-  l.lwz    r9, 128(r3)
   # jump to pc
   l.jr     r9
    l.nop


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107042.362660.patch
Type: text/x-patch
Size: 464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210729/3c5b1688/attachment.bin>


More information about the libcxx-commits mailing list