[libc-commits] [PATCH] D159110: [libc] Fix set_thread_ptr call in rv32 start up code

Jessica Clarke via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Aug 29 14:27:32 PDT 2023


jrtc27 requested changes to this revision.
jrtc27 added a comment.
This revision now requires changes to proceed.

> as rv32 doesn't have the ld instruction.

More importantly, even if it did, pointers are 32-bit values not 64-bit values. But regardless, the original RV64 code is wrong, it's doing a load not a move, so is setting tp to whatever the first pointer in the static TLS block happens to be, which is clearly nonsense. This should just be:

  static void set_thread_ptr(uintptr_t val) {
    LIBC_INLINE_ASM("mv tp, %0\n\t" : : "r"(val));
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159110



More information about the libc-commits mailing list