================
@@ -68,9 +68,6 @@ void CIRGenModule::setGlobalTlsReferences(const VarDecl &vd,
   if (!getLangOpts().CPlusPlus)
----------------
bcardosolopes wrote:

Different axis, I mean the keyword, not the model. Same local-dynamic you used, 
on your branch:

```c++
int f();
__thread      int a = 5;
_Thread_local int b = 5;
thread_local  int c = 5;
thread_local  int d = f();
```

```
$ clang -cc1 -triple x86_64-pc-linux-gnu -std=c++17 -ftls-model=local-dynamic \
        -emit-llvm -o - t.cpp | grep '^define.*_ZTW'
define weak_odr hidden noundef ptr @_ZTW1c() #3 comdat {
define weak_odr hidden noundef ptr @_ZTW1d() #3 comdat {

$ clang -cc1 -triple x86_64-pc-linux-gnu -std=c++17 -ftls-model=local-dynamic \
        -fclangir -emit-llvm -o - t.cpp | grep '^define.*_ZTW'
define weak_odr hidden ptr @_ZTW1d() {
define weak_odr hidden ptr @_ZTW1c() {
define weak_odr hidden ptr @_ZTW1b() {
define weak_odr hidden ptr @_ZTW1a() {
```

c/d is your fix, and it's right. Swap in any of the four models and OG's two 
lines don't move, so there's nothing model-shaped to match.

a/b is what I'm pointing at. `__thread` and `_Thread_local` are `TLS_Static`, 
only `thread_local` is `TLS_Dynamic` (`VarDecl::getTLSKind`), and the gate OG 
actually has is on the kind: `if (D->getTLSKind() == VarDecl::TLS_Dynamic) 
CXXThreadLocals.push_back(D);` (CodeGenModule.cpp:6014 and 6708). We don't have 
that one, so we wrap `__thread` too. On main it only showed up under the 
default model, now it's all four. Worth adding the kind check here?

https://github.com/llvm/llvm-project/pull/215380
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to