[libc-commits] [PATCH] D145584: [libc] Add support for setjmp and longjmp in riscv

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Mar 24 01:03:11 PDT 2023


sivachandra accepted this revision.
sivachandra added inline comments.
This revision is now accepted and ready to land.


================
Comment at: libc/src/setjmp/riscv64/longjmp.cpp:54-55
+
+  LIBC_INLINE_ASM("seqz %0, %1" : "+r"(buf) : "r"(val) :);
+  LIBC_INLINE_ASM("add %0, %0, %1" : "+r"(buf) : "r"(val), "r"(buf) :);
+}
----------------
Your comment is in the previous diff but thanks for the explanation. I think we have missed the `val` check for zero in the x86_64 case and should be fixed separately.

For the above two instructions, in the interest of reducing the amount of logic in inline assembly, can we do:

```
  val = val == 0 ? 1 : val;
  LIBC_INLINE_ASM("add a0, %0, zero\n\t" : : "r"(val) :);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145584/new/

https://reviews.llvm.org/D145584



More information about the libc-commits mailing list