From 3ceb1244c861447bc5edea3f2b8e550fc04b0194 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Thu, 7 Jul 2016 05:14:21 +0000 Subject: [PATCH] [CodeView] Implement support for thread-local variables git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274734 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 19 +++++++++++++++---- test/DebugInfo/COFF/globals.ll | 9 ++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 6e6a76e01a7..bb959e26a8e 100644 --- a/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/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(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/test/DebugInfo/COFF/globals.ll b/test/DebugInfo/COFF/globals.ll index f430bb3d34e..8e4d6e545ee 100644 --- a/test/DebugInfo/COFF/globals.ll +++ b/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}