[PATCH] D130053: [WebAssembly] Use `localexec` as default TLS model for non-Emscripten targets

Petr Penzin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 01:09:29 PDT 2022


penzn added a comment.

Looks like the effect of the change would be to ignore thread local mode selection for non-Emscripten triples, always picking `localexec`, while preserving the behavior for Emscripten. Maybe it would be good to clarify that in the change description.

Just out of curiosity: why does disabling bulk-memory disable TLS?



================
Comment at: llvm/test/CodeGen/WebAssembly/tls-local-exec.ll:94
 
- at tls_external = external thread_local(localexec) global i32, align 4
+ at tls_external = external thread_local global i32, align 4
 
----------------
sbc100 wrote:
> abrown wrote:
> > sbc100 wrote:
> > > Shouldn't we leave this file as is, with the explicit TLS model?   (according the language reference the default thread model is general dynamic: https://llvm.org/docs/LangRef.html#thread-local-storage-models "If no explicit model is given, the “general dynamic” model is used.").
> > > 
> > > I guess you are trying to test here that general dynamic is treated "as if" its local-exec,  but we also want to test how the explicit local-exec works, no?    Would we use a macro to and run this entire test with `(localexec)` and with the empty string to check they produce the same results?
> > Sure, that makes sense. Can you point me to an example of how to setup such a macro?
> You can do `git grep "FileCheck.* -D"` to find a lot of examples in llvm.
> Shouldn't we leave this file as is, with the explicit TLS model?   (according the language reference the default thread model is general dynamic: https://llvm.org/docs/LangRef.html#thread-local-storage-models "If no explicit model is given, the “general dynamic” model is used.").
> 
> I guess you are trying to test here that general dynamic is treated "as if" its local-exec,  but we also want to test how the explicit local-exec works, no?    Would we use a macro to and run this entire test with `(localexec)` and with the empty string to check they produce the same results?




================
Comment at: llvm/test/CodeGen/WebAssembly/tls-local-exec.ll:94
 
- at tls_external = external thread_local(localexec) global i32, align 4
+ at tls_external = external thread_local global i32, align 4
 
----------------
penzn wrote:
> sbc100 wrote:
> > abrown wrote:
> > > sbc100 wrote:
> > > > Shouldn't we leave this file as is, with the explicit TLS model?   (according the language reference the default thread model is general dynamic: https://llvm.org/docs/LangRef.html#thread-local-storage-models "If no explicit model is given, the “general dynamic” model is used.").
> > > > 
> > > > I guess you are trying to test here that general dynamic is treated "as if" its local-exec,  but we also want to test how the explicit local-exec works, no?    Would we use a macro to and run this entire test with `(localexec)` and with the empty string to check they produce the same results?
> > > Sure, that makes sense. Can you point me to an example of how to setup such a macro?
> > You can do `git grep "FileCheck.* -D"` to find a lot of examples in llvm.
> > Shouldn't we leave this file as is, with the explicit TLS model?   (according the language reference the default thread model is general dynamic: https://llvm.org/docs/LangRef.html#thread-local-storage-models "If no explicit model is given, the “general dynamic” model is used.").
> > 
> > I guess you are trying to test here that general dynamic is treated "as if" its local-exec,  but we also want to test how the explicit local-exec works, no?    Would we use a macro to and run this entire test with `(localexec)` and with the empty string to check they produce the same results?
> 
> 
> Sure, that makes sense. Can you point me to an example of how to setup such a macro?




================
Comment at: llvm/test/CodeGen/WebAssembly/tls-local-exec.ll:94
 
- at tls_external = external thread_local(localexec) global i32, align 4
+ at tls_external = external thread_local global i32, align 4
 
----------------
penzn wrote:
> penzn wrote:
> > sbc100 wrote:
> > > abrown wrote:
> > > > sbc100 wrote:
> > > > > Shouldn't we leave this file as is, with the explicit TLS model?   (according the language reference the default thread model is general dynamic: https://llvm.org/docs/LangRef.html#thread-local-storage-models "If no explicit model is given, the “general dynamic” model is used.").
> > > > > 
> > > > > I guess you are trying to test here that general dynamic is treated "as if" its local-exec,  but we also want to test how the explicit local-exec works, no?    Would we use a macro to and run this entire test with `(localexec)` and with the empty string to check they produce the same results?
> > > > Sure, that makes sense. Can you point me to an example of how to setup such a macro?
> > > You can do `git grep "FileCheck.* -D"` to find a lot of examples in llvm.
> > > Shouldn't we leave this file as is, with the explicit TLS model?   (according the language reference the default thread model is general dynamic: https://llvm.org/docs/LangRef.html#thread-local-storage-models "If no explicit model is given, the “general dynamic” model is used.").
> > > 
> > > I guess you are trying to test here that general dynamic is treated "as if" its local-exec,  but we also want to test how the explicit local-exec works, no?    Would we use a macro to and run this entire test with `(localexec)` and with the empty string to check they produce the same results?
> > 
> > 
> > Sure, that makes sense. Can you point me to an example of how to setup such a macro?
> 
> 
> Shouldn't we leave this file as is, with the explicit TLS model?   (according the language reference the default thread model is general dynamic: https://llvm.org/docs/LangRef.html#thread-local-storage-models "If no explicit model is given, the “general dynamic” model is used.").

Target is allowed to change model even if it is supported, "The target may choose a different TLS model if the specified model is not supported, or if a better choice of model can be made."

> I guess you are trying to test here that general dynamic is treated "as if" its local-exec,  but we also want to test how the explicit local-exec works, no?    Would we use a macro to and run this entire test with `(localexec)` and with the empty string to check they produce the same results?

This might affect more than general-dynamic vs local-exec, but I am not sure it is realistically to test for all possible ones. I think macro would be on the IR side, not FileCheck side (latter should get the same input), and I can't recall how we express something like that.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130053



More information about the llvm-commits mailing list