[llvm] r274676 - [CodeView] Emit an appropriate symbol kind for globals

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 6 14:07:47 PDT 2016


Author: majnemer
Date: Wed Jul  6 16:07:47 2016
New Revision: 274676

URL: http://llvm.org/viewvc/llvm-project?rev=274676&view=rev
Log:
[CodeView] Emit an appropriate symbol kind for globals

We emitted debug info for globals/functions as if they all had external
linkage.  Instead, emit local symbol records when appropriate.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp
    llvm/trunk/test/DebugInfo/COFF/globals-discarded.ll
    llvm/trunk/test/DebugInfo/COFF/globals.ll
    llvm/trunk/test/DebugInfo/COFF/multifunction.ll
    llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=274676&r1=274675&r2=274676&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Wed Jul  6 16:07:47 2016
@@ -642,8 +642,13 @@ void CodeViewDebug::emitDebugInfoForFunc
     OS.emitAbsoluteSymbolDiff(ProcRecordEnd, ProcRecordBegin, 2);
     OS.EmitLabel(ProcRecordBegin);
 
+  if (GV->hasLocalLinkage()) {
+    OS.AddComment("Record kind: S_LPROC32_ID");
+    OS.EmitIntValue(unsigned(SymbolKind::S_LPROC32_ID), 2);
+  } else {
     OS.AddComment("Record kind: S_GPROC32_ID");
     OS.EmitIntValue(unsigned(SymbolKind::S_GPROC32_ID), 2);
+  }
 
     // These fields are filled in by tools like CVPACK which run after the fact.
     OS.AddComment("PtrParent");
@@ -1993,8 +1998,13 @@ void CodeViewDebug::emitDebugInfoForGlob
   OS.AddComment("Record length");
   OS.emitAbsoluteSymbolDiff(DataEnd, DataBegin, 2);
   OS.EmitLabel(DataBegin);
-  OS.AddComment("Record kind: S_GDATA32");
-  OS.EmitIntValue(unsigned(SymbolKind::S_GDATA32), 2);
+  if (DIGV->isLocalToUnit()) {
+    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);
+  }
   OS.AddComment("Type");
   OS.EmitIntValue(getCompleteTypeIndex(DIGV->getType()).getIndex(), 4);
   OS.AddComment("DataOffset");

