[all-commits] [llvm/llvm-project] 0f6fd1: [libc] Add support for setjmp and longjmp in riscv

Mikhail R. Gadelha via All-commits all-commits at lists.llvm.org
Fri Mar 24 12:19:50 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0f6fd1b704c014089f94271e08417a8179ee2b1c
      https://github.com/llvm/llvm-project/commit/0f6fd1b704c014089f94271e08417a8179ee2b1c
  Author: Mikhail R. Gadelha <mikhail at igalia.com>
  Date:   2023-03-24 (Fri, 24 Mar 2023)

  Changed paths:
    M clang/docs/tools/clang-formatted-files.txt
    M libc/config/linux/riscv64/entrypoints.txt
    M libc/config/linux/riscv64/headers.txt
    M libc/include/llvm-libc-types/jmp_buf.h
    M libc/src/setjmp/CMakeLists.txt
    R libc/src/setjmp/longjmp.cpp
    A libc/src/setjmp/riscv64/CMakeLists.txt
    A libc/src/setjmp/riscv64/longjmp.cpp
    A libc/src/setjmp/riscv64/setjmp.cpp
    R libc/src/setjmp/setjmp.cpp
    A libc/src/setjmp/x86_64/CMakeLists.txt
    A libc/src/setjmp/x86_64/longjmp.cpp
    A libc/src/setjmp/x86_64/setjmp.cpp

  Log Message:
  -----------
  [libc] Add support for setjmp and longjmp in riscv

This patch implements setjmp and longjmp in riscv using inline asm. The
following changes were required:

* Omit frame pointer: otherwise gcc won't allow us to use s0
* Use __attribute__((naked)): otherwise both gcc and clang will generate
function prologue and epilogue in both functions. This doesn't happen
in x86_64, so we guard it to only riscv

Furthermore, using __attribute__((naked)) causes two problems: we
can't use `return 0` (both gcc and clang) and the function arguments in
the function body (clang only), so we had to use a0 and a1 directly.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145584




More information about the All-commits mailing list