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

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Aug 29 16:38:14 PDT 2023


sivachandra added a comment.

In D159110#4626672 <https://reviews.llvm.org/D159110#4626672>, @jrtc27 wrote:

> In D159110#4626668 <https://reviews.llvm.org/D159110#4626668>, @sivachandra wrote:
>
>> For my knowledge, what is wrong with a `tp` load in the existing code?
>
> Well it's the difference between `x = p` and `x = *p`. Only one is ever the right thing to do. Like I said, "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", i.e. you're reading in the first `sizeof(void *)` bytes of data from `.tdata` (or `.tbss`) and using that as the thread pointer, not the region of memory that just got mapped for the thread pointer.

Shouldn't the `ld` operation overwrite `tp` and not read from `tp`? The assembly looks like this: https://godbolt.org/z/PTqfTcshv


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