[PATCH] D79005: [LLD][COFF] Move debug info for thread-local variables into PDB global stream

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 14:00:21 PDT 2020


rnk added inline comments.


================
Comment at: lld/COFF/PDB.cpp:808
   case SymbolKind::S_UDT:
     return !isGlobalScope;
   // S_GDATA32 does not go in the module stream, but S_LDATA32 does.
----------------
Looks like we need to send S_LDATA32 to here.


================
Comment at: lld/test/COFF/Inputs/pdb-globals.yaml:41
+#   // S_LTHREAD32
+#   thread_local int LocalThreadLocal = 45;
+#   N += LocalThreadLocal;
----------------
rnk wrote:
> Huh, `static thread_local int` at global scope doesn't do it? And these don't show up in the PDB's global stream?
The example I came up with probably makes a better test case here, and we can handle function local globals (thread local or regular globals) in a follow-up.
```
$ cat t.cpp
namespace foo {
thread_local int global_tls;
int global_int() { return ++global_tls; }
static thread_local int static_tls;
int static_int() { return ++static_tls; }
int func_int() {
  thread_local int func_tls;
  return ++func_tls;
}
int func_static_int() {
  static int func_static;
  return ++func_static;
}
}

$ cl -c -Z7 t.cpp && link -dll -force t.obj  -debug && llvm-pdbutil dump -globals t.pdb | grep S_[LG]THREAD
Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28612 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

t.cpp
Microsoft (R) Incremental Linker Version 14.25.28612.0
Copyright (C) Microsoft Corporation.  All rights reserved.

     384 | S_LTHREAD32 [size = 32] `foo::static_tls`
     352 | S_GTHREAD32 [size = 32] `foo::global_tls`
```

I think we need to reuse the local S_UDT logic here, and return `isGlobalScope` from `symbolGoesInGlobalsStream`. Perhaps S_LDATA32 needs the same treatment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79005





More information about the llvm-commits mailing list