Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISCV] Allow libunwind to build for rv32e #98855

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

ArcaneNibble
Copy link
Member

@ArcaneNibble ArcaneNibble commented Jul 15, 2024

Don't try to save x16-x31 when using rv32e ISA

Note that I haven't actually tested yet whether or not unwinding actually works on rv32e, but the code as-is doesn't even build.

@ArcaneNibble ArcaneNibble requested a review from a team as a code owner July 15, 2024 03:31
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 15, 2024

@llvm/pr-subscribers-backend-risc-v

@llvm/pr-subscribers-libunwind

Author: R (ArcaneNibble)

Changes

Don't try to save x16-x31 when using rv32e ABI

Note that I haven't actually tested yet whether or not unwinding actually works on rv32e, but the code as-is doesn't even build.


Full diff: https://github.com/llvm/llvm-project/pull/98855.diff

2 Files Affected:

  • (modified) libunwind/src/UnwindRegistersRestore.S (+4)
  • (modified) libunwind/src/UnwindRegistersSave.S (+4)
diff --git a/libunwind/src/UnwindRegistersRestore.S b/libunwind/src/UnwindRegistersRestore.S
index 67d9e05711898..837cc8a8878d8 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -1169,7 +1169,11 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_riscv6jumptoEv)
     ILOAD x\i, (RISCV_ISIZE * \i)(a0)
   .endr
   // skip a0 for now
+#if defined(__riscv_abi_rve)
+  .irp i,11,12,13,14,15
+#else
   .irp i,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
+#endif
     ILOAD x\i, (RISCV_ISIZE * \i)(a0)
   .endr
   ILOAD    x10, (RISCV_ISIZE * 10)(a0)   // restore a0
diff --git a/libunwind/src/UnwindRegistersSave.S b/libunwind/src/UnwindRegistersSave.S
index 5bf6055fe4147..30d94600bbb35 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -1108,7 +1108,11 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
 #
 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
   ISTORE    x1, (RISCV_ISIZE * 0)(a0) // store ra as pc
+#if defined(__riscv_abi_rve)
+  .irp i,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+#else
   .irp i,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
+#endif
     ISTORE x\i, (RISCV_ISIZE * \i)(a0)
   .endr
 

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me, but I have basically no knowledge of risvc or the rv32e ABI so I'll let someone else stamp this.

@ArcaneNibble
Copy link
Member Author

ping? is there someone with the necessary knowledge to review this?

@ArcaneNibble
Copy link
Member Author

ping?

@asb
Copy link
Contributor

asb commented Aug 1, 2024

@lenary @kito-cheng is this something either of you might be able to help review?

@lenary lenary self-requested a review August 1, 2024 16:17
Copy link
Member

@lenary lenary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this from a RISC-V arch/abi point of view.

@ArcaneNibble
Copy link
Member Author

I don't have write access, someone else needs to decide to merge

@kito-cheng kito-cheng merged commit b33a675 into llvm:main Aug 2, 2024
54 checks passed
@lenary
Copy link
Member

lenary commented Aug 6, 2024

@ArcaneNibble your contributions now definitely meet the threshold for commit access - please request it following the instructions in the Developer Policy: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access (also take a read of the rest of the policy to understand how the processes are expected to work once you have it)

banach-space pushed a commit to banach-space/llvm-project that referenced this pull request Aug 7, 2024
Don't try to save x16-x31 when using rv32e ISA

Note that I haven't actually tested yet whether or not unwinding
actually works on rv32e, but the code as-is doesn't even build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants