[PATCH] D79028: [DebugInfo][CodeView] Include namespace into emitted globals

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 13:27:03 PDT 2020


rnk added inline comments.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:3116
+        OS,
+        DataSym == SymbolKind::S_LTHREAD32
+            ? DIGV->getName()
----------------
I think this isn't quite right. Consider:
```
$ 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 t.cpp  -Z7 && llvm-pdbutil dump -symbols t.obj  | grep 'THREA\|DATA'
Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28612 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

t.cpp
       0 | S_LTHREAD32 [size = 23] `func_tls`
       0 | S_LDATA32 [size = 26] `func_static`
       0 | S_GTHREAD32 [size = 30] `foo::global_tls`
       0 | S_LTHREAD32 [size = 30] `foo::static_tls`
```

It's function local TLS that shouldn't receive a fully qualified name. Let's handle that separately. Those are probably less common. I'm OK committing the previous patchset and handling function local globals separately.

To fix function local globals (thread local or otherwise), we have to walk up the DIGV scope and see if any of them is a subprogram. We have some existing logic for this for UDTs (typedefs).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79028





More information about the llvm-commits mailing list