This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Add support for thread-local data
Needs ReviewPublic

Authored by ncw on Mar 10 2018, 3:18 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

MOSTLY FINISHED - SOME BITS STILL TO TIDY UP

  • Enables users to use static __thread int threadLocalValue variable declarations
  • Enables Musl to use the existing __builtin_thread_pointer() intrinsic to read from the "thread-local register" (on x86 that intrinsic would be reading the %fs register, on ARM it might be the CP15 register?)

OK, OK, I know Wasm doesn't have threads quite yet - but it will do soon, surely sometime in 2018. At that point having the infrastructure in place would be quite nice.

I'm implementing the Itanium TLS ABI, as on ARM (x86 has a weird legacy model).

TODO:

  • Add some tests
  • Add an intrinsic __builtin_wasm_set_thread_pointer() to allow Musl to initialise its TLS block
  • Open the corresponding review for LLD (halfway done, I put it to one side about a month ago)

Diff Detail

Event Timeline

ncw created this revision.Mar 10 2018, 3:18 AM