summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp19
-rw-r--r--llvm/test/DebugInfo/COFF/globals.ll9
2 files changed, 19 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 6e6a76e01a7..bb959e26a8e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1998,12 +1998,23 @@ void CodeViewDebug::emitDebugInfoForGlobal(const DIGlobalVariable *DIGV,
OS.AddComment("Record length");
OS.emitAbsoluteSymbolDiff(DataEnd, DataBegin, 2);
OS.EmitLabel(DataBegin);
+ const auto *GV = cast<GlobalVariable>(DIGV->getVariable());
if (DIGV->isLocalToUnit()) {
- OS.AddComment("Record kind: S_LDATA32");
- OS.EmitIntValue(unsigned(SymbolKind::S_LDATA32), 2);
+ if (GV->isThreadLocal()) {
+ OS.AddComment("Record kind: S_LTHREAD32");
+ OS.EmitIntValue(unsigned(SymbolKind::S_LTHREAD32), 2);
+ } else {
+ OS.AddComment("Record kind: S_LDATA32");
+ OS.EmitIntValue(unsigned(SymbolKind::S_LDATA32), 2);
+ }
} else {
- OS.AddComment("Record kind: S_GDATA32");
- OS.EmitIntValue(unsigned(SymbolKind::S_GDATA32), 2);
+ if (GV->isThreadLocal()) {
+ OS.AddComment("Record kind: S_GTHREAD32");
+ OS.EmitIntValue(unsigned(SymbolKind::S_GTHREAD32), 2);
+ } else {
+ OS.AddComment("Record kind: S_GDATA32");
+ OS.EmitIntValue(unsigned(SymbolKind::S_GDATA32), 2);
+ }
}
OS.AddComment("Type");
OS.EmitIntValue(getCompleteTypeIndex(DIGV->getType()).getIndex(), 4);
diff --git a/llvm/test/DebugInfo/COFF/globals.ll b/llvm/test/DebugInfo/COFF/globals.ll
index f430bb3d34e..8e4d6e545ee 100644
--- a/llvm/test/DebugInfo/COFF/globals.ll
+++ b/llvm/test/DebugInfo/COFF/globals.ll
@@ -21,7 +21,7 @@
; ASM: .asciz "first" # Name
; ASM: .short {{.*-.*}} # Record length
-; ASM: .short 4365 # Record kind: S_GDATA32
+; ASM: .short 4371 # Record kind: S_GTHREAD32
; ASM: .long 4097 # Type
; ASM: .secrel32 "?middle@@3PEBHEB" # DataOffset
; ASM: .secidx "?middle@@3PEBHEB" # Segment
@@ -80,8 +80,7 @@
; OBJ: DisplayName: first
; OBJ: LinkageName: ?first@@3HA
; OBJ: }
-; OBJ: DataSym {
-; OBJ: Kind: S_GDATA32 (0x110D)
+; OBJ: ThreadLocalDataSym {
; OBJ: DataOffset: ?middle@@3PEBHEB+0x0
; OBJ: Type: const int* (0x1001)
; OBJ: DisplayName: middle
@@ -97,7 +96,7 @@
; OBJ: ]
; OBJ: ]
; OBJ: CodeViewDebugInfo [
-; OBJ: Section: .debug$S (6)
+; OBJ: Section: .debug$S (7)
; OBJ: Magic: 0x4
; OBJ: Subsection [
; OBJ: SubSectionType: Symbols (0xF1)
@@ -120,7 +119,7 @@ $"\01?comdat@?$A@X@@2HB" = comdat any
@"\01?first@@3HA" = internal global i32 0, align 4
@"\01?comdat@?$A@X@@2HB" = linkonce_odr constant i32 3, comdat, align 4
-@"\01?middle@@3PEBHEB" = global i32* @"\01?comdat@?$A@X@@2HB", align 8
+@"\01?middle@@3PEBHEB" = thread_local global i32* @"\01?comdat@?$A@X@@2HB", align 8
@"\01?last@@3HA" = global i32 0, align 4
!llvm.dbg.cu = !{!0}
OpenPOWER on IntegriCloud