Modified: llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp?rev=274676&r1=274675&r2=274676&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp Wed Jul  6 16:07:47 2016
@@ -279,6 +279,7 @@ void CVSymbolDumperImpl::visitConstantSy
 void CVSymbolDumperImpl::visitDataSym(SymbolKind Kind, DataSym &Data) {
   DictScope S(W, "DataSym");
 
+  W.printEnum("Kind", uint16_t(Kind), getSymbolTypeNames());
   StringRef LinkageName;
   if (ObjDelegate) {
     ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
@@ -552,6 +553,7 @@ void CVSymbolDumperImpl::visitProcSym(Sy
   InFunctionScope = true;
 
   StringRef LinkageName;
+  W.printEnum("Kind", uint16_t(Kind), getSymbolTypeNames());
   W.printHex("PtrParent", Proc.Header.PtrParent);
   W.printHex("PtrEnd", Proc.Header.PtrEnd);
   W.printHex("PtrNext", Proc.Header.PtrNext);

Modified: llvm/trunk/test/DebugInfo/COFF/globals-discarded.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/globals-discarded.ll?rev=274676&r1=274675&r2=274676&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/globals-discarded.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/globals-discarded.ll Wed Jul  6 16:07:47 2016
@@ -3,7 +3,7 @@
 ; This tests that we don't emit information about globals that were discarded
 ; during optimization. We should only see one global symbol record.
 
-; CHECK: .short  4365                    # Record kind: S_GDATA32
+; CHECK: .short  4364                    # Record kind: S_LDATA32
 ; CHECK: .long   117                     # Type
 ; CHECK: .secrel32       x               # DataOffset
 ; CHECK: .secidx x                       # Segment

Modified: llvm/trunk/test/DebugInfo/COFF/globals.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/globals.ll?rev=274676&r1=274675&r2=274676&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/globals.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/globals.ll Wed Jul  6 16:07:47 2016
@@ -14,7 +14,7 @@
 ; ASM:        .long   4                       # Debug section magic
 
 ; ASM:        .short  {{.*-.*}}               # Record length
-; ASM:        .short  4365                    # Record kind: S_GDATA32
+; ASM:        .short  4364                    # Record kind: S_LDATA32
 ; ASM:        .long   116                     # Type
 ; ASM:        .secrel32       "?first@@3HA"   # DataOffset
 ; ASM:        .secidx "?first@@3HA"           # Segment
@@ -74,18 +74,21 @@
 ; OBJ:   Subsection [
 ; OBJ:     SubSectionType: Symbols (0xF1)
 ; OBJ:     DataSym {
+; OBJ:       Kind: S_LDATA32 (0x110C)
 ; OBJ:       DataOffset: ?first@@3HA+0x0
 ; OBJ:       Type: int (0x74)
 ; OBJ:       DisplayName: first
 ; OBJ:       LinkageName: ?first@@3HA
 ; OBJ:     }
 ; OBJ:     DataSym {
+; OBJ:       Kind: S_GDATA32 (0x110D)
 ; OBJ:       DataOffset: ?middle@@3PEBHEB+0x0
 ; OBJ:       Type: const int* (0x1001)
 ; OBJ:       DisplayName: middle
 ; OBJ:       LinkageName: ?middle@@3PEBHEB
 ; OBJ:     }
 ; OBJ:     DataSym {
+; OBJ:       Kind: S_GDATA32 (0x110D)
 ; OBJ:       DataOffset: ?last@@3HA+0x0
 ; OBJ:       Type: int (0x74)
 ; OBJ:       DisplayName: last
@@ -115,7 +118,7 @@ target triple = "x86_64-pc-windows-msvc1
 
 $"\01?comdat@?$A at X@@2HB" = comdat any
 
-@"\01?first@@3HA" = global i32 0, align 4
+@"\01?first@@3HA" = internal global i32 0, align 4
 @"\01?comdat@?$A at X@@2HB" = linkonce_odr constant i32 3, comdat, align 4
 @"\01?middle@@3PEBHEB" = global i32* @"\01?comdat@?$A at X@@2HB", align 8
 @"\01?last@@3HA" = global i32 0, align 4
@@ -128,7 +131,7 @@ $"\01?comdat@?$A at X@@2HB" = comdat any
 !1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
 !2 = !{}
 !3 = !{!4, !6, !13, !15}
-!4 = distinct !DIGlobalVariable(name: "first", linkageName: "\01?first@@3HA", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, variable: i32* @"\01?first@@3HA")
+!4 = distinct !DIGlobalVariable(name: "first", linkageName: "\01?first@@3HA", scope: !0, file: !1, line: 1, type: !5, isLocal: true, isDefinition: true, variable: i32* @"\01?first@@3HA")
 !5 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
 !6 = distinct !DIGlobalVariable(name: "comdat", linkageName: "\01?comdat@?$A at X@@2HB", scope: !0, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, variable: i32* @"\01?comdat@?$A at X@@2HB", declaration: !8)
 !7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !5)

Modified: llvm/trunk/test/DebugInfo/COFF/multifunction.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/multifunction.ll?rev=274676&r1=274675&r2=274676&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/multifunction.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/multifunction.ll Wed Jul  6 16:07:47 2016
@@ -60,7 +60,7 @@
 ; X86-NEXT: [[F1_START]]:
 ; X86-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] #
 ; X86-NEXT: [[PROC_SEGMENT_START]]:
-; X86-NEXT: .short  4423
+; X86-NEXT: .short  4422
 ; X86-NEXT: .long   0
 ; X86-NEXT: .long   0
 ; X86-NEXT: .long   0
@@ -154,6 +154,7 @@
 ; OBJ32-NEXT:   SubSectionType: Symbols (0xF1)
 ; OBJ32-NOT:    ]
 ; OBJ32:        ProcStart {
+; OBJ32:          Kind: S_LPROC32_ID (0x1146)
 ; OBJ32:          CodeSize: 0x6
 ; OBJ32:          DisplayName: x
 ; OBJ32:          LinkageName: _x
@@ -168,6 +169,7 @@
 ; OBJ32-NEXT:   SubSectionType: Symbols (0xF1)
 ; OBJ32-NOT:    ]
 ; OBJ32:        ProcStart {
+; OBJ32:          Kind: S_GPROC32_ID (0x1147)
 ; OBJ32:          CodeSize: 0x6
 ; OBJ32:          DisplayName: y
 ; OBJ32:          LinkageName: _y
@@ -182,6 +184,7 @@
 ; OBJ32-NEXT:   SubSectionType: Symbols (0xF1)
 ; OBJ32-NOT:    ]
 ; OBJ32:        ProcStart {
+; OBJ32:          Kind: S_GPROC32_ID (0x1147)
 ; OBJ32:          CodeSize: 0x10
 ; OBJ32:          DisplayName: f
 ; OBJ32:          LinkageName: _f
@@ -324,7 +327,7 @@
 ; X64-NEXT: [[F1_START]]:
 ; X64-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] #
 ; X64-NEXT: [[PROC_SEGMENT_START]]:
-; X64-NEXT: .short  4423
+; X64-NEXT: .short  4422
 ; X64-NEXT: .long   0
 ; X64-NEXT: .long   0
 ; X64-NEXT: .long   0
@@ -420,6 +423,7 @@
 ; OBJ64-NEXT:   SubSectionType: Symbols (0xF1)
 ; OBJ64-NOT:    ]
 ; OBJ64:        ProcStart {
+; OBJ64:          Kind: S_LPROC32_ID (0x1146)
 ; OBJ64:          CodeSize: 0xE
 ; OBJ64:          DisplayName: x
 ; OBJ64:          LinkageName: x
@@ -434,6 +438,7 @@
 ; OBJ64-NEXT:   SubSectionType: Symbols (0xF1)
 ; OBJ64-NOT:    ]
 ; OBJ64:        ProcStart {
+; OBJ64:          Kind: S_GPROC32_ID (0x1147)
 ; OBJ64:          CodeSize: 0xE
 ; OBJ64:          DisplayName: y
 ; OBJ64:          LinkageName: y
@@ -448,6 +453,7 @@
 ; OBJ64-NEXT:   SubSectionType: Symbols (0xF1)
 ; OBJ64-NOT:    ]
 ; OBJ64:        ProcStart {
+; OBJ64:          Kind: S_GPROC32_ID (0x1147)
 ; OBJ64:          CodeSize: 0x18
 ; OBJ64:          DisplayName: f
 ; OBJ64:          LinkageName: f
@@ -561,7 +567,7 @@
 ; OBJ64-NEXT: ]
 
 ; Function Attrs: nounwind
-define void @x() #0 !dbg !4 {
+define internal void @x() #0 !dbg !4 {
 entry:
   call void @z(), !dbg !14
   ret void, !dbg !15

Modified: llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test?rev=274676&r1=274675&r2=274676&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test (original)
+++ llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test Wed Jul  6 16:07:47 2016
@@ -292,6 +292,7 @@
 ; EMPTY-NEXT:         }
 ; EMPTY-NEXT:         {
 ; EMPTY-NEXT:           ProcStart {
+; EMPTY-NEXT:             Kind: S_GPROC32 (0x1110)
 ; EMPTY-NEXT:             PtrParent: 0x0
 ; EMPTY-NEXT:             PtrEnd: 0xC4
 ; EMPTY-NEXT:             PtrNext: 0x0
@@ -842,6 +843,7 @@
 ; EMPTY-NEXT:     }
 ; EMPTY-NEXT:     {
 ; EMPTY-NEXT:       DataSym {
+; EMPTY-NEXT:         Kind: S_GDATA32 (0x110D)
 ; EMPTY-NEXT:         Type: void* (0x403)
 ; EMPTY-NEXT:         DisplayName: __purecall
 ; EMPTY-NEXT:       }




More information about the llvm-commits mailing list